所以我尝试了几种不同的方法,这就是我所在的位置:
我使用此线程中显示的方法在 App.xaml 中设置 MediaElement(导航到其他页面后继续播放的全局 MediaElement)。切换窗格时保持音乐播放效果很好......
我设置播放器处理程序的方式是将所有方法(例如播放、暂停、下一曲目等)添加到 LayoutAware 页面。这样我就可以从任何视图控制播放器。当应用程序处于焦点时效果很好
如果我离开播放音乐的原始视图,并切换到另一个应用程序,它会继续在后台播放,这就是我想要的
但是,如果我先更改为不同的视图,然后将应用程序移至后台,它就会停止!
只有当我离开第一次开始播放音乐的面板时,它才会这样做。
例如,如果我这样做:
1. launch the app
2. select a track (launches NowPlaying View)
3. Play the track and leave it on that same view
4. Navigate to a different app or the desktop, leaving the app running in the background
该应用程序继续播放音乐。
如果我那么:
5. Navigate back to the app
6. click "Back" to select a different track
7. navigate to a different app or the desktop leaving the app running in the background
音乐停止!
任何人都知道为什么会发生这种情况?如果您需要更多关于我如何设置的说明,请告诉我。