From e908f923e80f06f434fe029398dc91d2f5091810 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 7 May 2014 00:39:58 +0200 Subject: [PATCH] Fix unintended song loop due to api change --- .../PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs | 4 ++-- Vocaluxe/Base/CMain.cs | 4 ++-- Vocaluxe/Base/CSound.cs | 11 +++-------- Vocaluxe/Screens/CScreenSing.cs | 2 +- VocaluxeLib/IBasic.cs | 2 +- VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs | 2 +- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index 6b5ccaad..2131cd14 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -503,7 +503,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe CBase.BackgroundMusic.SetStatus(true); - _PreviewStream = CBase.Sound.Load(song.GetMP3(), false); + _PreviewStream = CBase.Sound.Load(song.GetMP3()); CBase.Sound.SetPosition(_PreviewStream, song.Preview.StartTime); CBase.Sound.SetStreamVolume(_PreviewStream, 0f); CBase.Sound.Play(_PreviewStream); @@ -527,7 +527,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe CSong song = CBase.Songs.GetSongByID(songID); CBase.BackgroundMusic.SetStatus(true); - _PreviewStream = CBase.Sound.Load(song.GetMP3(), false); + _PreviewStream = CBase.Sound.Load(song.GetMP3()); CBase.Sound.SetPosition(_PreviewStream, song.Preview.StartTime); CBase.Sound.SetStreamVolume(_PreviewStream, 0f); CBase.Sound.Play(_PreviewStream); diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 533444fd..f8d0b073 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -773,9 +773,9 @@ namespace Vocaluxe.Base class CBsound : ISound { - public int Load(string soundFile, bool prescan) + public int Load(string soundFile, bool loop = false, bool prescan = false) { - return CSound.Load(soundFile, prescan); + return CSound.Load(soundFile, loop, prescan); } public void SetPosition(int soundStream, float newPosition) diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 4a39e03e..9d7f65dd 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -85,14 +85,9 @@ namespace Vocaluxe.Base } #region Stream Handling - public static int Load(string media) + public static int Load(string media, bool loop=false, bool prescan=false) { - return _Playback.Load(media); - } - - public static int Load(string media, bool prescan) - { - return _Playback.Load(media, prescan); + return _Playback.Load(media, loop, prescan); } public static void Close(int stream) @@ -194,7 +189,7 @@ namespace Vocaluxe.Base if (!File.Exists(file)) return -1; - int stream = Load(file, fade); + int stream = Load(file, false, fade); if (stream < 0) return -1; Play(stream); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 42cdab5d..d39a6202 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -597,7 +597,7 @@ namespace Vocaluxe.Screens songname += " (" + CGame.RoundNr + "/" + rounds + ")"; _Texts[_TextSongName].Text = songname; - _CurrentStream = CSound.Load(song.GetMP3(), true); + _CurrentStream = CSound.Load(song.GetMP3(), false, true); CSound.SetStreamVolume(_CurrentStream, _Volume); CSound.SetPosition(_CurrentStream, song.Start); _CurrentTime = song.Start; diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 3ec5204c..739bbdf7 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -256,7 +256,7 @@ namespace VocaluxeLib public interface ISound { - int Load(string soundFile, bool prescan); + int Load(string soundFile, bool loop = false, bool prescan = false); void SetPosition(int soundStream, float newPosition); void Play(int soundStream); void Fade(int soundStream, float targetVolume, float duration); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 6743c1f8..b1106b7b 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -523,7 +523,7 @@ namespace VocaluxeLib.Menu.SongMenu if (song == null) return; - int stream = CBase.Sound.Load(Path.Combine(song.Folder, song.MP3FileName), true); + int stream = CBase.Sound.Load(Path.Combine(song.Folder, song.MP3FileName), true, true); float startposition = song.Preview.StartTime; float length = CBase.Sound.GetLength(stream);