Determine if a sound effect is reproduced in SimpleAudioEngine

I want to determine if [SimpleAudioEngine sharedEngine] is currently playing any effect. For background music, there is a method that gives you information about whether background music is playing:

[[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying]; 

Is there something similar for sound effects? If not, how else can I determine if I really play an effect?

+6
source share
1 answer

SimpleAudioEngine There is no method like isBackgroundMusicPlaying for effects, but you can save 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 call back:

 - (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource { isPlaying = NO; } 

I don’t know exactly if it is right to initialize the CDSoundSource , since I stole shamelessly the code from this section . Perhaps you should take a look at the description of the CDAudioManager class

We hope this helps you in the right direction.

+3
source

Source: https://habr.com/ru/post/897465/


All Articles