MediaElement player = new MediaElement();
player.Source = new Uri("ms-appx:///Assets/Media/backgroundtrack.mp3");
player.Volume = 100;
player.Play();
这段代码有什么问题?当我运行程序时,没有声音。
答案 0 :(得分:0)
var folder = await StorageFolder.GetFolderFromPathAsync("ms-appx:///Assets/Media");
if(folder != null)
{
var file = await folder.GetFileAsync("backgroundtrack.mp3");
if(file != null)
{
var stream = await file.OpenReadAsync();
mediaElement.SetSource(stream, file.ContentType);
player.Volume = 100;
player.Play();
}
}