iDevGames Forums
How to prevent my app from closing the user's currently playing music? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: How to prevent my app from closing the user's currently playing music? (/thread-908.html)



How to prevent my app from closing the user's currently playing music? - AdrianM - Aug 4, 2009 08:03 AM

When i launch my iphone application the music that's currently playing from the iphone is stopped; how can i prevent this behaviour?


How to prevent my app from closing the user's currently playing music? - bruss14 - Aug 4, 2009 09:21 AM

Use AudioSessionSetProperty() and choose an kAudioSessionCategory_ that doesn't stop music playback such as kAudioSessionCategory_UserInterfaceSoundEffects and then it'll play them both at the same time.

Is that what you're looking to do?


How to prevent my app from closing the user's currently playing music? - AdrianM - Aug 4, 2009 11:24 AM

bruss14 Wrote:Use AudioSessionSetProperty() and choose an kAudioSessionCategory_ that doesn't stop music playback such as kAudioSessionCategory_UserInterfaceSoundEffects and then it'll play them both at the same time.

Is that what you're looking to do?

Well, i tried doing it like this:

AudioSessionInitialize(NULL, NULL, NULL, self);
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);

AudioSessionSetActive(true);

but it does not work. I am playing sounds with OpenAL and when my app launches it still stops the current track played from the ipod library.


How to prevent my app from closing the user's currently playing music? - Frank C. - Aug 4, 2009 01:07 PM

I've found this to be touchy in OS 3.x depending where and when you initialize OpenAL. Try this order:

AudioSessionInitialize
AudioSessionSetProperty
Init OpenAL (alcOpenDevice, alcCreateContext, alcMakeContextCurrent, etc.)
AudioSessionSetActive


How to prevent my app from closing the user's currently playing music? - AdrianM - Aug 5, 2009 03:21 AM

Frank C. Wrote:I've found this to be touchy in OS 3.x depending where and when you initialize OpenAL. Try this order:

AudioSessionInitialize
AudioSessionSetProperty
Init OpenAL (alcOpenDevice, alcCreateContext, alcMakeContextCurrent, etc.)
AudioSessionSetActive

Thanks, it finally worked!