Merge branch 'sound-player' into develop
This commit is contained in:
commit
cd7bb322f9
25 files changed
+708
-300
No files matched your search
+171
-174
@@ -22,6 +22,7 @@ using System.IO;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Utils.Player;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
@@ -29,89 +30,87 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
private static bool _Initialized;
|
||||
|
||||
private static CSongPlayer _SongPlayer;
|
||||
private static CSongPlayer _PreviewPlayer;
|
||||
|
||||
private static bool _OwnSongsAvailable;
|
||||
private static EBackgroundMusicSource _MusicSource;
|
||||
private static bool _VideoEnabled;
|
||||
|
||||
private static CPlaylistElement _CurrentPlaylistElement; //Currently played music
|
||||
private static int _CurrentMusicStream = -1; //Current active music stream
|
||||
private static int _PreviousMusicIndex; //Index of _CurrentPlaylistElement in _PreviousFiles (kept for performance)
|
||||
private static int _PreviousMusicIndex = -1;
|
||||
|
||||
private static readonly List<CPlaylistElement> _BGMusicFiles = new List<CPlaylistElement>(); //Background music files
|
||||
private static readonly List<CPlaylistElement> _NotPlayedFiles = new List<CPlaylistElement>(); //Not played files
|
||||
private static readonly List<CPlaylistElement> _PreviousFiles = new List<CPlaylistElement>(); //Played files
|
||||
|
||||
private static int _Video = -1;
|
||||
private static CTexture _CurrentVideoTexture;
|
||||
private static CFading _VideoFading;
|
||||
|
||||
private static bool _OwnMusicAdded;
|
||||
private static bool _BackgroundMusicAdded;
|
||||
private static bool _Disabled;
|
||||
private static bool _PlaysPreview;
|
||||
|
||||
public static bool VideoEnabled
|
||||
{
|
||||
get { return _VideoEnabled; }
|
||||
set
|
||||
{
|
||||
if (_VideoEnabled == value)
|
||||
return;
|
||||
_VideoEnabled = value;
|
||||
if (_VideoEnabled)
|
||||
_LoadVideo();
|
||||
else if (_Video != -1)
|
||||
{
|
||||
CVideo.Close(_Video);
|
||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
||||
_Video = -1;
|
||||
}
|
||||
get { return _PlaysPreview ? _PreviewPlayer.VideoEnabled : _SongPlayer.VideoEnabled; }
|
||||
set {
|
||||
if(_PlaysPreview)
|
||||
_PreviewPlayer.VideoEnabled = value;
|
||||
else
|
||||
_SongPlayer.VideoEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CanSing { get; private set; }
|
||||
public static bool CanSing { get { return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? false : _SongPlayer.CanSing; } }
|
||||
|
||||
public static bool Disabled
|
||||
{
|
||||
get { return _Disabled; }
|
||||
set
|
||||
{
|
||||
if (Disabled == value)
|
||||
return;
|
||||
_Disabled = value;
|
||||
if (_Disabled)
|
||||
Pause();
|
||||
else
|
||||
Play();
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RepeatSong { get; set; }
|
||||
public static bool RepeatSong {
|
||||
get { return _SongPlayer.RepeatSong; }
|
||||
set { _SongPlayer.RepeatSong = value; }
|
||||
}
|
||||
|
||||
public static int SongID
|
||||
{
|
||||
get { return _CurrentPlaylistElement == null ? -1 : _CurrentPlaylistElement.SongID; }
|
||||
get { return _SongPlayer.SongID; }
|
||||
}
|
||||
|
||||
public static bool SongHasVideo
|
||||
{
|
||||
get { return _CurrentPlaylistElement != null && File.Exists(_CurrentPlaylistElement.VideoFilePath); }
|
||||
get { return _SongPlayer.SongHasVideo; }
|
||||
}
|
||||
|
||||
public static bool IsPlaying { get; private set; }
|
||||
public static bool IsPlaying { get { return _PlaysPreview ? _PreviewPlayer.IsPlaying : _SongPlayer.IsPlaying; } }
|
||||
|
||||
public static bool IsPlayingPreview { get { return _PlaysPreview; } }
|
||||
|
||||
public static string ArtistAndTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CurrentPlaylistElement == null)
|
||||
return "";
|
||||
if (_CurrentPlaylistElement.Artist != "" && _CurrentPlaylistElement.Title != "")
|
||||
return _CurrentPlaylistElement.Artist + " - " + _CurrentPlaylistElement.Title;
|
||||
return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath);
|
||||
get {
|
||||
if (_PlaysPreview)
|
||||
return _PreviewPlayer.ArtistAndTitle;
|
||||
else
|
||||
return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath) : _SongPlayer.ArtistAndTitle;
|
||||
}
|
||||
}
|
||||
|
||||
public static float Length
|
||||
{
|
||||
get { return _PlaysPreview ? _PreviewPlayer.Length : _SongPlayer.Length; }
|
||||
}
|
||||
|
||||
public static CTexture Cover
|
||||
{
|
||||
get { return _CurrentPlaylistElement == null ? CCover.NoCover : _CurrentPlaylistElement.Cover; }
|
||||
get { return _PlaysPreview ? _PreviewPlayer.Cover : _SongPlayer.Cover; }
|
||||
}
|
||||
|
||||
//Use this to set whether own songs are available for access
|
||||
@@ -143,8 +142,13 @@ namespace Vocaluxe.Base
|
||||
_MusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC;
|
||||
_AddBackgroundMusic();
|
||||
|
||||
_PreviousMusicIndex = -1;
|
||||
IsPlaying = false;
|
||||
_SongPlayer = new CSongPlayer();
|
||||
_SongPlayer.Volume = CConfig.BackgroundMusicVolume;
|
||||
|
||||
_PreviewPlayer = new CSongPlayer();
|
||||
_PreviewPlayer.Volume = CConfig.PreviewMusicVolume;
|
||||
_PreviewPlayer.RepeatSong = true;
|
||||
|
||||
_VideoEnabled = (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON);
|
||||
SetMusicSource(CConfig.BackgroundMusicSource);
|
||||
_Initialized = true;
|
||||
@@ -152,42 +156,29 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
if (_CurrentMusicStream >= 0)
|
||||
{
|
||||
CSound.Close(_CurrentMusicStream);
|
||||
_CurrentMusicStream = -1;
|
||||
}
|
||||
if (_Video != -1)
|
||||
{
|
||||
CVideo.Close(_Video);
|
||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
||||
_Video = -1;
|
||||
}
|
||||
_SongPlayer.Stop();
|
||||
_PreviewPlayer.Stop();
|
||||
|
||||
_BGMusicFiles.Clear();
|
||||
_NotPlayedFiles.Clear();
|
||||
_PreviousFiles.Clear();
|
||||
|
||||
IsPlaying = false;
|
||||
_Initialized = false;
|
||||
}
|
||||
|
||||
public static void Play()
|
||||
{
|
||||
if (IsPlaying || CConfig.BackgroundMusic == EOffOn.TR_CONFIG_OFF)
|
||||
if (IsPlaying || (CConfig.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_ON && !_PlaysPreview))
|
||||
return;
|
||||
|
||||
if (_CurrentMusicStream != -1)
|
||||
{
|
||||
//Resume
|
||||
CSound.SetStreamVolume(_CurrentMusicStream, 0f);
|
||||
CSound.Fade(_CurrentMusicStream, 100f, CSettings.BackgroundMusicFadeTime);
|
||||
CSound.Play(_CurrentMusicStream);
|
||||
if (_VideoEnabled && _Video != -1)
|
||||
CVideo.Resume(_Video);
|
||||
IsPlaying = true;
|
||||
}
|
||||
if (_PlaysPreview)
|
||||
_PreviewPlayer.Play();
|
||||
else
|
||||
Next();
|
||||
if (_SongPlayer.SongLoaded)
|
||||
//Resume
|
||||
_SongPlayer.TogglePause();
|
||||
else
|
||||
Next();
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
@@ -195,121 +186,101 @@ namespace Vocaluxe.Base
|
||||
if (!IsPlaying)
|
||||
return;
|
||||
|
||||
if (_Video != -1)
|
||||
if (_PlaysPreview)
|
||||
{
|
||||
CVideo.Close(_Video);
|
||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
||||
_Video = -1;
|
||||
_PreviewPlayer.Stop();
|
||||
_PlaysPreview = false;
|
||||
Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
_SongPlayer.Stop();
|
||||
_CurrentPlaylistElement = null;
|
||||
}
|
||||
CSound.FadeAndClose(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
|
||||
_CurrentMusicStream = -1;
|
||||
|
||||
_CurrentPlaylistElement = null;
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public static void Pause()
|
||||
{
|
||||
if (!IsPlaying)
|
||||
return;
|
||||
|
||||
if (_Video != -1)
|
||||
if (_PlaysPreview)
|
||||
{
|
||||
CVideo.Pause(_Video);
|
||||
CVideo.Skip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap);
|
||||
if (!_PreviewPlayer.SongLoaded)
|
||||
return;
|
||||
_PreviewPlayer.TogglePause();
|
||||
}
|
||||
CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
|
||||
IsPlaying = false;
|
||||
else
|
||||
if (!_SongPlayer.SongLoaded)
|
||||
Next();
|
||||
else
|
||||
_SongPlayer.TogglePause();
|
||||
}
|
||||
|
||||
public static void Next()
|
||||
{
|
||||
Stop(); //stop last song if any
|
||||
if (_PreviousMusicIndex < _PreviousFiles.Count - 2)
|
||||
if (!_PlaysPreview)
|
||||
{
|
||||
//We are in the previous list and next element exists
|
||||
_PreviousMusicIndex++;
|
||||
_CurrentPlaylistElement = _PreviousFiles[_PreviousMusicIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
//We are not in the previous list (anymore)
|
||||
if (_NotPlayedFiles.Count == 0)
|
||||
Stop(); //stop last song if any
|
||||
if (_PreviousMusicIndex < _PreviousFiles.Count - 2)
|
||||
{
|
||||
if (_PreviousFiles.Count == 0)
|
||||
return; //No songs to play
|
||||
_NotPlayedFiles.AddRange(_PreviousFiles);
|
||||
//We are in the previous list and next element exists
|
||||
_PreviousMusicIndex++;
|
||||
_CurrentPlaylistElement = _PreviousFiles[_PreviousMusicIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
//We are not in the previous list (anymore)
|
||||
if (_NotPlayedFiles.Count == 0)
|
||||
{
|
||||
if (_PreviousFiles.Count == 0)
|
||||
return; //No songs to play
|
||||
_NotPlayedFiles.AddRange(_PreviousFiles);
|
||||
}
|
||||
|
||||
_CurrentPlaylistElement = _NotPlayedFiles[CGame.Rand.Next(_NotPlayedFiles.Count)];
|
||||
_NotPlayedFiles.Remove(_CurrentPlaylistElement);
|
||||
_CurrentPlaylistElement = _NotPlayedFiles[CGame.Rand.Next(_NotPlayedFiles.Count)];
|
||||
_NotPlayedFiles.Remove(_CurrentPlaylistElement);
|
||||
|
||||
_PreviousFiles.Add(_CurrentPlaylistElement);
|
||||
_PreviousMusicIndex = _PreviousFiles.Count - 1;
|
||||
_PreviousFiles.Add(_CurrentPlaylistElement);
|
||||
_PreviousMusicIndex = _PreviousFiles.Count - 1;
|
||||
}
|
||||
_StartSong();
|
||||
}
|
||||
_StartSong();
|
||||
CanSing = !_IsBackgroundFile(_CurrentPlaylistElement);
|
||||
}
|
||||
|
||||
public static void Previous()
|
||||
{
|
||||
if (_PreviousMusicIndex < 0)
|
||||
return;
|
||||
Debug.Assert(_CurrentMusicStream != -1 && _CurrentPlaylistElement != null);
|
||||
if (CSound.GetPosition(_CurrentMusicStream) <= 1.5f && _PreviousMusicIndex > 0)
|
||||
if (!_PlaysPreview)
|
||||
{
|
||||
Stop(); //stop last song
|
||||
_PreviousMusicIndex--;
|
||||
if (_PreviousMusicIndex < 0)
|
||||
return;
|
||||
Debug.Assert(_CurrentPlaylistElement != null);
|
||||
if (_SongPlayer.Position <= 1.5f && _PreviousMusicIndex > 0)
|
||||
{
|
||||
Stop(); //stop last song
|
||||
_PreviousMusicIndex--;
|
||||
|
||||
_CurrentPlaylistElement = _PreviousFiles[_PreviousMusicIndex];
|
||||
CanSing = !_IsBackgroundFile(_CurrentPlaylistElement);
|
||||
_CurrentPlaylistElement = _PreviousFiles[_PreviousMusicIndex];
|
||||
}
|
||||
_StartSong();
|
||||
}
|
||||
_StartSong();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!IsPlaying)
|
||||
if (!IsPlaying && (!_SongPlayer.SongLoaded || !_PreviewPlayer.SongLoaded) )
|
||||
return;
|
||||
Debug.Assert(_CurrentMusicStream != -1 && _CurrentPlaylistElement != null);
|
||||
|
||||
float timeToPlay;
|
||||
if (Math.Abs(_CurrentPlaylistElement.Finish) < 0.001)
|
||||
if (_PlaysPreview)
|
||||
_PreviewPlayer.Update();
|
||||
else
|
||||
{
|
||||
//No End-Tag defined
|
||||
float len = CSound.GetLength(_CurrentMusicStream);
|
||||
timeToPlay = (len > 0f) ? len - CSound.GetPosition(_CurrentMusicStream) : CSettings.BackgroundMusicFadeTime + 1f;
|
||||
}
|
||||
else //End-Tag found
|
||||
timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
|
||||
|
||||
bool finished = CSound.IsFinished(_CurrentMusicStream);
|
||||
if (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)
|
||||
{
|
||||
if (RepeatSong)
|
||||
_StartSong();
|
||||
else
|
||||
_SongPlayer.Update();
|
||||
if (_SongPlayer.IsFinished)
|
||||
Next();
|
||||
}
|
||||
}
|
||||
|
||||
public static CTexture GetVideoTexture()
|
||||
{
|
||||
if (_Video == -1)
|
||||
return null;
|
||||
float vtime;
|
||||
if (CVideo.GetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime))
|
||||
{
|
||||
if (_VideoFading != null)
|
||||
{
|
||||
bool finished;
|
||||
_CurrentVideoTexture.Color.A = _VideoFading.GetValue(out finished);
|
||||
if (finished)
|
||||
_VideoFading = null;
|
||||
}
|
||||
return _CurrentVideoTexture;
|
||||
}
|
||||
return null;
|
||||
return _PlaysPreview ? _PreviewPlayer.GetVideoTexture() : _SongPlayer.GetVideoTexture();
|
||||
}
|
||||
|
||||
public static void SetMusicSource(EBackgroundMusicSource source)
|
||||
@@ -335,37 +306,74 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadPreview(CSong song, float start = 0f)
|
||||
{
|
||||
if (!_PlaysPreview)
|
||||
Pause();
|
||||
else
|
||||
StopPreview();
|
||||
|
||||
if (song == null)
|
||||
return;
|
||||
|
||||
if (start == 0f)
|
||||
start = song.Preview.StartTime;
|
||||
|
||||
_PlaysPreview = true;
|
||||
_PreviewPlayer.Load(song, start);
|
||||
|
||||
float startposition = song.Preview.StartTime;
|
||||
|
||||
float length = _PreviewPlayer.Length;
|
||||
|
||||
if (song.Preview.Source == EDataSource.None)
|
||||
startposition = length / 4f;
|
||||
else if (startposition > length - 5f)
|
||||
startposition = Math.Max(0f, Math.Min(length / 4f, length - 5f));
|
||||
|
||||
if (startposition >= 0.5f)
|
||||
startposition -= 0.5f;
|
||||
|
||||
_PreviewPlayer.Position = startposition;
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
public static void PlayPreview(float start = -1f)
|
||||
{
|
||||
if (start > -1f)
|
||||
_PreviewPlayer.Position = start;
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
public static void StopPreview()
|
||||
{
|
||||
_PreviewPlayer.Stop();
|
||||
_PlaysPreview = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re-)Starts the _CurrentPlaylistElement
|
||||
/// </summary>
|
||||
private static void _StartSong()
|
||||
{
|
||||
Debug.Assert(_CurrentPlaylistElement != null);
|
||||
//If we have an active stream, reuse it
|
||||
if (_CurrentMusicStream < 0)
|
||||
{
|
||||
//otherwhise load
|
||||
_CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath);
|
||||
if (_CurrentMusicStream < 0)
|
||||
return;
|
||||
CSound.SetStreamVolume(_CurrentMusicStream, 0f);
|
||||
CSound.Fade(_CurrentMusicStream, 100f, CSettings.BackgroundMusicFadeTime);
|
||||
}
|
||||
//Seek to #Start-Tag, if found
|
||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
|
||||
if (_VideoEnabled)
|
||||
//If current song same as loaded restart only
|
||||
if (_CurrentPlaylistElement.SongID == _SongPlayer.SongID && _SongPlayer.SongLoaded)
|
||||
_SongPlayer.Play();
|
||||
|
||||
//otherwhise load
|
||||
if (_BGMusicFiles.Contains(_CurrentPlaylistElement))
|
||||
_SongPlayer.LoadFile(_CurrentPlaylistElement.MusicFilePath, 0f, true);
|
||||
else
|
||||
{
|
||||
if (_Video != -1)
|
||||
{
|
||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap + _CurrentPlaylistElement.Start);
|
||||
else
|
||||
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
}
|
||||
else
|
||||
_LoadVideo();
|
||||
//Seek to #Start-Tag, if found
|
||||
float start = 0f;
|
||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
start = _CurrentPlaylistElement.Start;
|
||||
_SongPlayer.Load(CBase.Songs.GetSongByID(_CurrentPlaylistElement.SongID), start, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,16 +427,5 @@ namespace Vocaluxe.Base
|
||||
return _BGMusicFiles.Contains(element);
|
||||
}
|
||||
|
||||
private static void _LoadVideo()
|
||||
{
|
||||
if (_Video != -1 || String.IsNullOrEmpty(_CurrentPlaylistElement.VideoFilePath))
|
||||
return;
|
||||
_Video = CVideo.Load(_CurrentPlaylistElement.VideoFilePath);
|
||||
if (CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap + _CurrentPlaylistElement.Start); //Use gap, otherwhise we will overwrite position in GetVideoTexture
|
||||
else
|
||||
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
_VideoFading = new CFading(0f, 1f, 3f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace Vocaluxe.Base
|
||||
public static EBufferSize AudioBufferSize = EBufferSize.B2048;
|
||||
public static int AudioLatency;
|
||||
private static int _BackgroundMusicVolume = 30;
|
||||
public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON;
|
||||
public static EBackgroundMusicOffOn BackgroundMusic = EBackgroundMusicOffOn.TR_CONFIG_ON;
|
||||
public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC;
|
||||
public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON;
|
||||
private static int _PreviewMusicVolume = 50;
|
||||
@@ -478,8 +478,8 @@ namespace Vocaluxe.Base
|
||||
writer.WriteComment("AudioLatency from -500 to 500 ms");
|
||||
writer.WriteElementString("AudioLatency", AudioLatency.ToString());
|
||||
|
||||
writer.WriteComment("Background Music: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))));
|
||||
writer.WriteElementString("BackgroundMusic", Enum.GetName(typeof(EOffOn), BackgroundMusic));
|
||||
writer.WriteComment("Background Music: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundMusicOffOn))));
|
||||
writer.WriteElementString("BackgroundMusic", Enum.GetName(typeof(EBackgroundMusicOffOn), BackgroundMusic));
|
||||
|
||||
writer.WriteComment("Background Music Volume from 0 to 100");
|
||||
writer.WriteElementString("BackgroundMusicVolume", BackgroundMusicVolume.ToString());
|
||||
|
||||
@@ -60,6 +60,11 @@ namespace Vocaluxe.Base
|
||||
get { return _CurrentScreen; }
|
||||
}
|
||||
|
||||
public static EScreens NextScreen
|
||||
{
|
||||
get { return _NextScreen; }
|
||||
}
|
||||
|
||||
#region public methods
|
||||
public static void Init()
|
||||
{
|
||||
@@ -335,7 +340,7 @@ namespace Vocaluxe.Base
|
||||
bool popupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord;
|
||||
//Hide volume control for bg-music if bg-music is disabled
|
||||
if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || CSongs.Category == -1)
|
||||
&& _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_OFF)
|
||||
&& _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF)
|
||||
popupVolumeControlAllowed = false;
|
||||
|
||||
|
||||
@@ -391,13 +396,13 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
|
||||
ShowPopup(EPopupScreens.PopupPlayerControl);
|
||||
else
|
||||
HidePopup(EPopupScreens.PopupPlayerControl);
|
||||
}
|
||||
|
||||
if (popupPlayerControlAllowed && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
if (popupPlayerControlAllowed && CConfig.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_OFF)
|
||||
{
|
||||
if (keyEvent.Key == Keys.MediaNextTrack)
|
||||
CBackgroundMusic.Next();
|
||||
@@ -497,7 +502,7 @@ namespace Vocaluxe.Base
|
||||
bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, mouseEvent);
|
||||
if (popupPlayerControlAllowed && isOverPopupPlayerControl)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
|
||||
ShowPopup(EPopupScreens.PopupPlayerControl);
|
||||
}
|
||||
|
||||
|
||||
+62
-7
@@ -76,6 +76,11 @@ namespace Vocaluxe.Base
|
||||
return CConfig.BackgroundMusicVolume;
|
||||
}
|
||||
|
||||
public EBackgroundMusicOffOn GetBackgroundMusicStatus()
|
||||
{
|
||||
return CConfig.BackgroundMusic;
|
||||
}
|
||||
|
||||
public int GetPreviewMusicVolume()
|
||||
{
|
||||
return CConfig.PreviewMusicVolume;
|
||||
@@ -243,6 +248,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
return CSettings.SlideShowFadeTime;
|
||||
}
|
||||
|
||||
public float GetSoundPlayerFadeTime()
|
||||
{
|
||||
return CSettings.SoundPlayerFadeTime;
|
||||
}
|
||||
}
|
||||
|
||||
class CBtheme : ITheme
|
||||
@@ -335,11 +345,21 @@ namespace Vocaluxe.Base
|
||||
return CBackgroundMusic.VideoEnabled;
|
||||
}
|
||||
|
||||
public bool IsPlayingPreview()
|
||||
{
|
||||
return CBackgroundMusic.IsPlayingPreview;
|
||||
}
|
||||
|
||||
public void SetDisabled(bool disabled)
|
||||
{
|
||||
CBackgroundMusic.Disabled = disabled;
|
||||
}
|
||||
|
||||
public float GetLength()
|
||||
{
|
||||
return CBackgroundMusic.Length;
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
CBackgroundMusic.Next();
|
||||
@@ -360,6 +380,26 @@ namespace Vocaluxe.Base
|
||||
CBackgroundMusic.Play();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
CBackgroundMusic.Stop();
|
||||
}
|
||||
|
||||
public void LoadPreview(CSong song, float start = 0f)
|
||||
{
|
||||
CBackgroundMusic.LoadPreview(song, start);
|
||||
}
|
||||
|
||||
public void PlayPreview(float start = -1f)
|
||||
{
|
||||
CBackgroundMusic.PlayPreview(start);
|
||||
}
|
||||
|
||||
public void StopPreview()
|
||||
{
|
||||
CBackgroundMusic.StopPreview();
|
||||
}
|
||||
|
||||
public CTexture GetVideoTexture()
|
||||
{
|
||||
return CBackgroundMusic.GetVideoTexture();
|
||||
@@ -430,6 +470,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
return CGraphics.GlobalAlpha;
|
||||
}
|
||||
|
||||
public EScreens GetNextScreen()
|
||||
{
|
||||
return CGraphics.NextScreen;
|
||||
}
|
||||
}
|
||||
|
||||
class CBlog : ILog
|
||||
@@ -784,6 +829,16 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
CVideo.SetLoop(streamID, loop);
|
||||
}
|
||||
|
||||
public void Pause(int streamID)
|
||||
{
|
||||
CVideo.Pause(streamID);
|
||||
}
|
||||
|
||||
public void Resume(int streamID)
|
||||
{
|
||||
CVideo.Resume(streamID);
|
||||
}
|
||||
}
|
||||
|
||||
class CBsound : ISound
|
||||
@@ -803,9 +858,14 @@ namespace Vocaluxe.Base
|
||||
CSound.Play(soundStream);
|
||||
}
|
||||
|
||||
public void Fade(int soundStream, float targetVolume, float duration)
|
||||
public void Fade(int soundStream, float targetVolume, float duration, EStreamAction afterFadeAction = EStreamAction.Nothing)
|
||||
{
|
||||
CSound.Fade(soundStream, targetVolume, duration);
|
||||
CSound.Fade(soundStream, targetVolume, duration, afterFadeAction);
|
||||
}
|
||||
|
||||
public void Close(int soundStream)
|
||||
{
|
||||
CSound.Close(soundStream);
|
||||
}
|
||||
|
||||
public bool IsFinished(int soundStream)
|
||||
@@ -823,11 +883,6 @@ namespace Vocaluxe.Base
|
||||
return CSound.GetLength(soundStream);
|
||||
}
|
||||
|
||||
public void FadeAndClose(int soundStream, float targetVolume, float duration)
|
||||
{
|
||||
CSound.FadeAndClose(soundStream, targetVolume, duration);
|
||||
}
|
||||
|
||||
public void SetStreamVolume(int soundStream, float volume)
|
||||
{
|
||||
CSound.SetStreamVolume(soundStream, volume);
|
||||
|
||||
@@ -151,6 +151,8 @@ namespace Vocaluxe.Base
|
||||
public const float BackgroundMusicFadeTime = 0.5f;
|
||||
public const float PauseResetTime = 1f;
|
||||
|
||||
public const float SoundPlayerFadeTime = 0.5f;
|
||||
|
||||
public const float SlideShowImageTime = 3500f;
|
||||
public const float SlideShowFadeTime = 500f;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using VocaluxeLib;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback
|
||||
{
|
||||
|
||||
@@ -15,15 +15,10 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using VocaluxeLib;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback
|
||||
{
|
||||
public enum EStreamAction
|
||||
{
|
||||
Nothing,
|
||||
Pause,
|
||||
Stop,
|
||||
Close
|
||||
}
|
||||
|
||||
interface IPlayback
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Vocaluxe.Screens
|
||||
if (_Buttons[_ButtonPrevious].Selected)
|
||||
CBackgroundMusic.Previous();
|
||||
if (_Buttons[_ButtonPlay].Selected)
|
||||
CBackgroundMusic.Play();
|
||||
CBackgroundMusic.Pause();
|
||||
if (_Buttons[_ButtonPause].Selected)
|
||||
CBackgroundMusic.Pause();
|
||||
if (_Buttons[_ButtonRepeat].Selected)
|
||||
@@ -143,7 +143,7 @@ namespace Vocaluxe.Screens
|
||||
if (_Buttons[_ButtonPrevious].Selected)
|
||||
CBackgroundMusic.Previous();
|
||||
if (_Buttons[_ButtonPlay].Selected)
|
||||
CBackgroundMusic.Play();
|
||||
CBackgroundMusic.Pause();
|
||||
if (_Buttons[_ButtonPause].Selected)
|
||||
CBackgroundMusic.Pause();
|
||||
if (_Buttons[_ButtonRepeat].Selected)
|
||||
@@ -168,6 +168,17 @@ namespace Vocaluxe.Screens
|
||||
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()
|
||||
{
|
||||
_Statics[_StaticCover].Visible = !_VideoPreviewInt || !CBackgroundMusic.SongHasVideo;
|
||||
|
||||
@@ -152,6 +152,9 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
CBackgroundMusic.OwnSongsAvailable = true;
|
||||
|
||||
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON || CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON)
|
||||
CBackgroundMusic.VideoEnabled = true;
|
||||
|
||||
CBackgroundMusic.Play();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Vocaluxe.Screens
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
_SelectSlides[_SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic);
|
||||
_SelectSlides[_SelectSlideBackgroundMusic].SetValues<EBackgroundMusicOffOn>((int)CConfig.BackgroundMusic);
|
||||
_SelectSlides[_SelectSlideBackgroundMusicVolume].AddValues(new string[]
|
||||
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
|
||||
_SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
|
||||
@@ -150,14 +150,14 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
CConfig.GameMusicVolume = _SelectSlides[_SelectSlideGameMusicVolume].Selection * 5;
|
||||
CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5;
|
||||
CConfig.BackgroundMusic = (EOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
|
||||
CConfig.BackgroundMusic = (EBackgroundMusicOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
|
||||
CConfig.BackgroundMusicSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
|
||||
CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
|
||||
CConfig.SaveConfig();
|
||||
|
||||
CBackgroundMusic.SetMusicSource(CConfig.BackgroundMusicSource);
|
||||
CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume);
|
||||
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||
if (CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
|
||||
CBackgroundMusic.Play();
|
||||
else
|
||||
CBackgroundMusic.Pause();
|
||||
|
||||
@@ -123,6 +123,8 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
CBackgroundMusic.Disabled = false;
|
||||
|
||||
base.OnShow();
|
||||
//-1 --> Show average
|
||||
_Round = CGame.NumRounds > 1 ? -1 : 0;
|
||||
|
||||
@@ -537,8 +537,6 @@ namespace Vocaluxe.Screens
|
||||
_CloseSong();
|
||||
if (_Webcam)
|
||||
CWebcam.Stop();
|
||||
CBackgroundMusic.Disabled = false;
|
||||
CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume);
|
||||
}
|
||||
|
||||
private void _CloseSong()
|
||||
|
||||
@@ -662,11 +662,6 @@ namespace Vocaluxe.Screens
|
||||
|
||||
_Texts[_TextCategory].Text = CSongs.GetCurrentCategoryName();
|
||||
|
||||
if (CSongs.IsInCategory || CConfig.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
CBackgroundMusic.Disabled = true;
|
||||
else
|
||||
CBackgroundMusic.Disabled = false;
|
||||
|
||||
string selectionText = "";
|
||||
if (CSongs.IsInCategory)
|
||||
{
|
||||
@@ -716,9 +711,14 @@ namespace Vocaluxe.Screens
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
CBackgroundMusic.Disabled = false;
|
||||
CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume);
|
||||
|
||||
_SongMenu.OnHide();
|
||||
|
||||
if (CGraphics.NextScreen != EScreens.ScreenNames)
|
||||
{
|
||||
CBackgroundMusic.Disabled = false;
|
||||
CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume);
|
||||
}
|
||||
}
|
||||
|
||||
private void _HandlePartySongSelection(int songNr)
|
||||
|
||||
Reference in new issue
Block a user