Some improvements.
This commit is contained in:
1 parent
6dda1a38d0
commit
6c4fe011bf
6 files changed
+55
-66
No files matched your search
@@ -51,8 +51,13 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static bool VideoEnabled
|
public static bool VideoEnabled
|
||||||
{
|
{
|
||||||
get { return _SongPlayer.VideoEnabled; }
|
get { return _PlaysPreview ? _PreviewPlayer.VideoEnabled : _SongPlayer.VideoEnabled; }
|
||||||
set { _SongPlayer.VideoEnabled = value; }
|
set {
|
||||||
|
if(_PlaysPreview)
|
||||||
|
_PreviewPlayer.VideoEnabled = value;
|
||||||
|
else
|
||||||
|
_SongPlayer.VideoEnabled = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CanSing { get { return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? false : _SongPlayer.CanSing; } }
|
public static bool CanSing { get { return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? false : _SongPlayer.CanSing; } }
|
||||||
@@ -152,8 +157,8 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void Close()
|
public static void Close()
|
||||||
{
|
{
|
||||||
_SongPlayer.Close();
|
_SongPlayer.Stop();
|
||||||
_PreviewPlayer.Close();
|
_PreviewPlayer.Stop();
|
||||||
|
|
||||||
_BGMusicFiles.Clear();
|
_BGMusicFiles.Clear();
|
||||||
_NotPlayedFiles.Clear();
|
_NotPlayedFiles.Clear();
|
||||||
@@ -168,7 +173,7 @@ namespace Vocaluxe.Base
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_PlaysPreview)
|
if (_PlaysPreview)
|
||||||
_PreviewPlayer.TogglePause();
|
_PreviewPlayer.Play();
|
||||||
else
|
else
|
||||||
if (_SongPlayer.SongLoaded)
|
if (_SongPlayer.SongLoaded)
|
||||||
//Resume
|
//Resume
|
||||||
@@ -338,7 +343,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void StopPreview()
|
public static void StopPreview()
|
||||||
{
|
{
|
||||||
_PreviewPlayer.Close();
|
_PreviewPlayer.Stop();
|
||||||
_PlaysPreview = false;
|
_PlaysPreview = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +355,7 @@ namespace Vocaluxe.Base
|
|||||||
Debug.Assert(_CurrentPlaylistElement != null);
|
Debug.Assert(_CurrentPlaylistElement != null);
|
||||||
|
|
||||||
//If current song same as loaded restart only
|
//If current song same as loaded restart only
|
||||||
if (_CurrentPlaylistElement.SongID == _SongPlayer.SongID)
|
if (_CurrentPlaylistElement.SongID == _SongPlayer.SongID && _SongPlayer.SongLoaded)
|
||||||
_SongPlayer.Play();
|
_SongPlayer.Play();
|
||||||
|
|
||||||
//otherwhise load
|
//otherwhise load
|
||||||
|
|||||||
@@ -168,6 +168,17 @@ namespace Vocaluxe.Screens
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnShow()
|
||||||
|
{
|
||||||
|
base.OnShow();
|
||||||
|
_Buttons[_ButtonNext].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
_Buttons[_ButtonPause].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
_Buttons[_ButtonPlay].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
_Buttons[_ButtonPrevious].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
_Buttons[_ButtonRepeat].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
_Buttons[_ButtonSing].Visible = !CBackgroundMusic.IsPlayingPreview;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool UpdateGame()
|
public override bool UpdateGame()
|
||||||
{
|
{
|
||||||
_Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
|
_Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
|
|
||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
{
|
{
|
||||||
_ResetPreview();
|
_ResetPreview(false);
|
||||||
_Initialized = true;
|
_Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
if (categoryNr >= CBase.Songs.GetNumCategories())
|
if (categoryNr >= CBase.Songs.GetNumCategories())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_ResetPreview();
|
_ResetPreview(false);
|
||||||
CBase.Songs.SetCategory(categoryNr);
|
CBase.Songs.SetCategory(categoryNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,9 +511,12 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
CBase.BackgroundMusic.LoadPreview(song);
|
CBase.BackgroundMusic.LoadPreview(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _ResetPreview()
|
protected void _ResetPreview(bool playBGagain = true)
|
||||||
{
|
{
|
||||||
CBase.BackgroundMusic.Stop();
|
CBase.BackgroundMusic.StopPreview();
|
||||||
|
|
||||||
|
if (playBGagain)
|
||||||
|
CBase.BackgroundMusic.Play();
|
||||||
|
|
||||||
//Make sure we don't have a preview here otherwise a change won't be recognized
|
//Make sure we don't have a preview here otherwise a change won't be recognized
|
||||||
//(e.g. leave a category with one song and set preview to 0 --> previewOld=previewNew=0 --> No change --> Old data shown
|
//(e.g. leave a category with one song and set preview to 0 --> previewOld=previewNew=0 --> No change --> Old data shown
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
|
|
||||||
_TextBG.Draw();
|
_TextBG.Draw();
|
||||||
|
|
||||||
CTexture vidtex = CBase.BackgroundMusic.GetVideoTexture();
|
CTexture vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null;
|
||||||
|
|
||||||
if (vidtex != null)
|
if (vidtex != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,23 +67,6 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
get { return _StreamID != -1; }
|
get { return _StreamID != -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Position
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_StreamID == -1)
|
|
||||||
return -1;
|
|
||||||
return CBase.Sound.GetPosition(_StreamID);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_StreamID == -1)
|
|
||||||
return;
|
|
||||||
CBase.Sound.SetPosition(_StreamID, value);
|
|
||||||
CBase.Video.Skip(_Video, value, _Song.VideoGap);
|
|
||||||
_StartPosition = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CSongPlayer(bool loop = false) : base(loop) { }
|
public CSongPlayer(bool loop = false) : base(loop) { }
|
||||||
|
|
||||||
@@ -124,11 +107,15 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
if (song == null)
|
if (song == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Close();
|
Stop();
|
||||||
|
|
||||||
_Song = song;
|
_Song = song;
|
||||||
|
|
||||||
|
base.Load(Path.Combine(song.Folder, song.MP3FileName), position, false);
|
||||||
_LoadVideo();
|
_LoadVideo();
|
||||||
base.Load(Path.Combine(song.Folder, song.MP3FileName), position, autoplay);
|
|
||||||
|
if (autoplay)
|
||||||
|
Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFile(string file, float position = 0f, bool autoplay = false)
|
public void LoadFile(string file, float position = 0f, bool autoplay = false)
|
||||||
@@ -136,36 +123,24 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
if (String.IsNullOrEmpty(file))
|
if (String.IsNullOrEmpty(file))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Close();
|
Stop();
|
||||||
|
|
||||||
_Song = null;
|
|
||||||
base.Load(file, position, autoplay);
|
base.Load(file, position, autoplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Close()
|
|
||||||
{
|
|
||||||
base.Close();
|
|
||||||
|
|
||||||
if (_Video != -1)
|
|
||||||
{
|
|
||||||
CBase.Video.Close(_Video);
|
|
||||||
CBase.Drawing.RemoveTexture(ref _CurrentVideoTexture);
|
|
||||||
_Video = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public new void Play()
|
public new void Play()
|
||||||
{
|
{
|
||||||
base.Play();
|
CBase.Sound.SetPosition(_StreamID, _StartPosition);
|
||||||
|
CBase.Video.Skip(_Video, _StartPosition, _Song.VideoGap);
|
||||||
if (_VideoEnabled && _Video != -1)
|
TogglePause();
|
||||||
CBase.Video.Resume(_Video);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Stop()
|
public new void Stop()
|
||||||
{
|
{
|
||||||
base.Stop();
|
base.Stop();
|
||||||
|
|
||||||
|
_Song = null;
|
||||||
|
|
||||||
if (_Video != -1)
|
if (_Video != -1)
|
||||||
{
|
{
|
||||||
CBase.Video.Close(_Video);
|
CBase.Video.Close(_Video);
|
||||||
@@ -176,8 +151,7 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
|
|
||||||
public new void TogglePause()
|
public new void TogglePause()
|
||||||
{
|
{
|
||||||
base.TogglePause();
|
if (IsPlaying && _Video != -1)
|
||||||
if (!IsPlaying && _Video != -1)
|
|
||||||
{
|
{
|
||||||
CBase.Video.Pause(_Video);
|
CBase.Video.Pause(_Video);
|
||||||
CBase.Video.Skip(_Video, CBase.Sound.GetPosition(_StreamID) + _FadeTime, _Song.VideoGap);
|
CBase.Video.Skip(_Video, CBase.Sound.GetPosition(_StreamID) + _FadeTime, _Song.VideoGap);
|
||||||
@@ -186,6 +160,7 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
{
|
{
|
||||||
CBase.Video.Resume(_Video);
|
CBase.Video.Resume(_Video);
|
||||||
}
|
}
|
||||||
|
base.TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _LoadVideo()
|
private void _LoadVideo()
|
||||||
@@ -197,8 +172,14 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
if (_Video != -1 || String.IsNullOrEmpty(videoFilePath))
|
if (_Video != -1 || String.IsNullOrEmpty(videoFilePath))
|
||||||
return;
|
return;
|
||||||
_Video = CBase.Video.Load(videoFilePath);
|
_Video = CBase.Video.Load(videoFilePath);
|
||||||
CBase.Video.Skip(_Video, 0f, _Song.VideoGap + _StartPosition); //Use gap, otherwhise we will overwrite position in GetVideoTexture
|
CBase.Video.Skip(_Video, 0f, _Song.VideoGap); //Use gap, otherwhise we will overwrite position in GetVideoTexture
|
||||||
_VideoFading = new CFading(0f, 1f, 3f);
|
_VideoFading = new CFading(0f, 1f, 3f);
|
||||||
|
|
||||||
|
if (IsPlaying)
|
||||||
|
{
|
||||||
|
CBase.Video.Skip(_Video, Position, _Song.VideoGap);
|
||||||
|
CBase.Video.Resume(_Video);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,6 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
set {
|
set {
|
||||||
if(_StreamID == -1)
|
if(_StreamID == -1)
|
||||||
return;
|
return;
|
||||||
CBase.Sound.SetPosition(_StreamID, value);
|
|
||||||
_StartPosition = value;
|
_StartPosition = value;
|
||||||
}
|
}
|
||||||
get {
|
get {
|
||||||
@@ -73,8 +72,6 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
if (IsPlaying)
|
if (IsPlaying)
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
Close();
|
|
||||||
|
|
||||||
_StreamID = CBase.Sound.Load(file, false, true);
|
_StreamID = CBase.Sound.Load(file, false, true);
|
||||||
if (position > 0f)
|
if (position > 0f)
|
||||||
Position = position;
|
Position = position;
|
||||||
@@ -115,7 +112,9 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
if (_StreamID == -1 || !IsPlaying)
|
if (_StreamID == -1 || !IsPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CBase.Sound.Fade(_StreamID, 0f, _FadeTime, EStreamAction.Stop);
|
CBase.Sound.Fade(_StreamID, 0f, _FadeTime, EStreamAction.Close);
|
||||||
|
_StreamID = -1;
|
||||||
|
|
||||||
IsPlaying = false;
|
IsPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,16 +138,6 @@ namespace VocaluxeLib.Utils.Player
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
if (_StreamID == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CBase.Sound.Close(_StreamID);
|
|
||||||
_StreamID = -1;
|
|
||||||
IsPlaying = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _ApplyVolume()
|
private void _ApplyVolume()
|
||||||
{
|
{
|
||||||
if (_StreamID == -1)
|
if (_StreamID == -1)
|
||||||
|
|||||||
Reference in new issue
Block a user