MediaPlayer
MediaPlayer
MediaPlayer
MediaPlayer
Class
Definition
Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Prerelease APIs are identified by a Prerelease label.
[Contains prerelease APIs.]
Provides access to media playback functionality such as play, pause, fast-forward, rewind, and volume.
public : sealed class MediaPlayer : IClosable, IMediaPlayer, IMediaPlayer2, IMediaPlayer3, IMediaPlayer4, IMediaPlayer5, IMediaPlayer6, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2public sealed class MediaPlayer : IDisposable, IMediaPlayer, IMediaPlayer2, IMediaPlayer3, IMediaPlayer4, IMediaPlayer5, IMediaPlayer6, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2Public NotInheritable Class MediaPlayer Implements IDisposable, IMediaPlayer, IMediaPlayer2, IMediaPlayer3, IMediaPlayer4, IMediaPlayer5, IMediaPlayer6, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
The Media playback section of the documentation contains how-to articles that provide detailed guidance for adding media playback features to your app. The following table lists some of the available articles.
| Topic | Description |
|---|---|
| Play audio and video with MediaPlayer | Shows you how to take advantage of the new features and improvements to the media playback system for UWP apps. |
| Media items, playlists, and tracks | Shows you how to use the MediaSource class, which provides a common way to reference and play back media from different sources such as local or remote files and exposes a common model for accessing media data, regardless of the underlying media format. |
| Integrate with the System Media Transport Controls | Shows you how to integrate your app with the System Media Transport Controls (SMTC). |
| System-supported timed metadata cues | Describes how to take advantage of several formats of timed metadata that may be embedded in media files or streams. |
| Create, schedule, and manage media breaks | Shows you how to create, schedule, and manage media breaks to your media playback app. |
| Play media in the background | Shows you how to configure your app so that media continues to play when your app moves from the foreground to the background. |
| Adaptive Streaming | Describes how to add playback of adaptive streaming multimedia content to a Universal Windows Platform (UWP) apps. |
| Media casting | Shows you how to cast media to remote devices from a Universal Windows app. |
| PlayReady DRM | Describes how to add PlayReady protected media content to your Universal Windows Platform (UWP) app. |
Media playback SDK samples
The following SDK samples demonstrate the media playback features available to UWP apps on Windows 10. Use these samples to see the media playback APIs used in context or as a starting point for your own app.
Constructors
MediaPlayer() MediaPlayer() MediaPlayer() MediaPlayer()
Initializes a new instance of the MediaPlayer object.
public : MediaPlayer()public MediaPlayer()Public Sub New()// You can use this method in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Properties
AudioBalance AudioBalance AudioBalance AudioBalance
Gets or sets a ratio of volume across stereo speakers.
public : double AudioBalance { get; set; }public double AudioBalance { get; set; }Public ReadWrite Property AudioBalance As double// You can use this property in JavaScript.
- Value
- double double double double
The ratio of volume across speakers in the range between -1 and 1. The default value is 0.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
AudioCategory AudioCategory AudioCategory AudioCategory
Gets or sets the type of audio that is currently being played.
public : MediaPlayerAudioCategory AudioCategory { get; set; }public MediaPlayerAudioCategory AudioCategory { get; set; }Public ReadWrite Property AudioCategory As MediaPlayerAudioCategory// You can use this property in JavaScript.
- Value
- MediaPlayerAudioCategory MediaPlayerAudioCategory MediaPlayerAudioCategory MediaPlayerAudioCategory
The type of audio that is currently being played.
AudioDevice AudioDevice AudioDevice AudioDevice
Gets or sets the DeviceInformation object representing audio device used by the MediaPlayer to render audio.
public : DeviceInformation AudioDevice { get; set; }public DeviceInformation AudioDevice { get; set; }Public ReadWrite Property AudioDevice As DeviceInformation// You can use this property in JavaScript.
The DeviceInformation object representing audio device used by the MediaPlayer to render audio.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
To enumerate the currently available audio devices, call DeviceInformation.FindAllAsync, passing in the device selector string returned from MediaDevice.GetAudioRenderSelector.
AudioDeviceType AudioDeviceType AudioDeviceType AudioDeviceType
Gets or sets a value that describes the primary usage of the device that is being used to play back audio.
public : MediaPlayerAudioDeviceType AudioDeviceType { get; set; }public MediaPlayerAudioDeviceType AudioDeviceType { get; set; }Public ReadWrite Property AudioDeviceType As MediaPlayerAudioDeviceType// You can use this property in JavaScript.
- Value
- MediaPlayerAudioDeviceType MediaPlayerAudioDeviceType MediaPlayerAudioDeviceType MediaPlayerAudioDeviceType
The audio device type.
AutoPlay AutoPlay AutoPlay AutoPlay
Gets or sets a Boolean value indicating if playback automatically starts after the media is loaded.
public : PlatForm::Boolean AutoPlay { get; set; }public bool AutoPlay { get; set; }Public ReadWrite Property AutoPlay As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True is playback start automatically, otherwise false.
BreakManager BreakManager BreakManager BreakManager
Gets the MediaBreakManager associated with the MediaPlayer, which provides information about and control over media breaks for the player.
public : MediaBreakManager BreakManager { get; }public MediaBreakManager BreakManager { get; }Public ReadOnly Property BreakManager As MediaBreakManager// You can use this property in JavaScript.
The MediaBreakManager associated with the MediaPlayer.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
BufferingProgress BufferingProgress BufferingProgress BufferingProgress
Gets the amount of buffering that is completed for the media content, expressed as a percentage.
Note
MediaPlayer.BufferingProgress may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.BufferingProgress property.
public : double BufferingProgress { get; }public double BufferingProgress { get; }Public ReadOnly Property BufferingProgress As double// You can use this property in JavaScript.
- Value
- double double double double
The amount of buffering that is completed for the media content.
Remarks
The value ranges from 0 to 1. Multiply by 100 to obtain a percentage. The default value is 0.
CanPause CanPause CanPause CanPause
Gets a Boolean value indicating if the media can be paused.
Note
MediaPlayer.CanPause may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.CanPause property.
public : PlatForm::Boolean CanPause { get; }public bool CanPause { get; }Public ReadOnly Property CanPause As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the media can be paused, otherwise false.
CanSeek CanSeek CanSeek CanSeek
Gets a Boolean value indicating if the media supports seeking to a specific position.
Note
MediaPlayer.CanSeek may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.CanSeek property.
public : PlatForm::Boolean CanSeek { get; }public bool CanSeek { get; }Public ReadOnly Property CanSeek As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the media supports seeking, otherwise false.
CommandManager CommandManager CommandManager CommandManager
Gets the MediaPlaybackCommandManager associated with the MediaPlayer, which specifies the behavior of and receives events from the System Media Transport Controls.
public : MediaPlaybackCommandManager CommandManager { get; }public MediaPlaybackCommandManager CommandManager { get; }Public ReadOnly Property CommandManager As MediaPlaybackCommandManager// You can use this property in JavaScript.
- Value
- MediaPlaybackCommandManager MediaPlaybackCommandManager MediaPlaybackCommandManager MediaPlaybackCommandManager
The MediaPlaybackCommandManager associated with the MediaPlayer.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
CurrentState CurrentState CurrentState CurrentState
Gets the current state of media playback.
Note
MediaPlayer.CurrentState may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.PlaybackState property.
public : MediaPlayerState CurrentState { get; }public MediaPlayerState CurrentState { get; }Public ReadOnly Property CurrentState As MediaPlayerState// You can use this property in JavaScript.
The current state of media playback.
IsLoopingEnabled IsLoopingEnabled IsLoopingEnabled IsLoopingEnabled
Gets or sets a Boolean value indicating if the media will playback in a repeating loop.
public : PlatForm::Boolean IsLoopingEnabled { get; set; }public bool IsLoopingEnabled { get; set; }Public ReadWrite Property IsLoopingEnabled As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True is looping is enabled, otherwise false.
IsMuted IsMuted IsMuted IsMuted
Gets or sets a Boolean value indicating if the audio is muted.
public : PlatForm::Boolean IsMuted { get; set; }public bool IsMuted { get; set; }Public ReadWrite Property IsMuted As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the audio is muted, otherwise false.
IsProtected IsProtected IsProtected IsProtected
Gets a Boolean value indicating if the content is protected by a digital rights management system.
Note
MediaPlayer.IsProtected may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the IsProtected property.
public : PlatForm::Boolean IsProtected { get; }public bool IsProtected { get; }Public ReadOnly Property IsProtected As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the content is protected, otherwise false.
IsVideoFrameServerEnabled IsVideoFrameServerEnabled IsVideoFrameServerEnabled IsVideoFrameServerEnabled
Gets a value indicating whether video frame server mode is enabled for the MediaPlayer instance.
public : PlatForm::Boolean IsVideoFrameServerEnabled { get; set; }public bool IsVideoFrameServerEnabled { get; set; }Public ReadWrite Property IsVideoFrameServerEnabled As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if video frame server mode is enabled; otherwise, false.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
When frame server mode is enabled, the media player does not render video content. Instead, your app should register for the VideoFrameAvailable event and call CopyFrameToVideoSurface when the event is raised to get the video frame data.
NaturalDuration NaturalDuration NaturalDuration NaturalDuration
Get the actual duration of the media without applying the PlaybackRate.
Note
MediaPlayer.NaturalDuration may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.NaturalDuration property.
public : TimeSpan NaturalDuration { get; }public TimeSpan NaturalDuration { get; }Public ReadOnly Property NaturalDuration As TimeSpan// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The actual duration of the media without applying the PlaybackRate.
PlaybackMediaMarkers PlaybackMediaMarkers PlaybackMediaMarkers PlaybackMediaMarkers
Gets the collection of timeline markers for the media.
Note
MediaPlayer.PlaybackMediaMarkers may be altered or unavailable after Windows 10, version 1607. Instead, use MediaPlaybackItem.TimedMetadataTracks to manage data or text cues. For more information, see Media playback with MediaSource.
public : PlaybackMediaMarkerSequence PlaybackMediaMarkers { get; }public PlaybackMediaMarkerSequence PlaybackMediaMarkers { get; }Public ReadOnly Property PlaybackMediaMarkers As PlaybackMediaMarkerSequence// You can use this property in JavaScript.
- Value
- PlaybackMediaMarkerSequence PlaybackMediaMarkerSequence PlaybackMediaMarkerSequence PlaybackMediaMarkerSequence
The collection of timeline markers for the media.
PlaybackRate PlaybackRate PlaybackRate PlaybackRate
Gets or sets the playback rate, expressed as a percentage.
Note
MediaPlayer.PlaybackRate may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.PlaybackRate property.
public : double PlaybackRate { get; set; }public double PlaybackRate { get; set; }Public ReadWrite Property PlaybackRate As double// You can use this property in JavaScript.
- Value
- double double double double
The playback rate, expressed as a percentage.
Remarks
This value is expressed as a percentage. For example, a value of 1.5 sets the playback rate to 150% of the original.
The playback rate can't be set to a value greater than 1.0 while a MediaPlaybackItem with CanSkip set to false is playing. Attempting to do so will cause an exception to be thrown.
PlaybackSession PlaybackSession PlaybackSession PlaybackSession
Gets the MediaPlaybackSession associated with the MediaPlayer, which provides information about the state of the current playback session and provides events for responding to changes in playback session state.
public : MediaPlaybackSession PlaybackSession { get; }public MediaPlaybackSession PlaybackSession { get; }Public ReadOnly Property PlaybackSession As MediaPlaybackSession// You can use this property in JavaScript.
The MediaPlaybackSession associated with the MediaPlayer.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Position Position Position Position
Gets or sets the playback position within the media.
Note
MediaPlayer.Position may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.Position property.
public : TimeSpan Position { get; set; }public TimeSpan Position { get; set; }Public ReadWrite Property Position As TimeSpan// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The playback position within the media.
Remarks
The position can't be moved forward while a MediaPlaybackItem with CanSkip set to false is playing. Attempting to do so will cause an exception to be thrown.
ProtectionManager ProtectionManager ProtectionManager ProtectionManager
Gets or sets the content protection manager for the media.
public : MediaProtectionManager ProtectionManager { get; set; }public MediaProtectionManager ProtectionManager { get; set; }Public ReadWrite Property ProtectionManager As MediaProtectionManager// You can use this property in JavaScript.
The content protection manager for the media.
RealTimePlayback RealTimePlayback RealTimePlayback RealTimePlayback
Gets or sets a value that configures the MediaPlayer for real-time scenarios.
public : PlatForm::Boolean RealTimePlayback { get; set; }public bool RealTimePlayback { get; set; }Public ReadWrite Property RealTimePlayback As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the MediaPlayer is being used for real-time media; otherwise, false.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Source Source Source Source
Sets the playback source of the media player.
public : IMediaPlaybackSource Source { get; set; }public IMediaPlaybackSource Source { get; set; }Public ReadWrite Property Source As IMediaPlaybackSource// You can use this property in JavaScript.
The playback source of the media player.
Remarks
The playback source can be a MediaSource, a MediaPlaybackItem, or a MediaPlaybackList, which is a list of MediaPlaybackItem objects.
StereoscopicVideoRenderMode StereoscopicVideoRenderMode StereoscopicVideoRenderMode StereoscopicVideoRenderMode
Gets or sets a value indicating the current stereoscopic render mode.
public : StereoscopicVideoRenderMode StereoscopicVideoRenderMode { get; set; }public StereoscopicVideoRenderMode StereoscopicVideoRenderMode { get; set; }Public ReadWrite Property StereoscopicVideoRenderMode As StereoscopicVideoRenderMode// You can use this property in JavaScript.
- Value
- StereoscopicVideoRenderMode StereoscopicVideoRenderMode StereoscopicVideoRenderMode StereoscopicVideoRenderMode
The current stereoscopic render mode.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
SystemMediaTransportControls SystemMediaTransportControls SystemMediaTransportControls SystemMediaTransportControls
Gets an instance of the SystemMediaTransportControls class to enable user control of playback of the MediaPlayer and to allow the app to show information about the currently playing content in the system UI.
public : SystemMediaTransportControls SystemMediaTransportControls { get; }public SystemMediaTransportControls SystemMediaTransportControls { get; }Public ReadOnly Property SystemMediaTransportControls As SystemMediaTransportControls// You can use this property in JavaScript.
- Value
- SystemMediaTransportControls SystemMediaTransportControls SystemMediaTransportControls SystemMediaTransportControls
An instance of the SystemMediaTransportControls class.
TimelineController TimelineController TimelineController TimelineController
Gets or sets the MediaTimelineController associated with the MediaPlayer. Use this property to manipulate multiple MediaPlayer instances with a single timeline control.
public : MediaTimelineController TimelineController { get; set; }public MediaTimelineController TimelineController { get; set; }Public ReadWrite Property TimelineController As MediaTimelineController// You can use this property in JavaScript.
- Value
- MediaTimelineController MediaTimelineController MediaTimelineController MediaTimelineController
The MediaTimelineController associated with the MediaPlayer.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
TimelineControllerPositionOffset TimelineControllerPositionOffset TimelineControllerPositionOffset TimelineControllerPositionOffset
Gets or sets the offset applied to the position of the MediaTimelineController associated with the MediaPlayer.
public : TimeSpan TimelineControllerPositionOffset { get; set; }public TimeSpan TimelineControllerPositionOffset { get; set; }Public ReadWrite Property TimelineControllerPositionOffset As TimeSpan// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The offset applied to the position of the MediaTimelineController associated with the MediaPlayer.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
A MediaTimelineController can be associated with multiple instances of MediaPlayer which could be playing different media sources. This property allows you to offset the actual playback position of the player from the current position of the timeline controller.
Volume Volume Volume Volume
Get or sets the audio volume for media playback.
public : double Volume { get; set; }public double Volume { get; set; }Public ReadWrite Property Volume As double// You can use this property in JavaScript.
- Value
- double double double double
The audio volume for media playback.
Methods
AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet)
Adds an audio effect to the playback stream of the MediaPlayer.
public : void AddAudioEffect(PlatForm::String activatableClassId, bool effectOptional, IPropertySet configuration)public void AddAudioEffect(String activatableClassId, Boolean effectOptional, IPropertySet configuration)Public Function AddAudioEffect(activatableClassId As String, effectOptional As Boolean, configuration As IPropertySet) As void// You can use this method in JavaScript.
- activatableClassId
- PlatForm::String String String String
The activatable class ID of the audio effect to add to the playback stream.
- effectOptional
- bool Boolean Boolean Boolean
A value indicating whether the effect is optional.
- configuration
- IPropertySet IPropertySet IPropertySet IPropertySet
A property set containing configuration settings for the specified audio effect.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
Remarks
To remove audio effects from the playback stream, call RemoveAllEffects.
AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet)
Applies a video effect to media playback.
public : void AddVideoEffect(PlatForm::String activatableClassId, bool effectOptional, IPropertySet effectConfiguration)public void AddVideoEffect(String activatableClassId, Boolean effectOptional, IPropertySet effectConfiguration)Public Function AddVideoEffect(activatableClassId As String, effectOptional As Boolean, effectConfiguration As IPropertySet) As void// You can use this method in JavaScript.
- activatableClassId
- PlatForm::String String String String
The identifier of the effect.
- effectOptional
- bool Boolean Boolean Boolean
Tue if the effect shouldn't block playback when the effect can't be used at run time. False if the effect should block playback when the effect can't be used at run time.
- effectConfiguration
- IPropertySet IPropertySet IPropertySet IPropertySet
A property set that transmits property values to the effect specified by effectID.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Close() Close() Close() Close()
Closes the MediaPlayer and disposes of associated resources.
public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
The Close method is used by Universal Windows app using JavaScript. For apps written using the .NET Framework 4.5 in C# and VB.NET, the Close method is exposed as the Dispose() method on the MediaPlayer object. For apps written in C++, the Close method will be called when using the delete keyword on the object.
CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface, IDirect3DSurface) CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface, IDirect3DSurface) CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface, IDirect3DSurface) CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface, IDirect3DSurface)
Copies the video frame currently displayed by the MediaPlayer to the two provided IDirect3DSurface objects which represent the left eye and right eye content of a stereoscopic video frame.
public : void CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface destinationLeftEye, IDirect3DSurface destinationRightEye)public void CopyFrameToStereoscopicVideoSurfaces(IDirect3DSurface destinationLeftEye, IDirect3DSurface destinationRightEye)Public Function CopyFrameToStereoscopicVideoSurfaces(destinationLeftEye As IDirect3DSurface, destinationRightEye As IDirect3DSurface) As void// You can use this method in JavaScript.
- destinationLeftEye
- IDirect3DSurface IDirect3DSurface IDirect3DSurface IDirect3DSurface
The surface to which the left eye content is copied.
- destinationRightEye
- IDirect3DSurface IDirect3DSurface IDirect3DSurface IDirect3DSurface
The surface to which the right eye content is copied.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
CopyFrameToVideoSurface(IDirect3DSurface) CopyFrameToVideoSurface(IDirect3DSurface) CopyFrameToVideoSurface(IDirect3DSurface) CopyFrameToVideoSurface(IDirect3DSurface)
Copies the current video frame from the MediaPlayer to the provided IDirect3DSurface.
public : void CopyFrameToVideoSurface(IDirect3DSurface destination)public void CopyFrameToVideoSurface(IDirect3DSurface destination)Public Function CopyFrameToVideoSurface(destination As IDirect3DSurface) As void// You can use this method in JavaScript.
The IDirect3DSurface to which the video frame is copied.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
CopyFrameToVideoSurface(IDirect3DSurface, Rect) CopyFrameToVideoSurface(IDirect3DSurface, Rect) CopyFrameToVideoSurface(IDirect3DSurface, Rect) CopyFrameToVideoSurface(IDirect3DSurface, Rect)
Copies the current video frame from the MediaPlayer to the specified target rectangle within the provided IDirect3DSurface.
public : void CopyFrameToVideoSurface(IDirect3DSurface destination, Rect targetRectangle)public void CopyFrameToVideoSurface(IDirect3DSurface destination, Rect targetRectangle)Public Function CopyFrameToVideoSurface(destination As IDirect3DSurface, targetRectangle As Rect) As void// You can use this method in JavaScript.
The IDirect3DSurface to which the video frame is copied.
The target rectangle within the IDirect3DSurface to which the video frame is copied.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Dispose() Dispose() Dispose() Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()
GetAsCastingSource() GetAsCastingSource() GetAsCastingSource() GetAsCastingSource()
Gets a CastingSource representing the MediaPlayer, which allows it's media to be cast to other devices.
public : CastingSource GetAsCastingSource()public CastingSource GetAsCastingSource()Public Function GetAsCastingSource() As CastingSource// You can use this method in JavaScript.
The casting source.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
For more information on casting media to remote devices, see Media casting.
GetSurface(Compositor) GetSurface(Compositor) GetSurface(Compositor) GetSurface(Compositor)
Gets a MediaPlayerSurface object for the MediaPlayer, which allows you to render the player's contents using a Compositor without relying on the XAML framework.
public : MediaPlayerSurface GetSurface(Compositor compositor)public MediaPlayerSurface GetSurface(Compositor compositor)Public Function GetSurface(compositor As Compositor) As MediaPlayerSurface// You can use this method in JavaScript.
- compositor
- Compositor Compositor Compositor Compositor
The Compositor with which the returned surface will be used.
The media player surface.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
By default, the CompositionSurface generated by this method will have the dimensions 640x 480, in pixels. To get a different size, call SetSurfaceSize before calling GetSurface.
You can obtain multiple surfaces from a single MediaPlayer instance by calling MediaPlayer multiple times.
For more information on using the Windows.UI.Composition APIs to render visuals, see Visual layer.
For how-to guidance for rendering video to a composition surface, see Play audio and video with MediaPlayer.
- See Also
Pause() Pause() Pause() Pause()
Pauses media playback.
public : void Pause()public void Pause()Public Function Pause() As void// You can use this method in JavaScript.
Remarks
Note that after you call Pause, the time represented by the Position property may not be precisely accurate. Apps that need a frame-accurate position value, such as media editors, should call MediaPlayer.StepForwardOneFrame immediately after calling Pause before reading the Position value.
Play() Play() Play() Play()
Starts media playback.
public : void Play()public void Play()Public Function Play() As void// You can use this method in JavaScript.
RemoveAllEffects() RemoveAllEffects() RemoveAllEffects() RemoveAllEffects()
Removes all effects from the playback stream of the MediaPlayer.
public : void RemoveAllEffects()public void RemoveAllEffects()Public Function RemoveAllEffects() As void// You can use this method in JavaScript.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
Remarks
Add effects to the playback stream by calling AddAudioEffect or AddVideoEffect.
RenderSubtitlesToSurface(IDirect3DSurface) RenderSubtitlesToSurface(IDirect3DSurface) RenderSubtitlesToSurface(IDirect3DSurface) RenderSubtitlesToSurface(IDirect3DSurface)
Prerelease. Requests for the system to render the current subtitle text to the provided IDirect3DSurface.
public : PlatForm::Boolean RenderSubtitlesToSurface(IDirect3DSurface destination)public bool RenderSubtitlesToSurface(IDirect3DSurface destination)Public Function RenderSubtitlesToSurface(destination As IDirect3DSurface) As bool// You can use this method in JavaScript.
The object that implements IDirect3DSurface to which the subtitle text is rendered.
True if the system rendered subtitles to the surface; otherwise false.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
Handle the SubtitleFrameChanged event to receive a notification that the subtitle content has changed. Check the return value to see if subtitles were rendered. If the method returns false, then no subtitles were rendered. In this case you may decide to hide the subtitle render surface in your UI.
In order to use this feature, you must place the MediaPlayer into frame server mode by setting IsVideoFrameServerEnabled to true, and the playing media content must have at least one timed metadata track that has had its presentation mode set to PlatformPresented with a call to MediaPlaybackTimedMetadataTrackList.SetPresentationMode. For more information on using MediaPlayer in frame server mode, see Play audio and video with MediaPlayer. For more information on working with metadata tracks, see Media items, playlists, and tracks.
RenderSubtitlesToSurface(IDirect3DSurface, Rect) RenderSubtitlesToSurface(IDirect3DSurface, Rect) RenderSubtitlesToSurface(IDirect3DSurface, Rect) RenderSubtitlesToSurface(IDirect3DSurface, Rect)
Prerelease. Requests for the system to render the current subtitle text to the specified target rectangle within the provided IDirect3DSurface.
public : PlatForm::Boolean RenderSubtitlesToSurface(IDirect3DSurface destination, Rect targetRectangle)public bool RenderSubtitlesToSurface(IDirect3DSurface destination, Rect targetRectangle)Public Function RenderSubtitlesToSurface(destination As IDirect3DSurface, targetRectangle As Rect) As bool// You can use this method in JavaScript.
The object that implements IDirect3DSurface to which the subtitle text is rendered.
The rectangle within the provided surface within which the subtitles are rendered.
True if the system rendered subtitles to the surface; otherwise false.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
Note that this method is less efficient than the other overload of RenderSubtitleToSurface, but it allows you to use the same surface for rendering video and subtitles rather than requiring a separate surface for subtitles.
Handle the SubtitleFrameChanged event to receive a notification that the subtitle content has changed. Check the return value to see if subtitles were rendered.
In order to use this feature, you must place the MediaPlayer into frame server mode by setting IsVideoFrameServerEnabled to true, and the playing media content must have at least one timed metadata track that has had its presentation mode set to PlatformPresented with a call to MediaPlaybackTimedMetadataTrackList.SetPresentationMode. For more information on using MediaPlayer in frame server mode, see Play audio and video with MediaPlayer. For more information on working with metadata tracks, see Media items, playlists, and tracks.
SetFileSource(IStorageFile) SetFileSource(IStorageFile) SetFileSource(IStorageFile) SetFileSource(IStorageFile)
Set the media source to a file.
Note
MediaPlayer.SetFileSource may be altered or unavailable after Windows 10. Use MediaPlayer.Source instead.
public : void SetFileSource(IStorageFile file)public void SetFileSource(IStorageFile file)Public Function SetFileSource(file As IStorageFile) As void// You can use this method in JavaScript.
The media source file.
SetMediaSource(IMediaSource) SetMediaSource(IMediaSource) SetMediaSource(IMediaSource) SetMediaSource(IMediaSource)
Sets the media source for playback.
Note
MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use MediaPlayer.Source instead.
public : void SetMediaSource(IMediaSource source)public void SetMediaSource(IMediaSource source)Public Function SetMediaSource(source As IMediaSource) As void// You can use this method in JavaScript.
The media source for playback.
SetStreamSource(IRandomAccessStream) SetStreamSource(IRandomAccessStream) SetStreamSource(IRandomAccessStream) SetStreamSource(IRandomAccessStream)
Sets the media source to a stream.
Note
MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use MediaPlayer.Source instead.
public : void SetStreamSource(IRandomAccessStream stream)public void SetStreamSource(IRandomAccessStream stream)Public Function SetStreamSource(stream As IRandomAccessStream) As void// You can use this method in JavaScript.
The media source stream.
SetSurfaceSize(Size) SetSurfaceSize(Size) SetSurfaceSize(Size) SetSurfaceSize(Size)
Sets the size of the composition surface returned by GetSurface.
public : void SetSurfaceSize(Size size)public void SetSurfaceSize(Size size)Public Function SetSurfaceSize(size As Size) As void// You can use this method in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
The default size for the composition surface returned by GetSurface is 640x480, in pixels.
SetUriSource(Uri) SetUriSource(Uri) SetUriSource(Uri) SetUriSource(Uri)
Sets the path to the media.
Note
MediaPlayer.SetUriSource may be altered or unavailable after Windows 10. Use MediaPlayer.Source instead.
public : void SetUriSource(Uri value)public void SetUriSource(Uri value)Public Function SetUriSource(value As Uri) As void// You can use this method in JavaScript.
- value
- Uri Uri Uri Uri
The path to the media.
StepBackwardOneFrame() StepBackwardOneFrame() StepBackwardOneFrame() StepBackwardOneFrame()
Causes the MediaPlayer to move backward in the current media by one frame.
public : void StepBackwardOneFrame()public void StepBackwardOneFrame()Public Function StepBackwardOneFrame() As void// You can use this method in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
StepForwardOneFrame() StepForwardOneFrame() StepForwardOneFrame() StepForwardOneFrame()
Causes the MediaPlayer to move forward in the current media by one frame.
public : void StepForwardOneFrame()public void StepForwardOneFrame()Public Function StepForwardOneFrame() As void// You can use this method in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Events
BufferingEnded BufferingEnded BufferingEnded BufferingEnded
Occurs when buffering has finished.
Note
MediaPlayer.BufferingEnded may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.BufferingEnded event.
public : event TypedEventHandler BufferingEnded<MediaPlayer, object>public event TypedEventHandler BufferingEnded<MediaPlayer, object>Public Event BufferingEnded<MediaPlayer, object>// You can use this event in JavaScript.
BufferingStarted BufferingStarted BufferingStarted BufferingStarted
Occurs when buffering has started.
Note
MediaPlayer.BufferingStarted may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.BufferingStarted event.
public : event TypedEventHandler BufferingStarted<MediaPlayer, object>public event TypedEventHandler BufferingStarted<MediaPlayer, object>Public Event BufferingStarted<MediaPlayer, object>// You can use this event in JavaScript.
CurrentStateChanged CurrentStateChanged CurrentStateChanged CurrentStateChanged
Occurs when the state of the media player has changed.
Note
MediaPlayer.CurrentStateChanged may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.PlaybackStateChanged event.
public : event TypedEventHandler CurrentStateChanged<MediaPlayer, object>public event TypedEventHandler CurrentStateChanged<MediaPlayer, object>Public Event CurrentStateChanged<MediaPlayer, object>// You can use this event in JavaScript.
IsMutedChanged IsMutedChanged IsMutedChanged IsMutedChanged
Occurs when the current muted status of the MediaPlayer changes.
public : event TypedEventHandler IsMutedChanged<MediaPlayer, object>public event TypedEventHandler IsMutedChanged<MediaPlayer, object>Public Event IsMutedChanged<MediaPlayer, object>// You can use this event in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
MediaEnded MediaEnded MediaEnded MediaEnded
Occurs when the media has finished playback.
public : event TypedEventHandler MediaEnded<MediaPlayer, object>public event TypedEventHandler MediaEnded<MediaPlayer, object>Public Event MediaEnded<MediaPlayer, object>// You can use this event in JavaScript.
MediaFailed MediaFailed MediaFailed MediaFailed
Occurs when an error is encountered.
public : event TypedEventHandler MediaFailed<MediaPlayer, MediaPlayerFailedEventArgs>public event TypedEventHandler MediaFailed<MediaPlayer, MediaPlayerFailedEventArgs>Public Event MediaFailed<MediaPlayer, MediaPlayerFailedEventArgs>// You can use this event in JavaScript.
MediaOpened MediaOpened MediaOpened MediaOpened
Occurs when the media is opened.
public : event TypedEventHandler MediaOpened<MediaPlayer, object>public event TypedEventHandler MediaOpened<MediaPlayer, object>Public Event MediaOpened<MediaPlayer, object>// You can use this event in JavaScript.
MediaPlayerRateChanged MediaPlayerRateChanged MediaPlayerRateChanged MediaPlayerRateChanged
Occurs when the media playback rate has changed.
Note
MediaPlayer.MediaPlayerRateChanged may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.PlaybackRateChanged event.
public : event TypedEventHandler MediaPlayerRateChanged<MediaPlayer, MediaPlayerRateChangedEventArgs>public event TypedEventHandler MediaPlayerRateChanged<MediaPlayer, MediaPlayerRateChangedEventArgs>Public Event MediaPlayerRateChanged<MediaPlayer, MediaPlayerRateChangedEventArgs>// You can use this event in JavaScript.
PlaybackMediaMarkerReached PlaybackMediaMarkerReached PlaybackMediaMarkerReached PlaybackMediaMarkerReached
Occurs when a media marker has been reached during playback.
Note
MediaPlayer.PlaybackMediaMarkerReached may be altered or unavailable after Windows 10, version 1607. Instead, use MediaPlaybackItem.TimedMetadataTracks to manage data or text cues. For more information, see Media playback with MediaSource.
public : event TypedEventHandler PlaybackMediaMarkerReached<MediaPlayer, PlaybackMediaMarkerReachedEventArgs>public event TypedEventHandler PlaybackMediaMarkerReached<MediaPlayer, PlaybackMediaMarkerReachedEventArgs>Public Event PlaybackMediaMarkerReached<MediaPlayer, PlaybackMediaMarkerReachedEventArgs>// You can use this event in JavaScript.
SeekCompleted SeekCompleted SeekCompleted SeekCompleted
Occurs when a seek operation has finished.
Note
MediaPlayer.SeekCompleted may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.SeekCompleted event.
public : event TypedEventHandler SeekCompleted<MediaPlayer, object>public event TypedEventHandler SeekCompleted<MediaPlayer, object>Public Event SeekCompleted<MediaPlayer, object>// You can use this event in JavaScript.
SourceChanged SourceChanged SourceChanged SourceChanged
Occurs when the media source for the MediaPlayer changes.
public : event TypedEventHandler SourceChanged<MediaPlayer, object>public event TypedEventHandler SourceChanged<MediaPlayer, object>Public Event SourceChanged<MediaPlayer, object>// You can use this event in JavaScript.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
A typical use of this event is if you are implementing your own transport controls. You can respond to this event by checking to see whether the source is a MediaSource, MediaPlaybackItem, or MediaPlaybackList and then update your UI accordingly. For example, if the source is a MediaPlaybackItem, you could subscribe to the list of audio and caption tracks and update the list in your UI so that the user can select the active track.
SubtitleFrameChanged SubtitleFrameChanged SubtitleFrameChanged SubtitleFrameChanged
Prerelease. Occurs when the current subtitle content has changed while the MediaPlayer is in frame server mode.
public : event TypedEventHandler SubtitleFrameChanged<MediaPlayer, object>public event TypedEventHandler SubtitleFrameChanged<MediaPlayer, object>Public Event SubtitleFrameChanged<MediaPlayer, object>// You can use this event in JavaScript.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
In the handler for this event, you can call one of the overloads of RenderSubtitlesToSurface to request that the system render the current subtitles to the provided IDirect3DSurface. If this method returns false, then no subtitles were rendered. In this case, you may choose to hide the subtitle render surface until the next time the event is raised.
In order for this event to be raised, you must place the MediaPlayer into frame server mode by setting IsVideoFrameServerEnabled to true, and the playing media content must have at least one timed metadata track that has had its presentation mode set to PlatformPresented with a call to MediaPlaybackTimedMetadataTrackList.SetPresentationMode. For more information on using MediaPlayer in frame server mode, see Play audio and video with MediaPlayer. For more information on working with metadata tracks, see Media items, playlists, and tracks.
VideoFrameAvailable VideoFrameAvailable VideoFrameAvailable VideoFrameAvailable
Occurs when IsVideoFrameServerEnabled is set to true and a new video frame is available for processing.
public : event TypedEventHandler VideoFrameAvailable<MediaPlayer, object>public event TypedEventHandler VideoFrameAvailable<MediaPlayer, object>Public Event VideoFrameAvailable<MediaPlayer, object>// You can use this event in JavaScript.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
In the handler for this event, call CopyFrameToVideoSurface to get the video frame data.
VolumeChanged VolumeChanged VolumeChanged VolumeChanged
Occurs when the volume of the audio has changed.
public : event TypedEventHandler VolumeChanged<MediaPlayer, object>public event TypedEventHandler VolumeChanged<MediaPlayer, object>Public Event VolumeChanged<MediaPlayer, object>// You can use this event in JavaScript.