In my app, I have to use an AudioPlaybackAgent (APA) and a mediaelement. I used the APA to play songs , and when I need to play video, I use the MediaElement
When I navigate to a page use the MediaElement, I stop the BackgroundAudioPlayer:
BackgroundAudioPlayer.Instance.Pause();
When I navigate back to a page which need to play music, I call the APA to start again, but now it return the exception "The background audio resources are no longer available." :(
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
try
{
if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Playing)
BackgroundAudioPlayer.Instance.Play();
}
catch
{
BackgroundAudioPlayer.Instance.Play();
}
}
I can use the MediaPlayerLauncher , but this solution has many disvantage (only fullscreen, lack of my custom control ...). So is there any way to make the media element work along with the AudioPlaybackAgent, or any other way to playing video ???