播放背景声音地铁应用程序

时间:2013-06-11 00:16:45

标签: c# audio windows-8 windows-runtime

我正在尝试在后台播放声音,但只有当我的alt标签停止播放时它才会在前景中播放...

snd = new MediaElement();
snd.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.BackgroundCapableMedia;
StorageFolder folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
StorageFile file = await folder.GetFileAsync("hey.mp3");
var stream = await file.OpenAsync(FileAccessMode.Read);
snd.SetSource(stream, file.ContentType);
snd.Play();

1 个答案:

答案 0 :(得分:1)

以下是来自MSDN的Background Audio in WinRT with C#的示例