Contents

addSession(_:)

Adds a session to the active route.

Declaration

final func addSession(_ session: AVSystemRouteSession) -> Bool

Parameters

  • session:

    The session to add to this route. The session must be newly created and not already associated with another route or previously stopped.

Mentioned in

Return Value

true if the route successfully adds the session; false if the route cannot add it (for example, if the session is already associated with another route or if the route is in an invalid state).

Discussion

Call this function to register a new AVSystemRouteSession with the route before starting playback or communication. The session must be added to the route before calling its start() function.

Adding a session establishes the association between the session and this route, enabling the system to manage the session’s lifecycle and route media appropriately. You can add multiple sessions to a single route to handle different media streams or communication channels.

Sessions are single-use. Once a session has been stopped, it cannot be added to a route again. Create a new AVSystemRouteSession for each new playback.