site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=G7R1WqWaSIwQ2Tw0Wu8AQ2u92WCBzwjnk4+t0LZ2Kt0=; b=Zib1zERS8QWFw6xEH48ErddCb9AB6pvWcYVcKvXYGTQWAarjaGRVDUW7G1hWBKT+G2 9T+zGtyITJylOEhaWhOJ3MQbU9hCwzMsoBd/jJtHAJA0Sl1AeELDOr5ubys1F+XU+1zY xwwJXf34g8Gbl6mp19CjLo5eco+i62p/2PfIDh8YRmEDdpa9Zt2gVAD+PFmRLp6eaUjX yb6ps3nB+9GlKq/Q9F3jUJbGyUYpENkeHAbo/TNVE/ZS6jg+svTJYeGzIn/Sej5AtO7c nqYFMRaKCVoglvLaX98M9if+/qdtCj9dpCpM+EuBubU5NL5jRTO+kL+h4xEic3yuyDVk MqWw== Hey all, I have an application I am developing and I cannot currently build to a device. So I am asking in lieu of proper testing on my end at the moment. 1. I would like to mix my audio with that in another session (say Apple Music is playing something). So before I play my app audio, I call this: func activateAudioSession() { let session = AVAudioSession.sharedInstance() do { try session.setCategory(AVAudioSessionCategoryPlayback , with: [. duckOthers, .allowBluetoothA2DP]) try session.setActive(true) } catch { print("Activate session error: \(error)") } } When my audio has completed playing, I call this (in all cases): func deactivateAudioSession() { let session = AVAudioSession.sharedInstance() // Do this on a separate thread because on UI thread causes 500ms delay. This unducks others after being ducked. DispatchQueue.global().async { do { try session.setActive(false) } catch { print("Deactivate session error: \(error)") } } } 2. There might be a time when I want to stomp on any audio from another session. In that case, I have another method I call that does NOT contain the .duckOthers option which I take to mean that mix with others is not enabled. func activateAudioSessionWithStompingOthers() { let session = AVAudioSession.sharedInstance() do { try session.setCategory(AVAudioSessionCategoryPlayback , with: [. allowBluetoothA2DP]) try session.setActive(true) } catch { print("Activate session error: \(error)") } } Does this seem about right? Also - if I stomp on another session (again, say Apple Music), that session pauses. Once that's done the user would need to manually unpause it - there is nothing I can do programmatically to get that going again, correct? Thanks for your attention, Eric _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com