private void KillLast() { if (Instance == null) return; if (IsMusic) { MusicInstance.Stop(); MusicInstance.Dispose(); } else { Instance.Stop(); Instance.Dispose(); } Instance = null; MusicInstance = null; }
public bool PlayNext() { if (Sounds.Count == 0) return false; KillLast(); var sound = Sounds[0]; Sounds.RemoveAt(0); Sounds.Insert(Sounds.Count + (new Random()).Next(1), sound); //put back at end, with a little bit of shuffle. if (IsMusic) { MusicInstance = new MP3Player(sound); Instance = MusicInstance.Inst; } else { if (!SFXCache.ContainsKey(sound)) SFXCache[sound] = SoundEffect.FromStream(new XAFile(sound).DecompressedStream); var sfx = SFXCache[sound]; Instance = sfx.CreateInstance(); } Instance.Volume = Volume; if (!IsMusic && Pan != 0) Instance.Pan = Pan; Instance.Play(); return true; }