MediaControl class

Applies to Windows only

[MediaControl may be altered or unavailable for releases after Windows 8.1. Instead, use SystemMediaTransportControls.]

Describes the object that applications register with, to receive media focus and transport control notifications.

Syntax


var mediaControl = Windows.Media.MediaControl;

Attributes

[Deprecated()]
[MarshalingBehavior(Agile)]
[Threading(MTA)]
[Version(0x06020000)]

Members

The MediaControl class has these types of members:

Events

The MediaControl class has these events.

EventDescription
ChannelDownPressed Event raised when a ChannelDown command is issued to the application.
ChannelUpPressed Event raised when a ChannelUp command is issued to the application.
FastForwardPressed Event raised when a FastForward command is issued to the application.
NextTrackPressed Event raised when a NextTrack command is issued to the application.
PausePressed Event raised when a Pause command is issued to the application.
PlayPauseTogglePressed Event raised when a PlayPauseToggle command is issued to the application.
PlayPressed Event raised when a Play command is issued to the application.
PreviousTrackPressed Event raised when a PreviousTrack command is issued to the application.
RecordPressed Event raised when a Record command is issued to the application.
RewindPressed Event raised when a Rewind command is issued to the application.
SoundLevelChanged Event raised when the sound level changes.
StopPressed Event raised when a Stop command is issued to the application.

 

Methods

The MediaControl class inherits methods from the Object class (C#/VB/C++).

Properties

The MediaControl class has these properties.

PropertyAccess typeDescription

AlbumArt

Read/writeGets or sets the path to the artwork for the album cover.

ArtistName

Read/writeGets or sets the name of the artist.

IsPlaying

Read/writeGets or sets the state of the Play button.

SoundLevel

Read-onlyGets the current sound level.

TrackName

Read/writeGets or sets the track name.

 

Remarks

The MediaControl class provides access to button press events. These events can be monitored, and can modify the response and behavior of an audio-aware app. Here is a JavaScript code snippet that shows how to add event listeners to a MediaControl object. It then shows how to write code to handle those events.


// Assign the Windows.Media.MediaControl button object to 
// the user-defined mediaControls variable
mediaControls = Windows.Media.MediaControl;

// Add event listeners for the buttons
mediaControls.addEventListener(“PlayPressed”, play, false);
mediaControls.addEventListener(“PausePressed”, pause, false);
mediaControls.addEventListener(“PlayPauseTogglePressed”, playpausetoggle, false);
mediaControls.addEventListener(“NextTrackPressed”, nexttrack, false);
mediaControls.addEventListener(“PreviousTrackPressed”, previoustrack, false);
mediaControls.addEventListener(“SoundLevelChanged”, soundlevelchanged, false);

// Add code for event handlers for the events
   function play() {
	     document.getElementById(“audiotag”).play();
   }

   function pause() {
	     document.getElementById(“audiotag”).pause();
   }

   function playpausetoggle() {
      //<code goes here to handle the PlayPauseToggle event> 
   }
   
   ...
   // Additional code to handle the other events


To see the complete listing for this example, see How to configure keys for media controls.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

None supported

End of client support

Windows 8.1

End of server support

Windows Server 2012 R2

Namespace

Windows.Media
Windows::Media [C++]

Metadata

Windows.winmd

See also

How to configure keys for media controls

 

 

Show:
© 2014 Microsoft