Media​Playback​Item Media​Playback​Item Media​Playback​Item Class

Definition

Represents a media item that can be played back. This class acts as a wrapper around a MediaSource that exposes the audio tracks, video tracks, and timed metadata tracks included in the media source.

public sealed class MediaPlaybackItem : IMediaPlaybackItem, IMediaPlaybackItem2, IMediaPlaybackItem3, IMediaPlaybackSourcepublic sealed class MediaPlaybackItem : IMediaPlaybackItem, IMediaPlaybackItem2, IMediaPlaybackItem3, IMediaPlaybackSourcePublic NotInheritable Class MediaPlaybackItem Implements IMediaPlaybackItem, IMediaPlaybackItem2, IMediaPlaybackItem3, IMediaPlaybackSource
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

A MediaPlaybackItem can be passed directly to a player such as MediaPlayer or MediaElement. Or, you can pass the player a list of multiple media playback items using the MediaPlaybackList class.

For how-to guidance for working with media items, see Media items, playlists, and tracks.

Constructors

MediaPlaybackItem(MediaSource) MediaPlaybackItem(MediaSource) MediaPlaybackItem(MediaSource)

Initializes a new instance of the MediaPlaybackItem class.

public MediaPlaybackItem(MediaSource source)public MediaPlaybackItem(MediaSource source)Public Sub New(source As MediaSource)
Parameters
source
MediaSource MediaSource MediaSource

The media source from which the MediaPlaybackItem is created.

Attributes

Remarks

A MediaSource can only be used by a single MediaPlaybackItem. If you attempt to create a second MediaPlaybackItem from the same MediaSource, the constructor will fail with an MF_E_UNEXPECTED error. In C# this error is projected as a System.Exception.

MediaPlaybackItem(MediaSource, TimeSpan) MediaPlaybackItem(MediaSource, TimeSpan) MediaPlaybackItem(MediaSource, TimeSpan)

Initializes a new instance of the MediaPlaybackItem class with a StartTime value indicating the position within the item where playback should begin.

public MediaPlaybackItem(MediaSource source, TimeSpan startTime)public MediaPlaybackItem(MediaSource source, TimeSpan startTime)Public Sub New(source As MediaSource, startTime As TimeSpan)
Parameters
source
MediaSource MediaSource MediaSource

The media source from which the MediaPlaybackItem is created.

startTime
TimeSpan TimeSpan TimeSpan

The position within the MediaPlaybackItem where playback should begin.

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

MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan) MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan) MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan)

Initializes a new instance of the MediaPlaybackItem class with a StartTime value indicating the position within the item where playback should begin and a DurationLimit value specifying the maximum playback duration of the item.

public MediaPlaybackItem(MediaSource source, TimeSpan startTime, TimeSpan durationLimit)public MediaPlaybackItem(MediaSource source, TimeSpan startTime, TimeSpan durationLimit)Public Sub New(source As MediaSource, startTime As TimeSpan, durationLimit As TimeSpan)
Parameters
source
MediaSource MediaSource MediaSource

The media source from which the MediaPlaybackItem is created.

startTime
TimeSpan TimeSpan TimeSpan

The position within the MediaPlaybackItem where playback should begin.

durationLimit
TimeSpan TimeSpan TimeSpan

The maximum playback duration of the MediaPlaybackItem.

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

Properties

AudioTracks AudioTracks AudioTracks

Gets a read-only list of audio tracks in the MediaSource associated with the MediaPlaybackItem.

public MediaPlaybackAudioTrackList AudioTracks { get; }public MediaPlaybackAudioTrackList AudioTracks { get; }Public ReadOnly Property AudioTracks As MediaPlaybackAudioTrackList
Attributes

AutoLoadedDisplayProperties AutoLoadedDisplayProperties AutoLoadedDisplayProperties

Gets or sets a value that specifies for which types of media content, if any, the system should automatically load metadata to display in the System Media Transport Controls.

public AutoLoadedDisplayPropertyKind AutoLoadedDisplayProperties { get; set; }public AutoLoadedDisplayPropertyKind AutoLoadedDisplayProperties { get; set; }Public ReadWrite Property AutoLoadedDisplayProperties As AutoLoadedDisplayPropertyKind
Value
AutoLoadedDisplayPropertyKind AutoLoadedDisplayPropertyKind AutoLoadedDisplayPropertyKind

A value that specifies for which types of media content the system should automatically load and display metadata.

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

Remarks

You can programmatically provide metadata for media items, instead of having the system dynamically load the metadata in the content, by calling GetDisplayProperties, setting the data of the returned MediaItemDisplayProperties, and then calling ApplyDisplayProperties. For more information, see Media items, playlists, and tracks.

BreakSchedule BreakSchedule BreakSchedule

Gets the MediaBreakSchedule defining the schedule of media breaks for the MediaPlaybackItem.

public MediaBreakSchedule BreakSchedule { get; }public MediaBreakSchedule BreakSchedule { get; }Public ReadOnly Property BreakSchedule As MediaBreakSchedule
Value
MediaBreakSchedule MediaBreakSchedule MediaBreakSchedule

The MediaBreakSchedule defining the schedule of media breaks for the MediaPlaybackItem.

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 MediaBreakSchedule object allows you to specify MediaBreak objects that should be played before the MediaPlaybackItem is played, after the item is played, or at scheduled positions within the item's playback.

For how-to guidance for working with media breaks, see Create, schedule, and manage media breaks.

See Also

CanSkip CanSkip CanSkip

Gets or sets a value indicating whether the MediaPlaybackItem can be skipped.

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

True if the MediaPlaybackItem can be skipped; 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)

DurationLimit DurationLimit DurationLimit

Gets the maximum playback duration of the MediaPlaybackItem.

public IReference<TimeSpan> DurationLimit { get; }public IReference<TimeSpan> DurationLimit { get; }Public ReadOnly Property DurationLimit As IReference<TimeSpan>
Value

The maximum playback duration of the MediaPlaybackItem.

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

Remarks

Set this value by using the @Windows.Media.Playback.MediaPlaybackItem.#ctor(Windows.Media.Core.MediaSource,Windows.Foundation.TimeSpan,Windows.Foundation.TimeSpan)?text=MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan) constructor to ensure that the MediaPlaybackItem will be played for no longer than the specified duration.

IsDisabledInPlaybackList IsDisabledInPlaybackList IsDisabledInPlaybackList

Gets or sets a value that specifies whether a MediaPlaybackItem is disabled in a MediaPlaybackList.

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

True if the media playback item is disabled in the playback list; 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

A example scenario for using this property is when network connectivity is lost, your app can check the TotalDownloadProgress property to see which items in the playback list have completed downloading. For items that have not completed, set IsDisabledInPlaybackList to true so that the item won't be played in the list.

Note that after playback of an item has begun, setting the IsDisabledInPlaybackList property has no effect.

Source Source Source

Gets the MediaSource object associated with the MediaPlaybackItem.

public MediaSource Source { get; }public MediaSource Source { get; }Public ReadOnly Property Source As MediaSource
Value
MediaSource MediaSource MediaSource

The MediaSource object associated with the MediaPlaybackItem.

Attributes

StartTime StartTime StartTime

Gets the position within the MediaPlaybackItem where playback should begin.

public TimeSpan StartTime { get; }public TimeSpan StartTime { get; }Public ReadOnly Property StartTime As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

The position within the MediaPlaybackItem where playback should begin.

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

Remarks

Set this value by using the @Windows.Media.Playback.MediaPlaybackItem.#ctor(Windows.Media.Core.MediaSource,Windows.Foundation.TimeSpan)?text=MediaPlaybackItem(MediaSource, TimeSpan) or @Windows.Media.Playback.MediaPlaybackItem.#ctor(Windows.Media.Core.MediaSource,Windows.Foundation.TimeSpan,Windows.Foundation.TimeSpan)?text=MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan) constructor to specify that playback of the MediaPlaybackItem should begin at a position other than the start of the item.

TimedMetadataTracks TimedMetadataTracks TimedMetadataTracks

Gets a read-only list of timed metadata tracks in the MediaSource associated with the MediaPlaybackItem.

public MediaPlaybackTimedMetadataTrackList TimedMetadataTracks { get; }public MediaPlaybackTimedMetadataTrackList TimedMetadataTracks { get; }Public ReadOnly Property TimedMetadataTracks As MediaPlaybackTimedMetadataTrackList
Attributes

TotalDownloadProgress TotalDownloadProgress TotalDownloadProgress

Gets a value that indicates the proportion of the data for the MediaPlaybackItem that is currently downloaded.

public double TotalDownloadProgress { get; }public double TotalDownloadProgress { get; }Public ReadOnly Property TotalDownloadProgress As double
Value
double double double

A value, between 0 and 1.0, that indicates the total download progress of the MediaPlaybackItem where 0 means that none of the data has been downloaded and 1.0 means that all of the data has been downloaded.

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

VideoTracks VideoTracks VideoTracks

Gets a read-only list of video tracks in the MediaSource associated with the MediaPlaybackItem.

public MediaPlaybackVideoTrackList VideoTracks { get; }public MediaPlaybackVideoTrackList VideoTracks { get; }Public ReadOnly Property VideoTracks As MediaPlaybackVideoTrackList
Attributes

Methods

ApplyDisplayProperties(MediaItemDisplayProperties) ApplyDisplayProperties(MediaItemDisplayProperties) ApplyDisplayProperties(MediaItemDisplayProperties)

Updates the display properties for the MediaPlaybackItem. These properties are used by the System Media Transport Controls to display information about the currently playing media item.

public void ApplyDisplayProperties(MediaItemDisplayProperties value)public void ApplyDisplayProperties(MediaItemDisplayProperties value)Public Function ApplyDisplayProperties(value As MediaItemDisplayProperties) As void
Parameters
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

Get the display properties for a MediaPlaybackItem by calling GetDisplayProperties.

For how-to guidance for integrating with the SMTC, see Integrate with the System Media Transport Controls.

FindFromMediaSource(MediaSource) FindFromMediaSource(MediaSource) FindFromMediaSource(MediaSource)

Retrieves the MediaPlaybackItem associated with the provided MediaSource.

public static MediaPlaybackItem FindFromMediaSource(MediaSource source)public static MediaPlaybackItem FindFromMediaSource(MediaSource source)Public Static Function FindFromMediaSource(source As MediaSource) As MediaPlaybackItem
Parameters
Returns
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

GetDisplayProperties() GetDisplayProperties() GetDisplayProperties()

Gets the display properties for a MediaPlaybackItem.

public MediaItemDisplayProperties GetDisplayProperties()public MediaItemDisplayProperties GetDisplayProperties()Public Function GetDisplayProperties() As MediaItemDisplayProperties
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

To modify the display properties for a MediaPlaybackItem, retrieve the properties by calling GetDisplayProperties, update the data in the MediaItemDisplayProperties, then call ApplyDisplayProperties.

For how-to guidance for integrating with the SMTC, see Integrate with the System Media Transport Controls.

Events

AudioTracksChanged AudioTracksChanged AudioTracksChanged

Occurs when the list of audio tracks in the MediaSource associated with the MediaPlaybackItem changes.

public event TypedEventHandler AudioTracksChangedpublic event TypedEventHandler AudioTracksChangedPublic Event AudioTracksChanged
Attributes

TimedMetadataTracksChanged TimedMetadataTracksChanged TimedMetadataTracksChanged

Occurs when the list of timed metadata tracks in the MediaSource associated with the MediaPlaybackItem changes.

public event TypedEventHandler TimedMetadataTracksChangedpublic event TypedEventHandler TimedMetadataTracksChangedPublic Event TimedMetadataTracksChanged
Attributes

VideoTracksChanged VideoTracksChanged VideoTracksChanged

Occurs when the list of video tracks in the MediaSource associated with the MediaPlaybackItem changes.

public event TypedEventHandler VideoTracksChangedpublic event TypedEventHandler VideoTracksChangedPublic Event VideoTracksChanged
Attributes

See Also