MediaPlaybackItem
MediaPlaybackItem
MediaPlaybackItem
MediaPlaybackItem
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// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
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) MediaPlaybackItem(MediaSource)
Initializes a new instance of the MediaPlaybackItem class.
public : MediaPlaybackItem(MediaSource source)public MediaPlaybackItem(MediaSource source)Public Sub New(source As MediaSource)// You can use this method in JavaScript.
The media source from which the MediaPlaybackItem is created.
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) 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)// You can use this method in JavaScript.
The media source from which the MediaPlaybackItem is created.
- startTime
- TimeSpan TimeSpan TimeSpan TimeSpan
The position within the MediaPlaybackItem where playback should begin.
| 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) 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)// You can use this method in JavaScript.
The media source from which the MediaPlaybackItem is created.
- startTime
- TimeSpan TimeSpan TimeSpan TimeSpan
The position within the MediaPlaybackItem where playback should begin.
- durationLimit
- TimeSpan TimeSpan TimeSpan TimeSpan
The maximum playback duration of the MediaPlaybackItem.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
- See Also
Properties
AudioTracks 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// You can use this property in JavaScript.
- Value
- MediaPlaybackAudioTrackList MediaPlaybackAudioTrackList MediaPlaybackAudioTrackList MediaPlaybackAudioTrackList
The read-only list of audio tracks.
AutoLoadedDisplayProperties 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// You can use this property in JavaScript.
- Value
- AutoLoadedDisplayPropertyKind AutoLoadedDisplayPropertyKind AutoLoadedDisplayPropertyKind AutoLoadedDisplayPropertyKind
A value that specifies for which types of media content the system should automatically load and display metadata.
| 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 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// You can use this property in JavaScript.
The MediaBreakSchedule defining the schedule of media breaks for the MediaPlaybackItem.
| 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 CanSkip
Gets or sets a value indicating whether the MediaPlaybackItem can be skipped.
public : PlatForm::Boolean CanSkip { get; set; }public bool CanSkip { get; set; }Public ReadWrite Property CanSkip As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the MediaPlaybackItem can be skipped; otherwise, false.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
DurationLimit DurationLimit DurationLimit DurationLimit
Gets the maximum playback duration of the MediaPlaybackItem.
public : IReference<TimeSpan> DurationLimit { get; }public Nullable<TimeSpan> DurationLimit { get; }Public ReadOnly Property DurationLimit As Nullable<TimeSpan>// You can use this property in JavaScript.
- Value
- IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>
The maximum playback duration of the MediaPlaybackItem.
| 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 MediaPlaybackItem(MediaSource, TimeSpan, TimeSpan) constructor to ensure that the MediaPlaybackItem will be played for no longer than the specified duration.
IsDisabledInPlaybackList IsDisabledInPlaybackList IsDisabledInPlaybackList IsDisabledInPlaybackList
Gets or sets a value that specifies whether a MediaPlaybackItem is disabled in a MediaPlaybackList.
public : PlatForm::Boolean IsDisabledInPlaybackList { get; set; }public bool IsDisabledInPlaybackList { get; set; }Public ReadWrite Property IsDisabledInPlaybackList As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the media playback item is disabled in the playback list; otherwise, false.
| 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 Source
Gets the MediaSource object associated with the MediaPlaybackItem.
public : MediaSource Source { get; }public MediaSource Source { get; }Public ReadOnly Property Source As MediaSource// You can use this property in JavaScript.
The MediaSource object associated with the MediaPlaybackItem.
StartTime 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// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The position within the MediaPlaybackItem where playback should begin.
| 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 MediaPlaybackItem(MediaSource, TimeSpan) or 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 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// You can use this property in JavaScript.
- Value
- MediaPlaybackTimedMetadataTrackList MediaPlaybackTimedMetadataTrackList MediaPlaybackTimedMetadataTrackList MediaPlaybackTimedMetadataTrackList
The read-only list of timed metadata tracks.
TotalDownloadProgress 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// You can use this property in JavaScript.
- Value
- double 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.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
VideoTracks 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// You can use this property in JavaScript.
- Value
- MediaPlaybackVideoTrackList MediaPlaybackVideoTrackList MediaPlaybackVideoTrackList MediaPlaybackVideoTrackList
The read-only list of video tracks.
Methods
ApplyDisplayProperties(MediaItemDisplayProperties) 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// You can use this method in JavaScript.
- value
- MediaItemDisplayProperties MediaItemDisplayProperties MediaItemDisplayProperties MediaItemDisplayProperties
The display properties to apply to the MediaPlaybackItem.
| 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) 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// You can use this method in JavaScript.
The MediaSource associated with the MediaPlaybackItem.
The MediaPlaybackItem associated with the provided MediaSource.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
GetDisplayProperties() GetDisplayProperties() GetDisplayProperties() GetDisplayProperties()
Gets the display properties for a MediaPlaybackItem.
public : MediaItemDisplayProperties GetDisplayProperties()public MediaItemDisplayProperties GetDisplayProperties()Public Function GetDisplayProperties() As MediaItemDisplayProperties// You can use this method in JavaScript.
The display properties for a MediaPlaybackItem.
| 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 AudioTracksChanged
Occurs when the list of audio tracks in the MediaSource associated with the MediaPlaybackItem changes.
public : event TypedEventHandler AudioTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>public event TypedEventHandler AudioTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>Public Event AudioTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>// You can use this event in JavaScript.
TimedMetadataTracksChanged TimedMetadataTracksChanged TimedMetadataTracksChanged TimedMetadataTracksChanged
Occurs when the list of timed metadata tracks in the MediaSource associated with the MediaPlaybackItem changes.
public : event TypedEventHandler TimedMetadataTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>public event TypedEventHandler TimedMetadataTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>Public Event TimedMetadataTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>// You can use this event in JavaScript.
VideoTracksChanged VideoTracksChanged VideoTracksChanged VideoTracksChanged
Occurs when the list of video tracks in the MediaSource associated with the MediaPlaybackItem changes.
public : event TypedEventHandler VideoTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>public event TypedEventHandler VideoTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>Public Event VideoTracksChanged<MediaPlaybackItem, IVectorChangedEventArgs>// You can use this event in JavaScript.