Background​Media​Player Background​Media​Player Background​Media​Player Class

Definition

Provides access to the media player while it is running in the background.

public static class BackgroundMediaPlayerpublic static class BackgroundMediaPlayerPublic Static Class BackgroundMediaPlayer
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Starting with Windows 10, version 1607, apps should use the MediaPlayer for media playback. This object allows you to play media in the background seamlessly, using a single process. For information on using MediaPlayer, see Play audio and video with MediaPlayer. For information on playing media in the background with MediaPlayer, see Play media in the background. For information on the legacy, two-process background playback model, which is still supported for backwards compatibility, see Legacy background media playback.

Properties

Current Current Current

Gets the current instance of the background media player.

public static MediaPlayer Current { get; }public static MediaPlayer Current { get; }Public Static ReadOnly Property Current As MediaPlayer
Value
MediaPlayer MediaPlayer MediaPlayer

The current instance of the background media player.

Attributes

Methods

IsMediaPlaying() IsMediaPlaying() IsMediaPlaying()

Returns a Boolean value indicating if other media is currently playing on the device.

public static PlatForm::Boolean IsMediaPlaying()public static bool IsMediaPlaying()Public Static Function IsMediaPlaying() As bool
Returns
bool bool bool

Boolean value indicating if other media is currently playing on the device.

Attributes

Remarks

If this value is true, you may want to prompt the user to see if they would prefer to continue to listen to the other media source.

SendMessageToBackground(ValueSet) SendMessageToBackground(ValueSet) SendMessageToBackground(ValueSet)

Sends a message to the background media player.

public static void SendMessageToBackground(ValueSet value)public static void SendMessageToBackground(ValueSet value)Public Static Function SendMessageToBackground(value As ValueSet) As void
Parameters
value
ValueSet ValueSet ValueSet

Set of values representing the message.

Attributes

SendMessageToForeground(ValueSet) SendMessageToForeground(ValueSet) SendMessageToForeground(ValueSet)

Sends a message to the foreground task.

public static void SendMessageToForeground(ValueSet value)public static void SendMessageToForeground(ValueSet value)Public Static Function SendMessageToForeground(value As ValueSet) As void
Parameters
value
ValueSet ValueSet ValueSet

Set of values representing the message.

Attributes

Remarks

Apps should only call SendMessageToForeground while the foreground app is running. Attempting to call this method while the foreground app is not running will throw an exception. An app is responsible for communicating the foreground app state to the background process. This can be done using app lifecycle events, state values kept in local storage, and messages between processes.

Calls to SendMessageToForeground should always be made within a try block so that the exception thrown can be caught if the system is unable to send the message.

Shutdown() Shutdown() Shutdown()

Shuts down the current background media player.

public static void Shutdown()public static void Shutdown()Public Static Function Shutdown() As void
Attributes

Events

MessageReceivedFromBackground MessageReceivedFromBackground MessageReceivedFromBackground

Occurs when a message is received from the background task.

public static event EventHandler MessageReceivedFromBackgroundpublic static event EventHandler MessageReceivedFromBackgroundPublic Static Event MessageReceivedFromBackground
Attributes

MessageReceivedFromForeground MessageReceivedFromForeground MessageReceivedFromForeground

Occurs when a message is received from the foreground task.

public static event EventHandler MessageReceivedFromForegroundpublic static event EventHandler MessageReceivedFromForegroundPublic Static Event MessageReceivedFromForeground
Attributes

See Also