public static bool LoadSound(string path, string name) { if (!File.Exists(path)) return false; int channels, bitsPerSample, sampleRate; byte[] soundData = LoadWave(File.Open(path, FileMode.Open), out channels, out bitsPerSample, out sampleRate); var sound = new Sound(soundData, channels, sampleRate, bitsPerSample, name); sound.Volume = GameConstants.DefaultSoundVolume; Sounds.Add(name, sound); return true; }
/// <summary> /// Plays a random song from the playlist. /// </summary> public static void NextSong() { if (!Enabled) return; int index = Playlist.IndexOf(CurrentSound); int song = index; //we should not play the current song again while(song == index) song = GeneralMath.RandomInt() % Playlist.Count; if(index != -1) previousSound = Playlist[index]; CurrentSound = Playlist[song]; FadeOut(); }