How to prevent my app from closing the user's currently playing music?

Member
Posts: 29
Joined: 2008.10
Post: #1
When i launch my iphone application the music that's currently playing from the iphone is stopped; how can i prevent this behaviour?
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #2
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?
Quote this message in a reply
Member
Posts: 29
Joined: 2008.10
Post: #3
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.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #4
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
Quote this message in a reply
Member
Posts: 29
Joined: 2008.10
Post: #5
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!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Slowdown while playing many OpenAL sounds and accessing AVAudioPlayer.playing Rasterman 6 5,972 Aug 31, 2010 09:46 PM
Last Post: headkaze
  Playing sounds and music on iPhone, which API to use? Jamie W 17 9,417 Apr 20, 2010 07:55 AM
Last Post: Beast
  Prevent 3rd party lib from messing up gl kendric 6 4,468 Sep 15, 2009 06:56 PM
Last Post: kendric
  Prevent screen from dimming during game npatrick6 3 3,734 May 22, 2009 10:22 PM
Last Post: AnotherJake
  Prevent iPhone SnapShot? Graphic Ace 5 3,838 Mar 29, 2009 08:49 AM
Last Post: Graphic Ace