PlaylistApi

@objc(BMPPlaylistApi)
public protocol PlaylistApi

Provides the means to manage the playlist.

When the player transitions from one source in the playlist to another (either by normal playback or by seeking), a PlaylistTransition event is emitted and the new Source becomes active while the old one becomes inactive.

Accessible through Player.playlist.

  • The list of Sources currently in the playlist. Exactly one source is always active in a playlist.

    Declaration

    Swift

    var sources: [Source] { get }
  • Seeks to the specified time in the specified Source. The Source must be part of the playlist.

    Calling this method to seek to another source while casting will start playback automatically after the seek operation finished even if the player was paused previously. This is due to limitations on the CAF receiver.

    Declaration

    Swift

    func seek(source: Source, time: TimeInterval)
  • Adds the given Source to the playlist at the specified index.

    The Source is added before the Source that currently resides at the specified index.

    Limitations:

    • Adding the same Source instance more than once is not supported and will result in a no-op.
    • Adding a Source before a load or after an unload call will result in a no-op.
    • Adding a Source after playback has finished will result in a no-op.

    Declaration

    Swift

    func add(source: Source, at index: Int)

    Parameters

    source

    The Source that will be added to the playlist.

    index

    The index at which to add the new Source. index must be greater than or equal to zero and must not exceed the number of Sources in the playlist.

  • Adds the given Source to the end of the playlist

    Limitations:

    • Adding the same Source instance more than once is not supported and will result in a no-op.
    • Adding a Source before a load or after an unload call will result in a no-op.
    • Adding a Source after playback has finished will result in a no-op.

    Declaration

    Swift

    func add(source: Source)

    Parameters

    source

    The Source that will be added to the playlist.

  • Removes a Source from the playlist at the specified index.

    Limitations:

    • Removing the currently active Source is not possible. If the index that corresponds to the active source’s index is passed it will result in a no-op.

    Declaration

    Swift

    func remove(sourceAt index: Int)

    Parameters

    index

    The index from which to remove the Source. index must be greater than or equal to zero and must be less than the number of Sources in the playlist.