MediaPlayerLauncher on WP7 - how to resume previously playing media?

此生再无相见时 提交于 2019-12-05 07:47:10

Local media playing through XNA or a 'background audio agent'?

When you play media in WP7 / WP8, the OS audio context is taken, and the original context is lost. If the audio was launched from an external application, then you cannot resume at all. If the previous media was launched from within your application, then you could store the meta-data and re-play once your trailer is finished. The media would, of course, then begin playing from the start, rather than where the user left off. Unfortunately XNA does not allow you to seek within a given piece of media; however you can seek within an 'audio agent' instance of 'BackgroundAudioPlayer' by setting player.Position. It's also worth looking at the MediaHistory API:

var nowPlaying = Microsoft.Devices.MediaHistory.Instance.NowPlaying;

Figured it out. Calling MediaPlayer.Resume() right after show() solves the issue:

mpl.Media = new Uri(trailerurl, UriKind.Absolute);
mpl.Controls = MediaPlaybackControls.All;
mpl.Show();

MediaPlayer.Resume();

However, i would still like to know how to resume radio and spotify!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!