Game Development Community

User music while playing game.

by Brian Chaon · in iTorque 2D · 03/23/2009 (12:54 pm) · 6 replies

When I test the game on the device. If I am listening to music, the music shuts off. Is there a setting or something i can do to let the player be able to listen to thier own music while playing my game. Or is there something simple im missing.

#1
03/24/2009 (9:40 am)
Try adding this little code snippet right after #ifdef TORQUE_OS_IPHONE in OpenALInit() - you'll find this near the end of the audio.cc file.

// Let iPhone music play in the background
   AudioSessionInitialize(NULL, NULL, NULL, NULL);
   UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
   AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
   AudioSessionSetActive(true);
#2
03/24/2009 (9:50 am)
This won't work, because a structure in TGB is using the name of Apple's audiobuffer structure. It needs a little more reworking. I'd consider making their own struct AudioBuffer a bug in iTGB.
#3
03/24/2009 (10:57 am)
Oh yeah, that's right. I ended up changing the name of the class AudioBuffer in iTGB to iTgbAudioBuffer and then changed all the references to it to the new name. Took about ten minutes or so to update the few files that used AudioBuffer.
#4
03/24/2009 (11:48 am)
I've submitted it as a bug/feature request, and got a reply immediately. Bet they'll do something with it later :)
#5
03/24/2009 (7:48 pm)
Kevin: You know that VC++ as well as XCode have a refactor capability that would do this with 2 clicks and 20s of time? (sooooorrryy :) )
#6
03/25/2009 (3:45 pm)
I'm not real familiar with the whole XCode environment yet, so I sometimes fumble around looking for what I need. I know what I want to do - I know the tool can probably do it - but there is the problem of my knowledge gap of exactly "how" - followed by clicking on promising looking menus. :^)

So you can see why I was pretty happy to have something up and running in the simulator so quickly when I first checked out the SVN repo of my iTGB game onto my Mac.