AirPlay doesn't work correctly on iOS 17

User flow: u1. a user starts playing some audio in the app

  • before playing was set category
try audioSession.setCategory(.playback,
                                         mode: .default,
                                         policy: .longFormAudio)
  • was activated category
try audioSession.setActive(true, options: [])
  • set nowPlayingInfo
  • playing via AVPlayer

u2. user taps on the button of "airplay" (AVRoutePickerView) and changes the route of sound

u3. A user can hear sounds from a Bluetooth column, or connect to an Apple TV with its own audio system...

Issue: On iOS 17, after changing the route to Apple TV, a user can not hear a sound(apple tv works properly but sounds unavailable(if I do the same on iOS 16 everything works correctly)).

AVPlayer works correctly.

in the app I only receive event(name AVAudioSession.routeChangeNotification), and reason: RouteChangeReason.categoryChange (doc description: The audio category has changed (AVAudioSessionCategoryPlayback has been changed to AVAudioSessionCategoryPlayAndRecord).)

Apps capabilities has "Background Mode" = Audio, AirPlay....

Questions:

  1. Does AirPlay require addition configs on iOS 17?(i tried to add in info.plist "AVInitialRouteSharingPolicy = LongformAudio" - this does not help me)

  2. What going on with AVPlayer?(it is playing, but where sound?)

body of notification

Printing description of notification:
▿ name = AVAudioSessionRouteChangeNotification, object = Optional(<AVAudioSession: 0x280089e10>), userInfo = Optional([AnyHashable("AVAudioSessionRouteChangePreviousRouteKey"): <AVAudioSessionRouteDescription: 0x2800a8960, 
inputs = (
); 
outputs = (
    "<AVAudioSessionPortDescription: 0x2800a8300, type = Speaker; name = \U0414\U0438\U043d\U0430\U043c\U0456\U043a; UID = Speaker; selectedDataSource = (null)>"
)>, AnyHashable("AVAudioSessionRouteChangeReasonKey"): 3])
  - name : "AVAudioSessionRouteChangeNotification"
  - object : <AVAudioSession: 0x280089e10>
  ▿ userInfo : 2 elements
    ▿ 0 : 2 elements
      ▿ key : AnyHashable("AVAudioSessionRouteChangePreviousRouteKey")
        - value : "AVAudioSessionRouteChangePreviousRouteKey"
      - value : <AVAudioSessionRouteDescription: 0x2800a8960, 
inputs = (
); 
outputs = (
    "<AVAudioSessionPortDescription: 0x2800a8300, type = Speaker; name = \U0414\U0438\U043d\U0430\U043c\U0456\U043a; UID = Speaker; selectedDataSource = (null)>"
)>
    ▿ 1 : 2 elements
      ▿ key : AnyHashable("AVAudioSessionRouteChangeReasonKey")
        - value : "AVAudioSessionRouteChangeReasonKey"
      - value : 3
Post not yet marked as solved Up vote post of vit008 Down vote post of vit008
534 views