spotify / ios-sdk

Spotify SDK for iOS
https://developer.spotify.com/documentation/ios/
660 stars 185 forks source link

Play two streams simultaneously #34

Open JCardenete opened 6 years ago

JCardenete commented 6 years ago

When the Spotify app starts playing, it's automatically interrupting a stream that is playing from within my app. I could handle both with the previous SDK but I'm not sure if this is possible with the new one?

jackfreeman commented 6 years ago

@JCardenete You can play two streams simultaneously by setting your audio session to allow mixin of other audio sources: https://developer.apple.com/documentation/avfoundation/avaudiosession/categoryoptions/1616611-mixwithothers

For more info on configuration Audio Sessions see Apple's documentation here https://developer.apple.com/library/archive/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionBasics/AudioSessionBasics.html

JCardenete commented 6 years ago

Thanks @jackfreeman, that worked. Downside of this is we're losing control of the remote control center which is now owned by Spotify. So pausing/playing from there will only affect Spotify's stream but not ours.

jackfreeman commented 6 years ago

@JCardenete have a look at MPNowPlayingInfoCenter. Since your app is in the foreground it should be able to set the media controls.

jackfreeman commented 6 years ago

There is also MPRemoteCommandCenter

JCardenete commented 6 years ago

Yes, we're using those already. But it seems that when setting the 'mixWithOthers' iOS doesn't consider your app to show in the remote control center.

jackfreeman commented 6 years ago

@JCardenete You might try duckOthers too to see if it gives you priority on the control center (this will lower the volume of Spotify when sounds from your app play)

JCardenete commented 6 years ago

That didn't work either @jackfreeman, 'mixWithOthers' is making our app irrelevant for the control center.