MediaPlayer MediaPlayer MediaPlayer MediaPlayer Class

Provides access to media playback functionality such as play, pause, fast-forward, rewind, and volume.

Syntax

Declaration

public sealed class MediaPlayerpublic sealed class MediaPlayerPublic NotInheritable Class MediaPlayer

Constructors summary

Initializes a new instance of the MediaPlayer object.

Properties summary

Gets or sets a ratio of volume across stereo speakers.

Gets or sets the type of audio that is currently being played.

Gets or sets the DeviceInformation object representing audio device used by the MediaPlayer to render audio.

Gets or sets a value that describes the primary usage of the device that is being used to play back audio.

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

Gets the MediaBreakManager associated with the MediaPlayer, which provides information about and control over media breaks for the player.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingProgress property.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the CanPause property.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the CanSeek property.

Gets the MediaPlaybackCommandManager associated with the MediaPlayer, which specifies the behavior of and receives events from the System Media Transport Controls.

Gets the current state of media playback.

Note

MediaPlayer.CurrentState may be altered or unavailable after Windows 10, version 1607. Instead, use the PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackState property.

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

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

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 PlaybackSession property to get a MediaPlaybackSession object and then use the IsProtected property.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the NaturalDuration property.

Gets the collection of timeline markers for the media.

Note

MediaPlayer.PlaybackMediaMarkers may be altered or unavailable after Windows 10, version 1607. Instead, use TimedMetadataTracks to manage data or text cues. For more information, see Media playback with MediaSource.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackRate property.

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.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the Position property.

Gets or sets the content protection manager for the media.

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

Sets the playback source of the media player.

Gets or sets a value indicating the current stereoscopic render mode.

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.

Gets or sets the MediaTimelineController associated with the MediaPlayer. Use this property to manipulate multiple MediaPlayer instances with a single timeline control.

Gets or sets the offset applied to the position of the MediaTimelineController associated with the MediaPlayer.

Get or sets the audio volume for media playback.

Methods summary

Adds an audio effect to the playback stream of the MediaPlayer.

Applies a video effect to media playback.

Closes the MediaPlayer and disposes of associated resources.

Gets a CastingSource representing the MediaPlayer, which allows it's media to be cast to other devices.

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.

Pauses media playback.

Starts media playback.

Removes all effects from the playback stream of the MediaPlayer.

Set the media source to a file.

Note

MediaPlayer.SetFileSource may be altered or unavailable after Windows 10. Use Source instead.

Sets the media source for playback.

Note

MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use Source instead.

Sets the media source to a stream.

Note

MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use Source instead.

Sets the size of the composition surface returned by GetSurface(Windows.UI.Composition.Compositor).

Sets the path to the media.

Note

MediaPlayer.SetUriSource may be altered or unavailable after Windows 10. Use Source instead.

Causes the MediaPlayer to move backward in the current media by one frame.

Causes the MediaPlayer to move forward in the current media by one frame.

Events summary

Occurs when buffering has finished.

Note

MediaPlayer.BufferingEnded may be altered or unavailable after Windows 10, version 1607. Instead, use the PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingEnded event.

Occurs when buffering has started.

Note

MediaPlayer.BufferingStarted may be altered or unavailable after Windows 10, version 1607. Instead, use the PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingStarted event.

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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackStateChanged event.

Occurs when the current muted status of the MediaPlayer changes.

Occurs when the media has finished playback.

Occurs when an error is encountered.

Occurs when the media is opened.

Occurs when the media playback rate has changed.

Note

MediaPlayer.MediaPlayerRateChanged may be altered or unavailable after Windows 10, version 1607. Instead, use the PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackRateChanged event.

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 TimedMetadataTracks to manage data or text cues. For more information, see Media playback with MediaSource.

Occurs when a seek operation has finished.

Note

MediaPlayer.SeekCompleted may be altered or unavailable after Windows 10, version 1607. Instead, use the PlaybackSession property to get a MediaPlaybackSession object and then use the SeekCompleted event.

Occurs when the media source for the MediaPlayer changes.

Occurs when the volume of the audio has changed.

Constructors

  • MediaPlayer()
    MediaPlayer()
    MediaPlayer()
    MediaPlayer()

    Initializes a new instance of the MediaPlayer object.

    public MediaPlayer()public MediaPlayer()Public Function MediaPlayer() As

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

    Property Value

    • double
      double
      double
      double

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

  • 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

    Property Value

  • 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

    Property Value

    Remarks

    To enumerate the currently available audio devices, call FindAllAsync(System.String), passing in the device selector string returned from 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

    Property Value

  • AutoPlay
    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

    Property Value

    • bool
      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

    Property Value

  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingProgress property.

    public double BufferingProgress { get; }public double BufferingProgress { get; }Public ReadOnly Property BufferingProgress As double

    Property 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 PlaybackSession property to get a MediaPlaybackSession object and then use the CanPause property.

    public bool CanPause { get; }public bool CanPause { get; }Public ReadOnly Property CanPause As bool

    Property Value

    • bool
      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 PlaybackSession property to get a MediaPlaybackSession object and then use the CanSeek property.

    public bool CanSeek { get; }public bool CanSeek { get; }Public ReadOnly Property CanSeek As bool

    Property Value

    • bool
      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

    Property Value

  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackState property.

    public MediaPlayerState CurrentState { get; }public MediaPlayerState CurrentState { get; }Public ReadOnly Property CurrentState As MediaPlayerState

    Property Value

  • IsLoopingEnabled
    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

    Property Value

    • bool
      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 bool IsMuted { get; set; }public bool IsMuted { get; set; }Public ReadWrite Property IsMuted As bool

    Property Value

    • bool
      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 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

    Property Value

    • bool
      bool
      bool
      bool

      True if the content is protected, otherwise false.

  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the NaturalDuration property.

    public TimeSpan NaturalDuration { get; }public TimeSpan NaturalDuration { get; }Public ReadOnly Property NaturalDuration As TimeSpan

    Property Value

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

    Property Value

  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackRate property.

    public double PlaybackRate { get; set; }public double PlaybackRate { get; set; }Public ReadWrite Property PlaybackRate As double

    Property 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

    Property Value

  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the Position property.

    public TimeSpan Position { get; set; }public TimeSpan Position { get; set; }Public ReadWrite Property Position As TimeSpan

    Property Value

    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

    Property Value

  • RealTimePlayback
    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

    Property Value

    • bool
      bool
      bool
      bool

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

  • 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

    Property Value

    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

    Property Value

  • 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

    Property Value

  • 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

    Property Value

  • 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

    Property Value

    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

    Property Value

    • double
      double
      double
      double

      The audio volume for media playback.

Methods

  • AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)

    Adds an audio effect to the playback stream of the MediaPlayer.

    public void AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)public void AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)Public Function AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet) As void

    Parameters

    • activatableClassId
      System.String
      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
      System.Boolean

      A value indicating whether the effect is optional.

    • configuration

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

    Remarks

    To remove audio effects from the playback stream, call RemoveAllEffects().

  • AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)
    AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)

    Applies a video effect to media playback.

    public void AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)public void AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet)Public Function AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet) As void

    Parameters

    • activatableClassId
      System.String
      System.String
      System.String
      System.String

      The identifier of the effect.

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

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

  • Close()
    Close()
    Close()
    Close()

    Closes the MediaPlayer and disposes of associated resources.

    public void Close()public void Close()Public Function Close() As void

    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.

  • 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

    Returns

    Remarks

    For more information on casting media to remote devices, see Media casting.

  • GetSurface(Windows.UI.Composition.Compositor)
    GetSurface(Windows.UI.Composition.Compositor)
    GetSurface(Windows.UI.Composition.Compositor)
    GetSurface(Windows.UI.Composition.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(Windows.UI.Composition.Compositor)public MediaPlayerSurface GetSurface(Windows.UI.Composition.Compositor)Public Function GetSurface(Windows.UI.Composition.Compositor) As MediaPlayerSurface

    Parameters

    Returns

    Remarks

    By default, the ICompositionSurface generated by this method will have the dimensions 640x 480, in pixels. To get a different size, call SetSurfaceSize(Windows.Foundation.Size) 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.

  • Pause()
    Pause()
    Pause()
    Pause()

    Pauses media playback.

    public void Pause()public void Pause()Public Function Pause() As void
  • Play()
    Play()
    Play()
    Play()

    Starts media playback.

    public void Play()public void Play()Public Function Play() As void
  • 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

    Remarks

    Add effects to the playback stream by calling AddAudioEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet) or AddVideoEffect(System.String,System.Boolean,Windows.Foundation.Collections.IPropertySet).

  • SetFileSource(Windows.Storage.IStorageFile)
    SetFileSource(Windows.Storage.IStorageFile)
    SetFileSource(Windows.Storage.IStorageFile)
    SetFileSource(Windows.Storage.IStorageFile)

    Set the media source to a file.

    Note

    MediaPlayer.SetFileSource may be altered or unavailable after Windows 10. Use Source instead.

    public void SetFileSource(Windows.Storage.IStorageFile)public void SetFileSource(Windows.Storage.IStorageFile)Public Function SetFileSource(Windows.Storage.IStorageFile) As void

    Parameters

  • SetMediaSource(Windows.Media.Core.IMediaSource)
    SetMediaSource(Windows.Media.Core.IMediaSource)
    SetMediaSource(Windows.Media.Core.IMediaSource)
    SetMediaSource(Windows.Media.Core.IMediaSource)

    Sets the media source for playback.

    Note

    MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use Source instead.

    public void SetMediaSource(Windows.Media.Core.IMediaSource)public void SetMediaSource(Windows.Media.Core.IMediaSource)Public Function SetMediaSource(Windows.Media.Core.IMediaSource) As void

    Parameters

  • SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)
    SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)
    SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)
    SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)

    Sets the media source to a stream.

    Note

    MediaPlayer.SetMediaSource may be altered or unavailable after Windows 10. Use Source instead.

    public void SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)public void SetStreamSource(Windows.Storage.Streams.IRandomAccessStream)Public Function SetStreamSource(Windows.Storage.Streams.IRandomAccessStream) As void

    Parameters

  • SetSurfaceSize(Windows.Foundation.Size)
    SetSurfaceSize(Windows.Foundation.Size)
    SetSurfaceSize(Windows.Foundation.Size)
    SetSurfaceSize(Windows.Foundation.Size)

    Sets the size of the composition surface returned by GetSurface(Windows.UI.Composition.Compositor).

    public void SetSurfaceSize(Windows.Foundation.Size)public void SetSurfaceSize(Windows.Foundation.Size)Public Function SetSurfaceSize(Windows.Foundation.Size) As void

    Parameters

    • size

      An object representing the size of the composition surface.

    Remarks

    The default size for the composition surface returned by GetSurface(Windows.UI.Composition.Compositor) is 640x480, in pixels.

  • SetUriSource(Windows.Foundation.Uri)
    SetUriSource(Windows.Foundation.Uri)
    SetUriSource(Windows.Foundation.Uri)
    SetUriSource(Windows.Foundation.Uri)

    Sets the path to the media.

    Note

    MediaPlayer.SetUriSource may be altered or unavailable after Windows 10. Use Source instead.

    public void SetUriSource(Windows.Foundation.Uri)public void SetUriSource(Windows.Foundation.Uri)Public Function SetUriSource(Windows.Foundation.Uri) As void

    Parameters

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

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 PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingEnded event.

    public event TypedEventHandler BufferingEndedpublic event TypedEventHandler BufferingEndedPublic Event BufferingEnded
  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the BufferingStarted event.

    public event TypedEventHandler BufferingStartedpublic event TypedEventHandler BufferingStartedPublic Event BufferingStarted
  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackStateChanged event.

    public event TypedEventHandler CurrentStateChangedpublic event TypedEventHandler CurrentStateChangedPublic Event CurrentStateChanged
  • IsMutedChanged
    IsMutedChanged
    IsMutedChanged
    IsMutedChanged

    Occurs when the current muted status of the MediaPlayer changes.

    public event TypedEventHandler IsMutedChangedpublic event TypedEventHandler IsMutedChangedPublic Event IsMutedChanged
  • MediaEnded
    MediaEnded
    MediaEnded
    MediaEnded

    Occurs when the media has finished playback.

    public event TypedEventHandler MediaEndedpublic event TypedEventHandler MediaEndedPublic Event MediaEnded
  • MediaFailed
    MediaFailed
    MediaFailed
    MediaFailed

    Occurs when an error is encountered.

    public event TypedEventHandler MediaFailedpublic event TypedEventHandler MediaFailedPublic Event MediaFailed
  • MediaOpened
    MediaOpened
    MediaOpened
    MediaOpened

    Occurs when the media is opened.

    public event TypedEventHandler MediaOpenedpublic event TypedEventHandler MediaOpenedPublic Event MediaOpened
  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the PlaybackRateChanged event.

    public event TypedEventHandler MediaPlayerRateChangedpublic event TypedEventHandler MediaPlayerRateChangedPublic Event MediaPlayerRateChanged
  • 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 TimedMetadataTracks to manage data or text cues. For more information, see Media playback with MediaSource.

    public event TypedEventHandler PlaybackMediaMarkerReachedpublic event TypedEventHandler PlaybackMediaMarkerReachedPublic Event PlaybackMediaMarkerReached
  • 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 PlaybackSession property to get a MediaPlaybackSession object and then use the SeekCompleted event.

    public event TypedEventHandler SeekCompletedpublic event TypedEventHandler SeekCompletedPublic Event SeekCompleted
  • SourceChanged
    SourceChanged
    SourceChanged
    SourceChanged

    Occurs when the media source for the MediaPlayer changes.

    public event TypedEventHandler SourceChangedpublic event TypedEventHandler SourceChangedPublic Event SourceChanged

    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.

  • VolumeChanged
    VolumeChanged
    VolumeChanged
    VolumeChanged

    Occurs when the volume of the audio has changed.

    public event TypedEventHandler VolumeChangedpublic event TypedEventHandler VolumeChangedPublic Event VolumeChanged

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ActivatableAttribute

Details

Assembly

Windows.Media.Playback.dll