diff --git a/src/Audio/CCAudioEngine.cs b/src/Audio/CCAudioEngine.cs index 8df6353a5..abb76cd1b 100644 --- a/src/Audio/CCAudioEngine.cs +++ b/src/Audio/CCAudioEngine.cs @@ -382,6 +382,21 @@ public int PlayEffect (string filename, bool loop=false) return nId; } + + public bool EffectPlaying(int fxid) + { + bool playing = false; + + lock (list) + { + CCEffectPlayer effect = null; + + if (list.TryGetValue(fxid, out effect)) + playing = effect.Playing; + } + + return playing; + } public void StopEffect(int soundId) { diff --git a/tests/tests/classes/tests/CocosDenshionTest/CocosDenshionTest.cs b/tests/tests/classes/tests/CocosDenshionTest/CocosDenshionTest.cs index c05647deb..5f42ed2e5 100644 --- a/tests/tests/classes/tests/CocosDenshionTest/CocosDenshionTest.cs +++ b/tests/tests/classes/tests/CocosDenshionTest/CocosDenshionTest.cs @@ -361,6 +361,16 @@ void AddButtons() audio.StopAllEffects(); }; AddChildAt(btnStopAll, 0.9f, 0.6f); + + var effectsIsPlaying = new Button("Effects playing"); + effectsIsPlaying.Triggered += (sender, e) => + { + if (audio.EffectPlaying(soundId)) + CCLog.Log("sound effect is playing"); + else + CCLog.Log("sound effect is not playing"); + }; + AddChildAt(effectsIsPlaying, 0.7f, 0.4f); } AudioSlider sliderPitch, sliderMusicVolume, sliderEffectsVolume, sliderPan, sliderGain;