Howto check whether Ipod is playing music
Hello again,
well I already use AudioServicesSystemSounds for many clicks/clacks and similar things.
I like that because the player may start his ipod to have his music running while playing the game. (doubletapping the mainbutton even opens a small ipodmenu on top of the game).
Now to create a better athmosphere I want to play an intro, but only if the ipod is not playing any music currently. I think that actually makes sense, because when the user starts the game without having music running he really wants to play and I should give him the big thing.
So where can I get the "BOOL" that is YES when the ipod is currently playing music?
well I already use AudioServicesSystemSounds for many clicks/clacks and similar things.
I like that because the player may start his ipod to have his music running while playing the game. (doubletapping the mainbutton even opens a small ipodmenu on top of the game).
Now to create a better athmosphere I want to play an intro, but only if the ipod is not playing any music currently. I think that actually makes sense, because when the user starts the game without having music running he really wants to play and I should give him the big thing.
So where can I get the "BOOL" that is YES when the ipod is currently playing music?
Here's a function that'll do what you want...
On OS 3.x you need to initialize your audio session first (using kAudioSessionCategory_AmbientSound) before checking for other audio. You can then set the session category to SoloAmbientSound or MediaPlayback if you want to stop the other audio, or just leave it as AmbientSound to keep the other audio playing.
On OS 2.x yer pretty much SOL, 'cause AFAICT kAudioSessionProperty_OtherAudioIsPlaying always returns true on OS 2.2.1. In that case I just use SoloAmbientSound when I have my own music and AmbientSound if not.
Code:
bool OtherAudioIsPlaying(void)
{
UInt32 audioPlaying = 0;
UInt32 audioPlayingSize = sizeof(audioPlaying);
AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &audioPlayingSize, &audioPlaying);
return (bool)audioPlaying;
}On OS 3.x you need to initialize your audio session first (using kAudioSessionCategory_AmbientSound) before checking for other audio. You can then set the session category to SoloAmbientSound or MediaPlayback if you want to stop the other audio, or just leave it as AmbientSound to keep the other audio playing.
On OS 2.x yer pretty much SOL, 'cause AFAICT kAudioSessionProperty_OtherAudioIsPlaying always returns true on OS 2.2.1. In that case I just use SoloAmbientSound when I have my own music and AmbientSound if not.
Works a treat, thank you
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| HowTo initialize an EAGLView.m as a Subview | Bersaelor | 4 | 5,821 |
Oct 23, 2009 09:06 AM Last Post: Bersaelor |
|
| Turning off mixing iPod music | dsk00 | 0 | 2,245 |
Jun 4, 2009 10:25 PM Last Post: dsk00 |
|
| Sanity check, Aisle 9 | KittyMac | 6 | 3,602 |
Sep 14, 2006 07:51 PM Last Post: KittyMac |
|
| Howto compile a Maya Plug-in on OS X? | webwarrior | 4 | 4,145 |
Dec 16, 2004 01:19 PM Last Post: KenD |
|
| Texture loading code check. | CarbonX | 0 | 2,090 |
Jul 31, 2004 10:47 PM Last Post: CarbonX |
|

