6

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?

Guru
  • 21,652
  • 10
  • 63
  • 102
gebirgsbärbel
  • 2,327
  • 1
  • 22
  • 38

1 Answers1

3

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.

Youssef
  • 3,582
  • 1
  • 21
  • 28