From 837ee463b550f614b34373cc41d4a1efe52a2194 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 3 Dec 2012 09:16:13 +0100 Subject: [PATCH] Previous-function of bg-music is now similar to other audio-player. Clicking on prev-button during song: Play song from start, Clicking on prev-button during first 1.5 sec, go to prev song. --- Vocaluxe/Base/CBackgroundMusic.cs | 37 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 506c8c52..ad10b81a 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -294,25 +294,30 @@ namespace Vocaluxe.Base { if (_PreviousFileNames.Count > 0 || _PreviousMusicIndex >= 0) { - Stop(); + float pos = CSound.GetPosition(_CurrentMusicStream); + if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f) + { + CSound.SetPosition(_CurrentMusicStream, 0); + if (_VideoEnabled && _Video != -1) + CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); + } + else + { + Stop(); + _PreviousMusicIndex--; + if (_PreviousMusicIndex < 0) + _PreviousMusicIndex = 0; //No previous songs left, so play the first - _PreviousMusicIndex--; - if (_PreviousMusicIndex < 0) - _PreviousMusicIndex = 0; //No previous songs left, so play the first + _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; - _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; - - _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); - if (_VideoEnabled) - LoadVideo(); - CSound.SetStreamVolume(_CurrentMusicStream, 0f); - Play(); + _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); + if (_VideoEnabled) + LoadVideo(); + CSound.SetStreamVolume(_CurrentMusicStream, 0f); + Play(); + } } - } - - public static void Repeat() - { - if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1) + else if (_CurrentMusicStream != -1) { CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1)