Frage

so I tried a few different approaches, and here is where I am:

I setup the MediaElement in the App.xaml using the method shown in this thread (Global MediaElement that continues playing after navigating to other page). It works great to keep music playing when switching panes...

The way I setup the player handlers was to add all the methods (such as Play, Pause, next track, etc) to the LayoutAware page. This way I can control the player from any View. It works great when the app is in focus

If I leave the original view that played the music, and switch to another app, it keeps playing in the background, which is what I want

However, if I first change to a different view, and then move the app to the background, it stops!

It only does this when I navigate away from the panel that first started playing the music.

For example, if I do this:

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

The app continues playing music.

If I then:

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

the music stops!

Anyone have any ideas why this would happen? please let me know if you need more clarification about how I've set this up.

War es hilfreich?

Lösung

oops this was entirely user error.

I added the handlers for the MediaControl events in the page load, but was removing then OnNavigatedFrom.

I moved the unregister code to the Unloaded event, and now they remain in place so that the music can keep playing!

So in summary: make sure you have your MediaControl event handlers in place and in scope to keep music playing in the background!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top