MediaPlaybackList MediaPlaybackList MediaPlaybackList MediaPlaybackList Class

Definition

Represents a list of MediaPlaybackItem objects that can be played back. Provides methods for switching the currently playing item and enabling looping and shuffling.

public : sealed class MediaPlaybackList : IMediaPlaybackList, IMediaPlaybackList2, IMediaPlaybackList3, IMediaPlaybackSource
public sealed class MediaPlaybackList : IMediaPlaybackList, IMediaPlaybackList2, IMediaPlaybackList3, IMediaPlaybackSource
Public NotInheritable Class MediaPlaybackList Implements IMediaPlaybackList, IMediaPlaybackList2, IMediaPlaybackList3, IMediaPlaybackSource
var mediaPlaybackList = new mediaPlaybackList();
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Items in a MediaPlaybackList are rendered using gapless playback. The system will use provided metadata in MP3 or AAC encoded files to determine the delay or padding compensation needed for gapless playback. If the MP3 or AAC encoded files don't provide this metadata, then the system determines the delay or padding heuristically. For lossless formats, such as PCM, FLAC, or ALAC, the system takes no action because these encoders don't introduce delay or padding.

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

Constructors

MediaPlaybackList() MediaPlaybackList() MediaPlaybackList() MediaPlaybackList()

Initializes a new instance of the MediaPlaybackList class.

public : MediaPlaybackList()
public MediaPlaybackList()
Public Sub New()
var mediaPlaybackList = new mediaPlaybackList();

Properties

AutoRepeatEnabled AutoRepeatEnabled AutoRepeatEnabled AutoRepeatEnabled

Gets or sets a value indicating whether the playback list will loop when the end of the list is reached.

public : Platform::Boolean AutoRepeatEnabled { get; set; }
public bool AutoRepeatEnabled { get; set; }
Public ReadWrite Property AutoRepeatEnabled As bool
var bool = mediaPlaybackList.autoRepeatEnabled;
mediaPlaybackList.autoRepeatEnabled = bool;
Value
Platform::Boolean bool bool bool

True if auto-repeat is enabled; otherwise, false.

CurrentItem CurrentItem CurrentItem CurrentItem

Gets the currently playing MediaPlaybackItem.

public : MediaPlaybackItem CurrentItem { get; }
public MediaPlaybackItem CurrentItem { get; }
Public ReadOnly Property CurrentItem As MediaPlaybackItem
var mediaPlaybackItem = mediaPlaybackList.currentItem;

CurrentItemIndex CurrentItemIndex CurrentItemIndex CurrentItemIndex

Gets the index of the current item in the@Windows.Media.Playback.MediaPlaybackList?text=MediaPlaybackList.

public : unsigned int CurrentItemIndex { get; }
public uint CurrentItemIndex { get; }
Public ReadOnly Property CurrentItemIndex As uint
var uint = mediaPlaybackList.currentItemIndex;
Value
unsigned int uint uint uint

The index of the current item in the@Windows.Media.Playback.MediaPlaybackList?text=MediaPlaybackList.

Items Items Items Items

Gets an IObservableVector representation of the playback list.

public : IObservableVector<MediaPlaybackItem> Items { get; }
public IObservableVector<MediaPlaybackItem> Items { get; }
Public ReadOnly Property Items As IObservableVector<MediaPlaybackItem>
var iObservableVector = mediaPlaybackList.items;

MaxPlayedItemsToKeepOpen MaxPlayedItemsToKeepOpen MaxPlayedItemsToKeepOpen MaxPlayedItemsToKeepOpen

Gets or sets a value that specifies the number of MediaPlaybackItem objects that should be kept open after they have been played.

public : IReference<unsigned int> MaxPlayedItemsToKeepOpen { get; set; }
public Nullable<uint> MaxPlayedItemsToKeepOpen { get; set; }
Public ReadWrite Property MaxPlayedItemsToKeepOpen As Nullable<uint>
var nullable = mediaPlaybackList.maxPlayedItemsToKeepOpen;
mediaPlaybackList.maxPlayedItemsToKeepOpen = nullable;
Value
IReference<unsigned int> Nullable<uint> Nullable<uint> Nullable<uint>

A value that specifies the number of MediaPlaybackItem objects that should be kept open after they have been played.

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

Remarks

Set this value to cause the system to keep the specified number of media playback items open after they have been played so that, if the users navigates backwards through the playback list, the open items can be played immediately without needing to be reopened. The trade off is that the more items that are kept open, the more memory is used by your app, which is especially important to consider with background media playback, where resources are more limited than for a foreground app.

MaxPrefetchTime MaxPrefetchTime MaxPrefetchTime MaxPrefetchTime

Gets or sets the maximum time before a MediaPlaybackItem in the list is expected to play that the media content associated with the item is retrieved.

public : IReference<TimeSpan> MaxPrefetchTime { get; set; }
public Nullable<TimeSpan> MaxPrefetchTime { get; set; }
Public ReadWrite Property MaxPrefetchTime As Nullable<TimeSpan>
var nullable = mediaPlaybackList.maxPrefetchTime;
mediaPlaybackList.maxPrefetchTime = nullable;
Value
IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>

The maximum time before a MediaPlaybackItem in the list is expected to play that the media content associated with the item is retrieved.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

ShuffledItems ShuffledItems ShuffledItems ShuffledItems

Gets a read-only list of of MediaPlaybackItem objects that will be played in shuffle mode, in the order in which they will be played.

public : IVectorView<MediaPlaybackItem> ShuffledItems { get; }
public IReadOnlyList<MediaPlaybackItem> ShuffledItems { get; }
Public ReadOnly Property ShuffledItems As IReadOnlyList<MediaPlaybackItem>
var iReadOnlyList = mediaPlaybackList.shuffledItems;
Value
IVectorView<MediaPlaybackItem> IReadOnlyList<MediaPlaybackItem> IReadOnlyList<MediaPlaybackItem> IReadOnlyList<MediaPlaybackItem>

A read-only list of of MediaPlaybackItem objects that will be played in shuffle mode

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

Replace the list of pending shuffled items by calling SetShuffledItems.

ShuffleEnabled ShuffleEnabled ShuffleEnabled ShuffleEnabled

Gets or sets a value indicating whether the items in the playback list are played in a random order.

public : Platform::Boolean ShuffleEnabled { get; set; }
public bool ShuffleEnabled { get; set; }
Public ReadWrite Property ShuffleEnabled As bool
var bool = mediaPlaybackList.shuffleEnabled;
mediaPlaybackList.shuffleEnabled = bool;
Value
Platform::Boolean bool bool bool

True if shuffle is enabled; otherwise, false.

StartingItem StartingItem StartingItem StartingItem

Gets or sets the MediaPlaybackItem that will be played first.

public : MediaPlaybackItem StartingItem { get; set; }
public MediaPlaybackItem StartingItem { get; set; }
Public ReadWrite Property StartingItem As MediaPlaybackItem
var mediaPlaybackItem = mediaPlaybackList.startingItem;
mediaPlaybackList.startingItem = mediaPlaybackItem;
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

The MediaPlaybackItem specified for this property is played first regardless of whether ShuffleEnabled is true.

Methods

MoveNext() MoveNext() MoveNext() MoveNext()

Changes the current item of the MediaPlaybackList to the next item in the list.

public : MediaPlaybackItem MoveNext()
public MediaPlaybackItem MoveNext()
Public Function MoveNext() As MediaPlaybackItem
var mediaPlaybackItem = mediaPlaybackList.moveNext();
Returns

Remarks

This current item of the MediaPlaybackList can't be changed while a MediaPlaybackItem with CanSkip set to false is playing. Attempting to do so will cause an exception to be thrown.

MovePrevious() MovePrevious() MovePrevious() MovePrevious()

Changes the current item of the MediaPlaybackList to the previous item in the list.

public : MediaPlaybackItem MovePrevious()
public MediaPlaybackItem MovePrevious()
Public Function MovePrevious() As MediaPlaybackItem
var mediaPlaybackItem = mediaPlaybackList.movePrevious();
Returns

Remarks

This current item of the MediaPlaybackList can't be changed while a MediaPlaybackItem with CanSkip set to false is playing. Attempting to do so will cause an exception to be thrown.

MoveTo(UInt32) MoveTo(UInt32) MoveTo(UInt32) MoveTo(UInt32)

Changes the current item of the MediaPlaybackList to the item with the specified index.

public : MediaPlaybackItem MoveTo(unsigned int itemIndex)
public MediaPlaybackItem MoveTo(UInt32 itemIndex)
Public Function MoveTo(itemIndex As UInt32) As MediaPlaybackItem
var mediaPlaybackItem = mediaPlaybackList.moveTo(itemIndex);
Parameters
itemIndex
unsigned int UInt32 UInt32 UInt32

The index of the item to make current.

Returns

Remarks

This current item of the MediaPlaybackList can't be changed while a MediaPlaybackItem with CanSkip set to false is playing. Attempting to do so will cause an exception to be thrown.

SetShuffledItems(IIterable) SetShuffledItems(IIterable) SetShuffledItems(IIterable) SetShuffledItems(IIterable)

Sets the list of MediaPlaybackItem objects that will be played in shuffle mode, in the order in which they will be played.

public : void SetShuffledItems(IIterable<MediaPlaybackItem> value)
public void SetShuffledItems(IEnumerable<MediaPlaybackItem> value)
Public Function SetShuffledItems(value As IEnumerable<MediaPlaybackItem>) As void
mediaPlaybackList.setShuffledItems(value);
Parameters
value
IIterable<MediaPlaybackItem> IEnumerable<MediaPlaybackItem> IEnumerable<MediaPlaybackItem> IEnumerable<MediaPlaybackItem>

The list of MediaPlaybackItem objects that will be played in shuffle mode.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

Use this method to manage the order in which items are played when ShuffleEnabled is set to true, replacing the shuffle order generated by the system.

Events

CurrentItemChanged CurrentItemChanged CurrentItemChanged CurrentItemChanged

Occurs when the currently playing MediaPlaybackItem changes.

public : event TypedEventHandler CurrentItemChanged<MediaPlaybackList, CurrentMediaPlaybackItemChangedEventArgs>
public event TypedEventHandler CurrentItemChanged<MediaPlaybackList, CurrentMediaPlaybackItemChangedEventArgs>
Public Event TypedEventHandler CurrentItemChanged( Of ( Of MediaPlaybackList ), ( Of CurrentMediaPlaybackItemChangedEventArgs ))
function onCurrentItemChanged(eventArgs){/* Your code */}


mediaPlaybackList.addEventListener("currentItemChanged", onCurrentItemChanged);
mediaPlaybackList.removeEventListener("currentItemChanged", onCurrentItemChanged);

ItemFailed ItemFailed ItemFailed ItemFailed

Occurs when an error is encountered with a MediaPlaybackItem in the playback list.

public : event TypedEventHandler ItemFailed<MediaPlaybackList, MediaPlaybackItemFailedEventArgs>
public event TypedEventHandler ItemFailed<MediaPlaybackList, MediaPlaybackItemFailedEventArgs>
Public Event TypedEventHandler ItemFailed( Of ( Of MediaPlaybackList ), ( Of MediaPlaybackItemFailedEventArgs ))
function onItemFailed(eventArgs){/* Your code */}


mediaPlaybackList.addEventListener("itemFailed", onItemFailed);
mediaPlaybackList.removeEventListener("itemFailed", onItemFailed);

ItemOpened ItemOpened ItemOpened ItemOpened

Occurs when a MediaPlaybackItem in the playback list is successfully opened.

public : event TypedEventHandler ItemOpened<MediaPlaybackList, MediaPlaybackItemOpenedEventArgs>
public event TypedEventHandler ItemOpened<MediaPlaybackList, MediaPlaybackItemOpenedEventArgs>
Public Event TypedEventHandler ItemOpened( Of ( Of MediaPlaybackList ), ( Of MediaPlaybackItemOpenedEventArgs ))
function onItemOpened(eventArgs){/* Your code */}


mediaPlaybackList.addEventListener("itemOpened", onItemOpened);
mediaPlaybackList.removeEventListener("itemOpened", onItemOpened);

See Also