I want to detect whether [SimpleAudioEngine sharedEngine] is currently playing any effect. For Background music there is a method that gives you the information whether background music is playing:
[[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying];
Does something similar exist for sound effects? If not how else can I detect whether I am already playing an effect?
SimpleAudioEngine
Doesn't have a method like isBackgroundMusicPlaying
for effects, but you can store a BOOL
called isPlaying and use CDSoundSource
CDSoundSource* currentSound = [[CDAudioManager sharedManager] audioSourceForChannel:kASC_Right];
[currentSound load:audioFile];
currentSound.delegate = self;
currentSound.backgroundMusic = NO;
isPlaying = YES;
[currentSound play];
Then implement the callback:
- (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource {
isPlaying = NO;
}
I don't know exactly if that's the correct way to initialise the CDSoundSource
since I've stolen shamelessly the code from this topic . Maybe you should take a look at the CDAudioManager Class Reference
Hope this helps to point you in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With