From d348313b165dec70ec00220f98543383411d5773 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Mon, 5 Mar 2012 22:28:38 +0100 Subject: [PATCH] Added a 3 second fade at the start of the video. Some cleanup --- Vocaluxe/Base/CBackgroundMusic.cs | 21 +++++++++++++++---- Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 10 ++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 4ab3dd50..b4f2179e 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -31,6 +31,7 @@ namespace Vocaluxe.Base private static int _Video = -1; private static STexture _CurrentVideoTexture = new STexture(-1); + private static Stopwatch _FadeTimer = new Stopwatch(); public static void Init() { @@ -76,9 +77,12 @@ namespace Vocaluxe.Base public static void Stop() { - if (_VideoEnabled && _Video != 0) + if (_VideoEnabled && _Video != -1) + { CVideo.VdClose(_Video); - _Video = -1; + CDraw.RemoveTexture(ref _CurrentVideoTexture); + _Video = -1; + } CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); _CurrentPlaylistElement = new PlaylistElement(); @@ -127,7 +131,6 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; } - _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.GetMusicFilePath()); CSound.SetStreamVolume(_CurrentMusicStream, 0f); Play(); @@ -317,6 +320,15 @@ namespace Vocaluxe.Base { float vtime = 0f; CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime); + if (_FadeTimer.ElapsedMilliseconds <= 3000L) + { + _CurrentVideoTexture.color.A = (_FadeTimer.ElapsedMilliseconds / 3000f); + } + else + { + _CurrentVideoTexture.color.A = 1f; + _FadeTimer.Stop(); + } CDraw.DrawTexture(bounds, _CurrentVideoTexture, EAspect.Crop); return true; } @@ -357,10 +369,11 @@ namespace Vocaluxe.Base { if (_Video == -1) { - CVideo.VdClose(_Video); _Video = CVideo.VdLoad(_CurrentPlaylistElement.GetVideoFilePath()); CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream), _CurrentPlaylistElement.GetVideoGap()); _VideoEnabled = true; + _FadeTimer.Reset(); + _FadeTimer.Start(); } } } diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 085ec6d1..18cc6690 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -133,9 +133,6 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { - Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying(); - Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying(); - Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle(); return true; } @@ -151,6 +148,7 @@ namespace Vocaluxe.Screens return false; if (CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.HasVideo()) { + Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); CBackgroundMusic.UploadNewFrame(Statics[htStatics(StaticCover)]); Statics[htStatics(StaticCover)].Visible = false; } @@ -159,6 +157,12 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticCover)].Visible = true; Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); } + Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying(); + Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying(); + Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle(); + if (CBackgroundMusic.IsVideoEnabled()) + Buttons[htButtons(ButtonShowVideo)].SColor = CTheme.GetColor("ButtonSColor"); + return base.Draw(); }