public void SetMusic(string se, bool looping) { float volume = game.settings.musVolume; if (game.settings.mutedMusic) { volume = 0; } if (File.Exists(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg")) { if (currentMusic == se) { return; } currentMusic = se; if (music != null) { music.Stop(); } } else { currentMusic = ""; music.Stop(); Console.WriteLine("PANIC: MUSIC FILE " + se + " NOT FOUND"); return; } if (se != currentMusic || music == null) { if (music != null) { music.Stop(); music.Dispose(); music = null; } music = new OggStream(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg"); music.IsLooped = looping; music.Volume = volume; music.Play(); currentMusic = se; } else { if (music.IsFinished()) { music.Stop(); music.Dispose(); music = null; music = new OggStream(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg"); music.IsLooped = looping; music.Volume = volume; music.Play(); currentMusic = se; } } }
void PlatformDispose(bool disposing) { if (stream == null) { return; } stream.Dispose(); stream = null; }
public void Dispose() { if (_stream == null) { return; } Stop(); _stream.Dispose(); _stream = null; }
void PlatformDispose(bool disposing) { lock (_sourceMutex) { if (stream == null) { return; } stream.Dispose(); stream = null; } }
internal Song(string name, string file, AudioFormat format = AudioFormat.Ogg) { if (format != AudioFormat.Ogg) { throw new NotImplementedException("Support for formats other than ogg is not yet implemented."); } _name = name; _file = file; try { _stream = new OggStream(_file); _stream.Prepare(); } catch (InvalidDataException) { _stream.Dispose(); _stream = new OggStream(_file); _stream.Prepare(); } }
void PlatformDispose(bool disposing) { stream.Dispose(); }