Contents

Implementing simple enhanced buffering for your content

Configure your app for simple enhanced buffering to stream content faster to AirPlay-enabled devices and supported CarPlay vehicles.

Overview

The AVPlayer and AVQueuePlayer classes provide the simplest way to enhance buffering for your content with AirPlay 2.

To implement simple enhanced buffering, complete the following steps.

  1. Create a player.

let player = AVQueuePlayer()
  1. Identify a URL that points to local or cloud content that you want to play.

  2. Create an AVAsset instance with a URL, and then create an AVPlayerItem instance with that asset.

let url = URL(string: "http://www.examplecontenturl.com")!
let asset = AVAsset(url: url)
let item = AVPlayerItem(asset: asset)
  1. Give the player item to the player.

player.insert(item, after: nil)
  1. Start playback.

player.play()

See Also

Buffered playback