Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Close #288 Audio engine: Add ability to check if effects are playing
Browse files Browse the repository at this point in the history
  • Loading branch information
rtabbara committed Dec 19, 2015
1 parent e39a5ae commit 56d3258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Audio/CCAudioEngine.cs
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions tests/tests/classes/tests/CocosDenshionTest/CocosDenshionTest.cs
Expand Up @@ -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;
Expand Down

0 comments on commit 56d3258

Please sign in to comment.