What's New / Media, Audio & Capture

What's new in AVSystemRouting

+17 NewiOS

AVSystemRouting manages system-level audio and media routing across output devices. The API centers on route controllers, route events, and routing errors.

17 new APIs, no deprecations or removals. New types include the enums AVSystemRouteLaunchMode and AVSystemRouteEventReason, the AVSystemRoutingError struct with a nested Code enum, and the protocols AVSystemRouteControllerObserver and AVSystemRouteDataDelegate. Nested members also land: AVSystemRoute.LaunchMode, AVSystemRouteEvent.Reason, and AVSystemRoutingError.Code.

New

17
extension

__AVSystemRoute

NewiOS
extension __AVSystemRoute

Properties for custom media app-to-extension communication.

Declaration
extension __AVSystemRoute {

    /// A data channel for communicating with the extension outside of any media session.
    ///
    /// Use this channel for control messages, state synchronization, and other bidirectional
    /// communication needs that are not tied to a specific ``AVSystemRouteSession-5i6j6``.
    open var routeDataChannel: __AVSystemRouteDataChannel { get }
}
extension

AVSystemRoute.LaunchMode

NewiOS
extension AVSystemRoute.LaunchMode : Equatable
Declaration
extension AVSystemRoute.LaunchMode : Equatable {
}
extension

AVSystemRoute.LaunchMode

NewiOS
extension AVSystemRoute.LaunchMode : Hashable
Declaration
extension AVSystemRoute.LaunchMode : Hashable {
}
protocol

AVSystemRouteControllerObserver

NewiOS
public protocol AVSystemRouteControllerObserver : AnyObject

A protocol for observers of a system routing controller.

Declaration
public protocol AVSystemRouteControllerObserver : AnyObject {

    /// Connects to, or disconnects from, a device when a user requests it in the
    /// picker.
    ///
    /// - Parameters:
    ///   - controller: The system routing controller.
    ///   - event: The routing event to handle.
    func systemRouteController(_ controller: AVSystemRouteController, handle event: AVSystemRouteEvent) async -> Bool
}
extension

AVSystemRouteControllerObserver

NewiOS
extension AVSystemRouteControllerObserver
Declaration
extension AVSystemRouteControllerObserver {

    /// Connects to, or disconnects from, a device when a user requests it in the
    /// picker.
    ///
    /// - Parameters:
    ///   - controller: The system routing controller.
    ///   - event: The routing event to handle.
    /// - Returns: `true` if the event was handled successfully, `false` otherwise.
    public func systemRouteController(_ controller: AVSystemRouteController, handle event: AVSystemRouteEvent) async -> Bool
}
protocol

AVSystemRouteDataDelegate

NewiOS
public protocol AVSystemRouteDataDelegate : AnyObject

A protocol for handling data from a remote application.

Declaration
public protocol AVSystemRouteDataDelegate : AnyObject {

    /// Receives data sent from a connected remote applicaiton.
    ///
    /// - Parameter data: The data received from the remote app.
    ///
    /// - Throws: An error if processing the received data fails.
    func receive(_ data: Data) async throws
}
extension

AVSystemRouteEvent.Reason

NewiOS
extension AVSystemRouteEvent.Reason : Equatable
Declaration
extension AVSystemRouteEvent.Reason : Equatable {
}
extension

AVSystemRouteEvent.Reason

NewiOS
extension AVSystemRouteEvent.Reason : Hashable
Declaration
extension AVSystemRouteEvent.Reason : Hashable {
}
enum

AVSystemRouteEventReason

NewiOS
public enum AVSystemRouteEventReason : Int, @unchecked Sendable

Values that indicate the reason for a routing event.

Declaration
public enum AVSystemRouteEventReason : Int, @unchecked Sendable {

    /// A value that indicates a user selected a route in the picker.
    case activate = 0

    /// A value that indicates a user deselected a route in the picker.
    case deactivate = 1
}
enum

AVSystemRouteLaunchMode

NewiOS
public enum AVSystemRouteLaunchMode : Int, @unchecked Sendable

The mode that determines how media playback launches on a remote device.

Use this enumeration with initWithURL:mode: to control how media playback is initiated on the remote device. The launch mode determines whether your app launches its counterpart on the remote device, or uses a system-provided media player.

Declaration
public enum AVSystemRouteLaunchMode : Int, @unchecked Sendable {

    /// Launches the corresponding application on the remote device.
    	///
    	/// Use this mode when you want to start your app's counterpart on the remote device,
    	/// enabling app-to-application communication and custom playback experiences. The remote application
    	/// can handle the provided URL and maintain bidirectional communication through the
    	/// `AVSystemRouteDataChannel` returned in the completion handler.
    	///
    	/// Application identifiers must be configured in the `MDESupportedProtocols`
    	/// key in your app's `Info.plist` file. For example:
    	/// ```xml
    	/// <key>MDESupportedProtocols</key>
    	///	<dict>
    	///		<key>com.example.sharingprotocol</key>
    	///		<string>com.example.myapplicationidentifier</string>
    	/// </dict>
    	/// ```
    	///
    	/// - Important: If `MDESupportedProtocols` is not set, calls to
    	///              ``AVSystemRouteSession/startWithCompletionHandler:`` fail.
    case application = 0

    /// Launches the system's built-in media player on the remote device.
    	///
    	/// Use this mode when you want to use the remote device's built-in media player
    	/// instead of launching a custom application. This provides a standardized playback
    	/// experience without requiring a corresponding application to be installed on the remote device.
    	///
    	/// To support the `AVSystemRouteLaunchModePlayer` launch mode,
    	/// the `MDESupportsUniversalURLPlayback` key must be set in the app's `Info.plist` file. For example:
    	/// ```xml
    	/// <key>MDESupportsUniversalURLPlayback</key>
    	/// <true/>
    	/// ```
    	///
    	/// - Important: If `MDESupportsUniversalURLPlayback` is not set to `true`, calls to
    	///              ``AVSystemRouteSession/startWithCompletionHandler:`` fail.
    case player = 1
}
struct

AVSystemRoutingError

NewiOS
public struct AVSystemRoutingError : CustomNSError, Hashable, Error
Declaration
public struct AVSystemRoutingError : CustomNSError, Hashable, Error {

    public init(_nsError: NSError)

    public static var errorDomain: String { get }

    /// An error that an AVSystemRouting operation throws when it fails.
    @available(iOS 27.0, *)
    public enum Code : Int, @unchecked Sendable, Equatable {

        /// An error that an AVSystemRouting operation throws when it fails.
        public typealias _ErrorType = AVSystemRoutingError

        /// A connection failure with the remote application.
        case connectionFailed = -73985
    }

    /// A connection failure with the remote application.
    public static var connectionFailed: AVSystemRoutingError.Code { get }
}
struct

AVSystemRoutingError

NewiOS
public struct AVSystemRoutingError : LocalizedError, Sendable

An error that an AVSystemRouting operation throws when it fails.

Declaration
public struct AVSystemRoutingError : LocalizedError, Sendable {

    /// The codes that identify the type of a routing error.
    public enum Code : Sendable {

        /// A connection failure with the remote application.
        case connectionFailed

        /// Returns a Boolean value indicating whether two values are equal.
        ///
        /// Equality is the inverse of inequality. For any values `a` and `b`,
        /// `a == b` implies that `a != b` is `false`.
        ///
        /// - Parameters:
        ///   - lhs: A value to compare.
        ///   - rhs: Another value to compare.
        public static func == (a: AVSystemRoutingError.Code, b: AVSystemRoutingError.Code) -> Bool

        /// Hashes the essential components of this value by feeding them into the
        /// given hasher.
        ///
        /// Implement this method to conform to the `Hashable` protocol. The
        /// components used for hashing must be the same as the components compared
        /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
        /// with each of these components.
        ///
        /// - Important: In your implementation of `hash(into:)`,
        ///   don't call `finalize()` on the `hasher` instance provided,
        ///   or replace it with a different instance.
        ///   Doing so may become a compile-time error in the future.
        ///
        /// - Parameter hasher: The hasher to use when combining the components
        ///   of this instance.
        public func hash(into hasher: inout Hasher)

        /// The hash value.
        ///
        /// Hash values are not guaranteed to be equal across different executions of
        /// your program. Do not save hash values to use during a future execution.
        ///
        /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
        ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
        ///   The compiler provides an implementation for `hashValue` for you.
        public var hashValue: Int { get }
    }

    /// The code that identifies the type of routing error.
    public let code: AVSystemRoutingError.Code

    /// Creates an error with the specified error code.
    ///
    /// - Parameter code: The error code for this error.
    public init(_ code: AVSystemRoutingError.Code)

    /// A localized description of the error.
    public var errorDescription: String? { get }

    /// A localized explanation of the reason for the error.
    public var failureReason: String? { get }

    /// A localized suggestion for how to recover from the error.
    public var recoverySuggestion: String? { get }

    /// A localized help anchor for the error.
    public var helpAnchor: String? { get }
}
extension

AVSystemRoutingError.Code

NewiOS
extension AVSystemRoutingError.Code : Equatable
Declaration
extension AVSystemRoutingError.Code : Equatable {
}
extension

AVSystemRoutingError.Code

NewiOS
extension AVSystemRoutingError.Code : Hashable
Declaration
extension AVSystemRoutingError.Code : Hashable {
}
enum

AVSystemRoute.LaunchMode

NewiOS
public enum LaunchMode : Sendable

The mode that determines how media playback launches on a remote device.

Use this enumeration with init(url:mode:) to control how media playback is initiated on the remote device. The launch mode determines whether your app launches its counterpart on the remote device, or uses a system-provided media player.

Declaration
public enum LaunchMode : Sendable {

    /// Launches the corresponding application on the remote device.
    ///
    /// Use this mode when you want to start your app's counterpart on the remote device,
    /// enabling app-to-application communication and custom playback experiences. The remote application
    /// can handle the provided URL and maintain bidirectional communication through the
    /// ``AVSystemRoute/DataChannel`` returned by ``AVSystemRouteSession/start()``.
    ///
    /// Application identifiers must be configured in the `MDESupportedProtocols`
    /// key in your app's `Info.plist` file. For example:
    /// ```xml
    /// <key>MDESupportedProtocols</key>
    ///	<dict>
    ///		<key>com.example.sharingprotocol</key>
    ///		<string>com.example.myapplicationidentifier</string>
    /// </dict>
    /// ```
    ///
    /// - Important: If `MDESupportedProtocols` is not set, calls to
    ///              ``AVSystemRouteSession/start()`` fail.
    case application

    /// Launches the system's built-in media player on the remote device.
    ///
    /// Use this mode when you want to use the remote device's built-in media player
    /// instead of launching a custom application. This provides a standardized playback
    /// experience without requiring a corresponding application to be installed on the remote device.
    ///
    /// To support the ``AVSystemRoute/LaunchMode/player`` launch mode, the `MDESupportsUniversalURLPlayback`
    /// key must be set in the app's `Info.plist` file. For example:
    /// ```xml
    /// <key>MDESupportsUniversalURLPlayback</key>
    /// <true/>
    /// ```
    ///
    /// - Important: If `MDESupportsUniversalURLPlayback` is not set to `true`, calls to
    ///              ``AVSystemRouteSession/start()`` fail.
    case player

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: AVSystemRoute.LaunchMode, b: AVSystemRoute.LaunchMode) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
enum

AVSystemRouteEvent.Reason

NewiOS
public enum Reason : Sendable

Values that indicate the reason for a routing event.

Declaration
public enum Reason : Sendable {

    /// A value that indicates a user selected a route in the picker.
    case activate

    /// A value that indicates a user deselected a route in the picker.
    case deactivate

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: AVSystemRouteEvent.Reason, b: AVSystemRouteEvent.Reason) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
enum

AVSystemRoutingError.Code

NewiOS
public enum Code : Int, @unchecked Sendable, Equatable

An error that an AVSystemRouting operation throws when it fails.

Declaration
public enum Code : Int, @unchecked Sendable, Equatable {

    /// An error that an AVSystemRouting operation throws when it fails.
    public typealias _ErrorType = AVSystemRoutingError

    /// A connection failure with the remote application.
    case connectionFailed = -73985
}

No APIs match your filter.

← More in Media, Audio & Capture