Instance Method

replaceCurrentItem(with:)

Replaces the current player item with a new player item.

Declaration

func replaceCurrentItem(with item: AVPlayerItem?)

Parameters

item

A player item.

Discussion

The player item replacement occurs immediately and item becomes the player’s currentItem. Calling this method with the player’s current player item has no effect.

You can use Key-value observing to observe changes to the player’s currentItem property.

Special Considerations

The new item must have the same compositor as the item it replaces, or have no compositor.

See Also

Managing Playback

func play()

Begins playback of the current item.

func pause()

Pauses playback of the current item.

var rate: Float

The current playback rate.

var actionAtItemEnd: AVPlayer.ActionAtItemEnd

The action to perform when the current player item has finished playing.

enum AVPlayer.ActionAtItemEnd

The actions a player should take when it finishes playing.

var preventsDisplaySleepDuringVideoPlayback: Bool

A Boolean value that indicates whether video playback prevents display and device sleep.