AVAudioSession output route switches back from Airplay to HDMI after sleep/wake
Originator: | aman | ||
Number: | rdar://44875522 | Date Originated: | |
Status: | Resolved: | ||
Product: | Product Version: | ||
Classification: | Reproducible: |
Area: tvOS SDK Steps to Reproduce: 1. Hold down Play button on the Siri remote. 2. Turn on Airplay output and disable local output. 3. Launch app that activates AVAudioSession and notice that session.currentRoute.outputs.firstObject.portType says Airplay 4. Hold down TV button and put the ATV to sleep 5. Wake up the ATV 6. Launch app that activates AVAudioSession and expect Airplay but see HDMI output 7. Go to home screen and hold down Play button. Airplay option is still selected Version/Build: Apple TV 4 tvOS 12.0 Code: import UIKit import AVFoundation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let notificationCenter = NotificationCenter.default notificationCenter.addObserver(self, selector: #selector(handleRouteChange), name: AVAudioSession.routeChangeNotification, object: nil) return true } @objc func handleRouteChange(notification: Notification) { guard let userInfo = notification.userInfo, let reasonValue = userInfo[AVAudioSessionRouteChangeReasonKey] as? UInt, let reason = AVAudioSession.RouteChangeReason(rawValue:reasonValue) else { return } print("route changed: reason=\(reason)") } func applicationWillResignActive(_ application: UIApplication) { let session = AVAudioSession.sharedInstance() do { try session.setActive(false) } catch { print("deactive error: \(error)") } } func applicationDidBecomeActive(_ application: UIApplication) { let session = AVAudioSession.sharedInstance() do { try session.setCategory(.playback, mode: .moviePlayback, policy: .longForm) try session.setActive(true) print("outputs: \(session.currentRoute.outputs)") } catch { print("reactive error: \(error)") } } } Output: outputs: [<AVAudioSessionPortDescription: 0x1c000ed20, type = AirPlay; name = AirPlay; UID = 12779568-c588-478e-8019-d3b65ae2c30b; selectedDataSource = (null)>] <sleep> <wake> outputs: [<AVAudioSessionPortDescription: 0x1c000f870, type = HDMIOutput; name = Entertainment Room; UID = 4C2DBA07-0000-0000-2E14-010380593278; selectedDataSource = (null)>]
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
+1
Same issue :-( Is someone found a fix?
I have exactly the same problem, but i've notice that other apps can correctly output to Airplay after wake up....so it must be a way to avoid this :)
If you find more info about this pls let us know.