<!--
{
  "documentType" : "article",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/supporting-airplay-in-your-app",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Supporting AirPlay in your app"
}
-->

# Supporting AirPlay in your app

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

## Discussion

AirPlay enables you to send content wirelessly from an Apple device to an Apple TV or AirPlay-enabled speaker. AirPlay provides enhanced support for wireless audio distribution, including the ability to send content to multiple AirPlay-enabled speakers.

### Identify the audio type the app plays

In iOS, tvOS, and watchOS, set your audio session’s route-sharing policy to `.longForm`. Long-form audio is anything other than system sounds, such as music, audiobooks, or podcasts. This setting identifies the audio that an app plays, such as in the following example.

```swift
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, 
                             mode: .default, 
                             policy: .longFormAudio)
```

### Add an AirPlay picker

Add <doc://com.apple.documentation/documentation/AVKit/AVRoutePickerView> to your view hierarchy to include an AirPlay picker in your app. The picker provides users with a list of potential AirPlay devices they can use with your app. To control when to show the picker, use [`AVRouteDetector`](/documentation/AVFoundation/AVRouteDetector) to identify the state of the route detector.

### Add a media player

Use APIs to customize your AirPlay adoption with Media Player integration. If you use <doc://com.apple.documentation/documentation/MediaPlayer/MPRemoteCommandCenter>, you can receive remote commands. If you use <doc://com.apple.documentation/documentation/MediaPlayer/MPNowPlayingInfoCenter>, you can inform the system metadata about the track that’s playing on the device.

### Configure an app for fast streaming

Adopt one of two playback API sets that take advantage of the enhanced buffering in AirPlay:

- For simple enhanced buffering, use [`AVPlayer`](/documentation/AVFoundation/AVPlayer) or [`AVQueuePlayer`](/documentation/AVFoundation/AVQueuePlayer). This works well for video content. For more information, see [Implementing simple enhanced buffering for your content](/documentation/AVFoundation/implementing-simple-enhanced-buffering-for-your-content).
- For more flexibility with enhanced buffering, use [`AVSampleBufferAudioRenderer`](/documentation/AVFoundation/AVSampleBufferAudioRenderer) and [`AVSampleBufferRenderSynchronizer`](/documentation/AVFoundation/AVSampleBufferRenderSynchronizer). This option is better for apps that require control over I/O, perform preprocessing on their media data, or have a DRM model that [`AVPlayer`](/documentation/AVFoundation/AVPlayer) doesn’t support. For more information, see [Implementing flexible enhanced buffering for your content](/documentation/AVFoundation/implementing-flexible-enhanced-buffering-for-your-content).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)