Delen via


MediaPlaybackSession Class

Definition

Provides information about the state of the current playback session of a MediaPlayer and provides events for responding to changes in playback session state.

public ref class MediaPlaybackSession sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class MediaPlaybackSession final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class MediaPlaybackSession
Public NotInheritable Class MediaPlaybackSession
Inheritance
Object Platform::Object IInspectable MediaPlaybackSession
Attributes

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Remarks

Get an instance of this class by accessing the PlaybackSession property of a MediaPlayer or the PlaybackSession property of a MediaBreakManager.

For how-to guidance for working with MediaPlayer and playback sessions, see Play audio and video with MediaPlayer.

Version history

Windows version SDK version Value added
1703 15063 BufferedRangesChanged
1703 15063 GetBufferedRanges
1703 15063 GetPlayedRanges
1703 15063 GetSeekableRanges
1703 15063 IsMirroring
1703 15063 IsSupportedPlaybackRateRange
1703 15063 PlayedRangesChanged
1703 15063 SeekableRangesChanged
1703 15063 SphericalVideoProjection
1703 15063 SupportedPlaybackRatesChanged
1803 17134 GetOutputDegradationPolicyState
1803 17134 PlaybackRotation

Properties

BufferingProgress

Gets a value that indicates the current buffering progress of a MediaPlaybackSession.

CanPause

Gets a value that indicates whether media can be paused if the MediaPlayer.Pause method is called.

CanSeek

Gets a value that indicates whether the current playback position of the media can be changed by setting the value of the MediaPlayer.Position property.

DownloadProgress

Gets a value indicating the position after the current playback Position to which downloading has completed and content is buffered.

IsMirroring

Gets or sets a value indicating whether the content of the media playback session is currently being mirrored horizontally.

IsProtected

Gets a value that indicates whether the media that is currently playing in the MediaPlaybackSession is protected by digital rights management (DRM).

MediaPlayer

Gets the MediaPlayer associated with the MediaPlaybackSession.

NaturalDuration

Gets a value indicating the duration of the currently playing media, when being played back at normal speed.

NaturalVideoHeight

Gets the height of the video in the currently playing media item.

NaturalVideoWidth

Gets the width of the video in the currently playing media item.

NormalizedSourceRect

Gets or sets a normalized rectangle within the video source which is rendered by the MediaPlayer. This enables pan and zoom within video.

PlaybackRate

Gets or sets a value representing the current playback rate for the MediaPlaybackSession.

PlaybackRotation

Gets or sets a value from the MediaRotation enumeration that specifies the rotation applied to video content during playback.

PlaybackState

Gets a value indicating the current playback state of the MediaPlaybackSession, such as buffering or playing.

Position

Gets or sets the current playback position within the currently playing media.

SphericalVideoProjection

Gets an object that manages the spherical video projection settings used by the media playback session.

StereoscopicVideoPackingMode

Gets or sets a value specifying the stereoscopic video packing mode for the MediaPlaybackSession.

Methods

GetBufferedRanges()

Retrieves a read-only list of time ranges for which data is buffered and playback can begin immediately.

GetOutputDegradationPolicyState()

Gets an object that expresses the current output degradation policy state of the MediaPlaybackSession.

GetPlayedRanges()

Retrieves a read-only list of time ranges for which content has been played back.

GetSeekableRanges()

Retrieves a read-only list of time ranges in which the playack position can be seeked to. For live streaming, these ranges represent the times ranges for which data is still available.

IsSupportedPlaybackRateRange(Double, Double)

Gets a value indicating whether the specified range of playback rates is supported.

Events

BufferedRangesChanged

Occurs when the set of time ranges for which data is buffered changes.

BufferingEnded

Occurs when buffering ends for the MediaPlaybackSession.

BufferingProgressChanged

Occurs when the buffering progress for the MediaPlaybackSession changes.

BufferingStarted

Occurs when buffering starts for the MediaPlaybackSession.

DownloadProgressChanged

Occurs when the download progress for a MediaPlaybackSession changes.

NaturalDurationChanged

Occurs when the duration of the currently playing media item changes.

NaturalVideoSizeChanged

Occurs when the size of the video in the currently playing media item changes.

PlaybackRateChanged

Occurs when the current playback rate for the MediaPlaybackSession changes.

PlaybackStateChanged

Occurs when the current playback state changes.

PlayedRangesChanged

Occurs when the set of time ranges that have been played changes.

PositionChanged

Occurs when the current playback position within the currently playing media changes.

SeekableRangesChanged

Occurs when the set of time ranges that can be seeked to changes.

SeekCompleted

Occurs when a seek operation for the MediaPlaybackSession completes.

SupportedPlaybackRatesChanged

Occurs when the set of playback rates supported by the media playback session changes.

Applies to

See also