Article

Implementing Simple Enhanced Buffering for Your Content

Configure your app for simple enhanced buffering to stream content faster to your AirPlay-enabled device.

Overview

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

To do simple enhanced buffering, complete this 4 step process.

  1. Instantiate an AVPlayer or AVQueuePlayer object.

    Listing 1

    Instantiate an AVPlayer or AVQueuePlayer object.

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

  3. Wrap the URL in an AVAsset object, and wrap that AVAsset object in an AVPlayerItem object:

    Listing 2

    Wrap the URL in an AVAsset object, and wrap that AVAsset object in an AVPlayerItem object.

    let url = URL(string: "http://www.examplecontenturl.com")
    let asset = AVAsset(url: url)
    let item = AVPlayerItem(asset: asset)
    
  4. Give this AVPlayerItem object to the AVQueuePlayer object:

    Listing 3

    Give this AVPlayerItem object to the AVQueuePlayer object.

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

See Also

Getting Started

Getting AirPlay 2 into Your App

Set up your app to use AirPlay 2 to send content wirelessly.

Implementing Flexible Enhanced Buffering for Your Content

Configure your app for flexible enhanced buffering to stream content faster to your AirPlay-enabled device.

Playing Custom Audio with Your Own Player

Construct an audio player to play your custom audio data, and optionally take advantage of the advanced features of AirPlay 2.

Integrating AirPlay for Long-Form Video Apps

Integrate AirPlay features and implement a dedicated external playback experience by preparing the routing system for long-form video playback.