do not play bg music files twice until all files are played

This commit is contained in:
Alexander Eckart committed 2012-02-23 20:19:19 +01:00
1 parent 351aa6e799
commit 0e73a77c0b
1 file changed
+13 -1
+13 -1
View File
@@ -16,6 +16,7 @@ namespace Vocaluxe.Base
private static string _CurrentMusicFilePath = String.Empty; private static string _CurrentMusicFilePath = String.Empty;
private static List<string> _AllFileNames = new List<string>(); private static List<string> _AllFileNames = new List<string>();
private static List<string> _NotPlayedFileNames = new List<string>();
private static List<string> _BGMusicFileNames = new List<string>(); private static List<string> _BGMusicFileNames = new List<string>();
private static bool _OwnMusicAdded; private static bool _OwnMusicAdded;
@@ -84,7 +85,12 @@ namespace Vocaluxe.Base
{ {
Stop(); Stop();
_CurrentMusicFilePath = _AllFileNames[CGame.Rand.Next(_AllFileNames.Count)]; if (_NotPlayedFileNames.Count == 0)
_NotPlayedFileNames.AddRange(_AllFileNames);
_CurrentMusicFilePath = _NotPlayedFileNames[CGame.Rand.Next(_NotPlayedFileNames.Count)];
_NotPlayedFileNames.Remove(_CurrentMusicFilePath);
_CurrentMusicStream = CSound.Load(_CurrentMusicFilePath); _CurrentMusicStream = CSound.Load(_CurrentMusicFilePath);
CSound.SetStreamVolume(_CurrentMusicStream, 0f); CSound.SetStreamVolume(_CurrentMusicStream, 0f);
Play(); Play();
@@ -105,6 +111,7 @@ namespace Vocaluxe.Base
foreach (CSong song in CSongs.AllSongs) foreach (CSong song in CSongs.AllSongs)
{ {
_AllFileNames.Add(song.GetMP3()); _AllFileNames.Add(song.GetMP3());
_NotPlayedFileNames.Add(song.GetMP3());
} }
} }
_OwnMusicAdded = true; _OwnMusicAdded = true;
@@ -113,9 +120,13 @@ namespace Vocaluxe.Base
public static void RemoveOwnMusic() public static void RemoveOwnMusic()
{ {
_AllFileNames.Clear(); _AllFileNames.Clear();
_NotPlayedFileNames.Clear();
if (_BackgroundMusicAdded) if (_BackgroundMusicAdded)
{
_AllFileNames.AddRange(_BGMusicFileNames); _AllFileNames.AddRange(_BGMusicFileNames);
_NotPlayedFileNames.AddRange(_BGMusicFileNames);
}
if (IsPlaying() && !IsBackgroundFile(_CurrentMusicFilePath) || _AllFileNames.Count == 0) if (IsPlaying() && !IsBackgroundFile(_CurrentMusicFilePath) || _AllFileNames.Count == 0)
Next(); Next();
@@ -128,6 +139,7 @@ namespace Vocaluxe.Base
if (!_BackgroundMusicAdded) if (!_BackgroundMusicAdded)
{ {
_AllFileNames.AddRange(_BGMusicFileNames); _AllFileNames.AddRange(_BGMusicFileNames);
_NotPlayedFileNames.AddRange(_BGMusicFileNames);
_BackgroundMusicAdded = true; _BackgroundMusicAdded = true;
} }
} }