Media​Player Media​Player Media​Player Class

Definition

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, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2public sealed class MediaPlayer : IDisposable, IMediaPlayer, IMediaPlayer2, IMediaPlayer3, IMediaPlayer4, IMediaPlayer5, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2Public NotInheritable Class MediaPlayer Implements IDisposable, IMediaPlayer, IMediaPlayer2, IMediaPlayer3, IMediaPlayer4, IMediaPlayer5, IMediaPlayerEffects, IMediaPlayerEffects2, IMediaPlayerSource, IMediaPlayerSource2
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Constructors

MediaPlayer() MediaPlayer() MediaPlayer()

Initializes a new instance of the MediaPlayer object.

public MediaPlayer()public MediaPlayer()Public Sub New()
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Properties

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
Value
double double double

The ratio of volume across speakers in the range between -1 and 1. The default value is 0.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
MediaPlayerAudioCategory MediaPlayerAudioCategory MediaPlayerAudioCategory

The type of audio that is currently being played.

Attributes

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
Value
DeviceInformation DeviceInformation DeviceInformation

The DeviceInformation object representing audio device used by the MediaPlayer to render audio.

Attributes
Additional features and requirements
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

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
Attributes

AutoPlay AutoPlay AutoPlay

Gets or sets a Boolean value indicating if playback automatically starts after the media is loaded.

public bool AutoPlay { get; set; }public bool AutoPlay { get; set; }Public ReadWrite Property AutoPlay As bool
Value
bool bool bool

True is playback start automatically, otherwise false.

Attributes

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
double double double

The amount of buffering that is completed for the media content.

Attributes

Remarks

The value ranges from 0 to 1. Multiply by 100 to obtain a percentage. The default value is 0.

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 bool CanPause { get; }public bool CanPause { get; }Public ReadOnly Property CanPause As bool
Value
bool bool bool

True if the media can be paused, otherwise false.

Attributes

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 bool CanSeek { get; }public bool CanSeek { get; }Public ReadOnly Property CanSeek As bool
Value
bool bool bool

True if the media supports seeking, otherwise false.

Attributes

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
MediaPlayerState MediaPlayerState MediaPlayerState

The current state of media playback.

Attributes

IsLoopingEnabled IsLoopingEnabled IsLoopingEnabled

Gets or sets a Boolean value indicating if the media will playback in a repeating loop.

public bool IsLoopingEnabled { get; set; }public bool IsLoopingEnabled { get; set; }Public ReadWrite Property IsLoopingEnabled As bool
Value
bool bool bool

True is looping is enabled, otherwise false.

Attributes

IsMuted IsMuted IsMuted

Gets or sets a Boolean value indicating if the audio is muted.

public bool IsMuted { get; set; }public bool IsMuted { get; set; }Public ReadWrite Property IsMuted As bool
Value
bool bool bool

True if the audio is muted, otherwise false.

Attributes

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 bool IsProtected { get; }public bool IsProtected { get; }Public ReadOnly Property IsProtected As bool
Value
bool bool bool

True if the content is protected, otherwise false.

Attributes

IsVideoFrameServerEnabled IsVideoFrameServerEnabled IsVideoFrameServerEnabled

Gets a value indicating whether video frame server mode is enabled for the MediaPlayer instance.

public bool IsVideoFrameServerEnabled { get; set; }public bool IsVideoFrameServerEnabled { get; set; }Public ReadWrite Property IsVideoFrameServerEnabled As bool
Value
bool bool bool

True if video frame server mode is enabled; otherwise, false.

Attributes
Additional features and requirements
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

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
Value
TimeSpan TimeSpan TimeSpan

The actual duration of the media without applying the PlaybackRate.

Attributes

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
Value
PlaybackMediaMarkerSequence PlaybackMediaMarkerSequence PlaybackMediaMarkerSequence

The collection of timeline markers for the media.

Attributes

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
Value
double double double

The playback rate, expressed as a percentage.

Attributes

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

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
TimeSpan TimeSpan TimeSpan

The playback position within the media.

Attributes

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

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
Value
MediaProtectionManager MediaProtectionManager MediaProtectionManager

The content protection manager for the media.

Attributes

RealTimePlayback RealTimePlayback RealTimePlayback

Gets or sets a value that configures the MediaPlayer for real-time scenarios.

public bool RealTimePlayback { get; set; }public bool RealTimePlayback { get; set; }Public ReadWrite Property RealTimePlayback As bool
Value
bool bool bool

True if the MediaPlayer is being used for real-time media; otherwise, false.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
IMediaPlaybackSource IMediaPlaybackSource IMediaPlaybackSource

The playback source of the media player.

Attributes

Remarks

The playback source can be a MediaSource, a MediaPlaybackItem, or a MediaPlaybackList, which is a list of MediaPlaybackItem objects.

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Attributes

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Value
TimeSpan TimeSpan TimeSpan

The offset applied to the position of the MediaTimelineController associated with the MediaPlayer.

Attributes
Additional features and requirements
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

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
Value
double double double

The audio volume for media playback.

Attributes

Methods

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(String activatableClassId, Boolean 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
Parameters
activatableClassId
System.String System.String System.String

The activatable class ID of the audio effect to add to the playback stream.

effectOptional
System.Boolean System.Boolean System.Boolean

A value indicating whether the effect is optional.

configuration
IPropertySet IPropertySet IPropertySet

A property set containing configuration settings for the specified audio effect.

Attributes
Additional features and requirements
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)

Applies a video effect to media playback.

public void AddVideoEffect(String activatableClassId, Boolean 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
Parameters
activatableClassId
System.String System.String System.String

The identifier of the effect.

effectOptional
System.Boolean System.Boolean System.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

A property set that transmits property values to the effect specified by effectID.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Attributes
Additional features and requirements
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)

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
Parameters
destinationLeftEye
IDirect3DSurface IDirect3DSurface IDirect3DSurface

The surface to which the left eye content is copied.

destinationRightEye
IDirect3DSurface IDirect3DSurface IDirect3DSurface

The surface to which the right eye content is copied.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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
Parameters
destination
IDirect3DSurface IDirect3DSurface IDirect3DSurface

The IDirect3DSurface to which the video frame is copied.

Attributes
Additional features and requirements
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)

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
Parameters
destination
IDirect3DSurface IDirect3DSurface IDirect3DSurface

The IDirect3DSurface to which the video frame is copied.

targetRectangle
Rect Rect Rect

The target rectangle within the IDirect3DSurface to which the video frame is copied.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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 Dispose
Attributes

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
Returns
Attributes
Additional features and requirements
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)

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
Parameters
compositor
Compositor Compositor Compositor

The Compositor with which the returned surface will be used.

Returns
Attributes
Additional features and requirements
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()

Pauses media playback.

public void Pause()public void Pause()Public Function Pause() As void
Attributes

Play() Play() Play()

Starts media playback.

public void Play()public void Play()Public Function Play() As void
Attributes

RemoveAllEffects() RemoveAllEffects() RemoveAllEffects()

Removes all effects from the playback stream of the MediaPlayer.

public void RemoveAllEffects()public void RemoveAllEffects()Public Function RemoveAllEffects() As void
Attributes
Additional features and requirements
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.

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
Parameters
file
IStorageFile IStorageFile IStorageFile

The media source file.

Attributes

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
Parameters
source
IMediaSource IMediaSource IMediaSource

The media source for playback.

Attributes

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
Parameters
Attributes

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
Parameters
size
Size Size Size

An object representing the size of the composition surface.

Attributes
Additional features and requirements
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)

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
Parameters
value
Uri Uri Uri

The path to the media.

Attributes

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Events

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 BufferingEndedpublic event TypedEventHandler BufferingEndedPublic Event BufferingEnded
Attributes

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 BufferingStartedpublic event TypedEventHandler BufferingStartedPublic Event BufferingStarted
Attributes

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 CurrentStateChangedpublic event TypedEventHandler CurrentStateChangedPublic Event CurrentStateChanged
Attributes

IsMutedChanged IsMutedChanged IsMutedChanged

Occurs when the current muted status of the MediaPlayer changes.

public event TypedEventHandler IsMutedChangedpublic event TypedEventHandler IsMutedChangedPublic Event IsMutedChanged
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

MediaEnded MediaEnded MediaEnded

Occurs when the media has finished playback.

public event TypedEventHandler MediaEndedpublic event TypedEventHandler MediaEndedPublic Event MediaEnded
Attributes

MediaFailed MediaFailed MediaFailed

Occurs when an error is encountered.

public event TypedEventHandler MediaFailedpublic event TypedEventHandler MediaFailedPublic Event MediaFailed
Attributes

MediaOpened MediaOpened MediaOpened

Occurs when the media is opened.

public event TypedEventHandler MediaOpenedpublic event TypedEventHandler MediaOpenedPublic Event MediaOpened
Attributes

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 MediaPlayerRateChangedpublic event TypedEventHandler MediaPlayerRateChangedPublic Event MediaPlayerRateChanged
Attributes

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 PlaybackMediaMarkerReachedpublic event TypedEventHandler PlaybackMediaMarkerReachedPublic Event PlaybackMediaMarkerReached
Attributes

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 SeekCompletedpublic event TypedEventHandler SeekCompletedPublic Event SeekCompleted
Attributes

SourceChanged SourceChanged SourceChanged

Occurs when the media source for the MediaPlayer changes.

public event TypedEventHandler SourceChangedpublic event TypedEventHandler SourceChangedPublic Event SourceChanged
Attributes
Additional features and requirements
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.

VideoFrameAvailable VideoFrameAvailable VideoFrameAvailable

Occurs when IsVideoFrameServerEnabled is set to true and a new video frame is available for processing.

public event TypedEventHandler VideoFrameAvailablepublic event TypedEventHandler VideoFrameAvailablePublic Event VideoFrameAvailable
Attributes
Additional features and requirements
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

Occurs when the volume of the audio has changed.

public event TypedEventHandler VolumeChangedpublic event TypedEventHandler VolumeChangedPublic Event VolumeChanged
Attributes