MediaControl MediaControl MediaControl MediaControl Class

Note

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

Declaration

public static class MediaControlpublic static class MediaControlPublic Static Class MediaControlpublic static class MediaControl

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.

Properties summary

Note

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

Gets or sets the path to the artwork for the album cover.

Note

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

Gets or sets the name of the artist.

Note

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

Gets or sets the state of the Play button.

Note

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

Gets the current sound level.

Note

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

Gets or sets the track name.

Events summary

Note

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

Event raised when a ChannelDown command is issued to the application.

Note

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

Event raised when a ChannelUp command is issued to the application.

Note

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

Event raised when a FastForward command is issued to the application.

Note

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

Event raised when a NextTrack command is issued to the application.

Note

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

Event raised when a Pause command is issued to the application.

Note

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

Event raised when a PlayPauseToggle command is issued to the application.

Note

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

Event raised when a Play command is issued to the application.

Note

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

Event raised when a PreviousTrack command is issued to the application.

Note

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

Event raised when a Record command is issued to the application.

Note

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

Event raised when a Rewind command is issued to the application.

Note

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

Event raised when the sound level changes.

Note

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

Event raised when a Stop command is issued to the application.

Properties

  • AlbumArt
    AlbumArt
    AlbumArt
    AlbumArt
    Note

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

    Gets or sets the path to the artwork for the album cover.

    public static Uri AlbumArt { get; set; }public static Uri AlbumArt { get; set; }Public Static ReadWrite Property AlbumArt As Uripublic static Uri AlbumArt { get; set; }

    Property Value

    Remarks

    If you provide an invalid path for the album art property, it will cause an exception to be thrown. The only valid URI formats are ms-appx:// and ms-appdata://.

  • ArtistName
    ArtistName
    ArtistName
    ArtistName
    Note

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

    Gets or sets the name of the artist.

    public static string ArtistName { get; set; }public static string ArtistName { get; set; }Public Static ReadWrite Property ArtistName As stringpublic static string ArtistName { get; set; }

    Property Value

    • string
      string
      string
      string

      The name of the artist.

  • IsPlaying
    IsPlaying
    IsPlaying
    IsPlaying
    Note

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

    Gets or sets the state of the Play button.

    public static bool IsPlaying { get; set; }public static bool IsPlaying { get; set; }Public Static ReadWrite Property IsPlaying As boolpublic static bool IsPlaying { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

      The state of the Play button.

    Remarks

    IsPlaying is a Boolean value that indicates the state of the Play button. You can retrieve or set this value. You can also use the current value to make programmatic decisions about the behavior of the app.

  • SoundLevel
    SoundLevel
    SoundLevel
    SoundLevel
    Note

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

    Gets the current sound level.

    public static SoundLevel SoundLevel { get; }public static SoundLevel SoundLevel { get; }Public Static ReadOnly Property SoundLevel As SoundLevelpublic static SoundLevel SoundLevel { get; }

    Property Value

    Remarks

    Note that the sound level of an application is tied to the state of its render streams only, and not to the states of its capture or loopback streams.

  • TrackName
    TrackName
    TrackName
    TrackName
    Note

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

    Gets or sets the track name.

    public static string TrackName { get; set; }public static string TrackName { get; set; }Public Static ReadWrite Property TrackName As stringpublic static string TrackName { get; set; }

    Property Value

    • string
      string
      string
      string

      The name of the track.

Events

  • ChannelDownPressed
    ChannelDownPressed
    ChannelDownPressed
    ChannelDownPressed
    Note

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

    Event raised when a ChannelDown command is issued to the application.

    public static event EventHandler ChannelDownPressedpublic static event EventHandler ChannelDownPressedPublic Static Event ChannelDownPressedpublic static event EventHandler ChannelDownPressed
  • ChannelUpPressed
    ChannelUpPressed
    ChannelUpPressed
    ChannelUpPressed
    Note

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

    Event raised when a ChannelUp command is issued to the application.

    public static event EventHandler ChannelUpPressedpublic static event EventHandler ChannelUpPressedPublic Static Event ChannelUpPressedpublic static event EventHandler ChannelUpPressed
  • FastForwardPressed
    FastForwardPressed
    FastForwardPressed
    FastForwardPressed
    Note

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

    Event raised when a FastForward command is issued to the application.

    public static event EventHandler FastForwardPressedpublic static event EventHandler FastForwardPressedPublic Static Event FastForwardPressedpublic static event EventHandler FastForwardPressed
  • NextTrackPressed
    NextTrackPressed
    NextTrackPressed
    NextTrackPressed
    Note

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

    Event raised when a NextTrack command is issued to the application.

    public static event EventHandler NextTrackPressedpublic static event EventHandler NextTrackPressedPublic Static Event NextTrackPressedpublic static event EventHandler NextTrackPressed
  • PausePressed
    PausePressed
    PausePressed
    PausePressed
    Note

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

    Event raised when a Pause command is issued to the application.

    public static event EventHandler PausePressedpublic static event EventHandler PausePressedPublic Static Event PausePressedpublic static event EventHandler PausePressed
  • PlayPauseTogglePressed
    PlayPauseTogglePressed
    PlayPauseTogglePressed
    PlayPauseTogglePressed
    Note

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

    Event raised when a PlayPauseToggle command is issued to the application.

    public static event EventHandler PlayPauseTogglePressedpublic static event EventHandler PlayPauseTogglePressedPublic Static Event PlayPauseTogglePressedpublic static event EventHandler PlayPauseTogglePressed
  • PlayPressed
    PlayPressed
    PlayPressed
    PlayPressed
    Note

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

    Event raised when a Play command is issued to the application.

    public static event EventHandler PlayPressedpublic static event EventHandler PlayPressedPublic Static Event PlayPressedpublic static event EventHandler PlayPressed
  • PreviousTrackPressed
    PreviousTrackPressed
    PreviousTrackPressed
    PreviousTrackPressed
    Note

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

    Event raised when a PreviousTrack command is issued to the application.

    public static event EventHandler PreviousTrackPressedpublic static event EventHandler PreviousTrackPressedPublic Static Event PreviousTrackPressedpublic static event EventHandler PreviousTrackPressed
  • RecordPressed
    RecordPressed
    RecordPressed
    RecordPressed
    Note

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

    Event raised when a Record command is issued to the application.

    public static event EventHandler RecordPressedpublic static event EventHandler RecordPressedPublic Static Event RecordPressedpublic static event EventHandler RecordPressed
  • RewindPressed
    RewindPressed
    RewindPressed
    RewindPressed
    Note

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

    Event raised when a Rewind command is issued to the application.

    public static event EventHandler RewindPressedpublic static event EventHandler RewindPressedPublic Static Event RewindPressedpublic static event EventHandler RewindPressed
  • SoundLevelChanged
    SoundLevelChanged
    SoundLevelChanged
    SoundLevelChanged
    Note

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

    Event raised when the sound level changes.

    public static event EventHandler SoundLevelChangedpublic static event EventHandler SoundLevelChangedPublic Static Event SoundLevelChangedpublic static event EventHandler SoundLevelChanged
  • StopPressed
    StopPressed
    StopPressed
    StopPressed
    Note

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

    Event raised when a Stop command is issued to the application.

    public static event EventHandler StopPressedpublic static event EventHandler StopPressedPublic Static Event StopPressedpublic static event EventHandler StopPressed

Device family

Windows Desktop Extension SDK (introduced v10.0.10240.0)
Xbox One Extensions for the UWP (introduced v10.0.10586.0)

API contract

Windows.Media.MediaControlContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DeprecatedAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Media.dll