public void PlaySound(string name, bool loop) { if (paused) { return; } if (sounds.ContainsKey(name)) { AudioEffect ass = ((AudioEffect)sounds.Get(name)); ass.Loop(loop); ass.PlayAudioEffect(); } else { if (clipCount > 50) { int idx = sounds.Size() - 1; string k = (string)sounds.GetKey(idx); AudioEffect clip = (AudioEffect)sounds.Remove(k); clip.StopAudioEffect(); clip = null; clipCount--; } asound = new AudioEffect(name); asound.Loop(loop); asound.PlayAudioEffect(); sounds.Put(name, asound); clipCount++; } }
public void StopSound(int index) { AudioEffect sound = (AudioEffect)sounds.Get(index); if (sound != null) { sound.StopAudioEffect(); } }
public AudioEffectSound CreateAudio(string path) { AudioEffectSound player = new AudioEffectSound(); try { AudioEffect effect = MediaSound.NewAudioEffect(path); player.OnLoaded(effect); } catch (Exception ex) { player.OnLoadError(ex); } return(player); }
public void StopSoundAll() { if (sounds != null) { List <ArrayMap.Entry> list = sounds.ToList(); for (int i = 0; i < list.Count; i++) { ArrayMap.Entry sound = list[i]; if (sound != null) { AudioEffect ass = (AudioEffect)sound.GetValue(); if (ass != null) { ass.StopAudioEffect(); } } } } }