Media Device
Let people stream media from any iOS app to your playback hardware through the media device picker.
Overview
Media Device lets you make your playback hardware available to the system. People can then stream to it from any iOS app, selecting your device from the media device picker. The picker is the same UI people use for AirPlay and Bluetooth output. You build a MediaDeviceExtension that the system loads when someone opens the picker, and your extension handles discovery, connection, and playback on behalf of the system.
[Image]
The extension life cycle follows three phases: discovery, activation, and playback. During discovery, your extension reports available devices to the system through MediaDeviceRoutingManager. Your devices appear in the media device picker that media apps present to people. When someone selects one of your devices, the system creates a MediaOutputSession and asks your extension to connect. After your extension connects and calls activatedDevice(_:session:), the system notifies supporting media apps about the selected device, and they can call playback APIs such as startSession(_:identifier:url:).
Your extension may also register to receive real-time audio and video samples by conforming to RealtimeSampleHandling. Real-time streaming, including screen mirroring, requires your extension to publish an audio server driver plug-in shortly after the system activates the device; follow Creating an Audio Server Driver Plug-in to create it. To capture video samples, use ScreenCaptureKit.
Media Device works with AVSystemRouting, which provides the API for media apps. Media apps use AVSystemRouteController to observe route changes, and AVSystemRoute to control playback while your extension handles the protocol-specific communication with the hardware.
Topics
Essentials
Creating a media device extensionRouting media to third-party devicesMediaDeviceExtensionMediaDeviceExtensionConfiguration
Device discovery and management
MediaOutputDeviceMediaOutputDevice.CapabilitiesMediaOutputDevice.DeviceTypeMediaOutputDevice.VolumeControlMediaOutputDevice.AuthorizationMethod