This project is read-only.

Play in background ?

Topics: Windows 8 Xaml
Sep 18, 2012 at 8:28 AM


It's possible to keep playing (for example remote MP3) while application is NOT active ?


Thank you

Sep 18, 2012 at 10:19 PM

Andrew, the AudioCategory property will determine the behavior of media while the app is inactive.

BackgroundCapableMedia is what you want.

Regards, Tim

Oct 19, 2012 at 4:13 AM
Edited Oct 19, 2012 at 5:10 AM

I have set the property to BackgroundCapableMedia, but when I go to another application, the player stops playing. Have I done something wrong or can an app running in debug mode not fire this capability?

From reading around the Internet, there are some app settings that need to be set to allow media to play background.  I have set Task Type="audio" in the extensions but still no dice.

Oct 19, 2012 at 8:05 AM

I think you must set some events to your player :

  MediaControl.PlayPressed += ....;
  MediaControl.PausePressed += ...;
  MediaControl.PlayPauseTogglePressed += ....;
  MediaControl.StopPressed += ...;



Oct 20, 2012 at 3:01 AM

When I try to add that code, I receive the error:

'Public Shared Event PlayPressed(sender As Object, e As Object)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

I also cannot set the Subs to handle the event directly because the operating system does not declare the public object WithEvents.

Nov 4, 2012 at 7:16 PM

I also added the media element but when suspending the application it stops playing, can some one help with this ?

(Like in a step by step tutorial)

Apr 13, 2013 at 8:26 AM
seems like old thread but is the guide:
Apr 15, 2013 at 6:46 PM
Fyi: the v1.1 release introduced a new plugin called MediaControlPlugin. This plugin automatically wires up the MediaControl events for you so you no longer have to perform this step. Or, if you have your own code in place already and want to continue using it instead of the built in plugin, you can easily disable the plugin by setting it's IsEnabled property to false.
        public MainPage()
            player.Initializing += player_Initializing;
        void player_Initializing(object sender, MediaPlayerDeferrableEventArgs e)
            var mediaControlPlugin = player.Plugins.OfType<MediaControlPlugin>().First();
            mediaControlPlugin.IsEnabled = false;