MediaControl Class

[MediaControl 在 Windows 8.1 之后的版本中可能会更改或不可用。请改用 SystemMediaTransportControls。]

描述应用程序注册的对象,以接收媒体焦点并传输控件通知。

语法


var mediaControl = Windows.Media.MediaControl;

特性

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

成员

MediaControl类 具有这些类型的成员:

事件

MediaControl类 具有这些事件。

事件说明
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.

 

方法

The MediaControl 类 继承这些方法于:Object 类 (C#/VB/C++).

属性

MediaControl类 具有这些属性。

属性访问类型说明

AlbumArt

读/写Gets or sets the path to the artwork for the album cover.

ArtistName

读/写Gets or sets the name of the artist.

IsPlaying

读/写Gets or sets the state of the Play button.

SoundLevel

只读Gets the current sound level.

TrackName

读/写Gets or sets the track name.

 

备注

MediaControl 类提供对按钮点按事件的访问。这些事件可被监控,并且可以修改一个音频识别应用程序的响应和行为。这是显示如何将事件侦听器添加到 MediaControl 对象的 JavaScript 代码段。然后显示如何编写代码以处理这些事件。


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


若要在本示例中查看完整列表,请参见如何配置媒体控制的键

要求

最低支持客户端

Windows 8 [仅 Windows 应用商店应用程序]

最低支持服务器

Windows Server 2012 [仅 Windows 应用商店应用程序]

客户端支持结束

Windows 8.1

服务器支持结束

Windows Server 2012 R2

命名空间

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

元数据

Windows.winmd

另请参见

如何配置媒体控制的键

 

 

显示:
© 2015 Microsoft