如何在UWP的背景中播放音频
问题描述:
我使用UWP for Windows 10创建了媒体播放器应用程序。目前我无法在后台播放任何音频,当我最小化媒体播放器窗口时,音频停止播放并在我恢复时最大化窗口。这是我的媒体元素XAML代码我使用:如何在UWP的背景中播放音频
<MediaElement x:Name="PlayerElement" Height="532" Width="829"
AreTransportControlsEnabled="True" Stretch="Uniform" HorizontalAlignment="Center"
VerticalAlignment="Center" PosterSource="/Images/Logo3.png"
AutoPlay="True" MediaEnded="PlayNewSong" Margin="0,0,-9,0" AudioCategory="BackgroundCapableMedia"/>
我以为AudioCategory财产会解决我的问题,但遗憾的是它没有。任何帮助,将不胜感激。
答
这个官方样本收集你可以拉您需要样本项目BackgroundMediaPlayback文件夹。
+0
artista_14是正确的。有上面提供的示例链接和教程在这里:https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/background- audio – chcortes
https://stackoverflow.com/questions/37120489/whats-the-easiest-way-to-play-audio-in-background-in-uwp –
我做到了,它没有工作.. –