Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MediaControl.PlayPauseTogglePressed | playpausetogglepressed event

Applies to Windows only

[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.

Syntax


public static event EventHandler<object> PlayPauseTogglePressed

Event information

DelegateEventHandler [JavaScript] | System.EventHandler<Object> [.NET] | Windows.Foundation.EventHandler<Object> [C++]

Remarks

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 some of those events, such as the PlayPauseTogglePressed event. The code snippet assumes that there is a corresponding HTML file that contains an <audio> tag, with its element ID set to "audiotag."


// 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

Minimum supported server

Windows Server 2012

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
MediaControl

 

 

Show:
© 2014 Microsoft