Added preview-player which is used for playing preview in song-menu.

This commit is contained in:
Florian Küpper committed 2014-08-09 17:12:27 +02:00
1 parent bd41de6dbe
commit 4c01396e46
10 files changed
+163 -47

No files matched your search

+2
View File
@@ -263,6 +263,8 @@ namespace Vocaluxe.Base
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart);
xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref _PreviewMusicVolume);
xmlReader.TryGetIntValueRange("//root/Sound/GameMusicVolume", ref _GameMusicVolume);
CPreviewPlayer.UpdateVolume();
#endregion Sound
#region Game
+45 -1
View File
@@ -51,11 +51,12 @@ namespace Vocaluxe.Base
private static readonly IDataBase _DataBase = new CBdataBase();
private static readonly IControllers _Controller = new CBcontrollers();
private static readonly IPlaylist _Playlist = new CBplaylist();
private static readonly IPreviewPlayer _PreviewPlayer = new CBpreviewPlayer();
public static void Init()
{
CBase.Assign(_Config, _Settings, _Theme, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Controller, _Playlist);
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Controller, _Playlist, _PreviewPlayer);
}
}
@@ -960,4 +961,47 @@ namespace Vocaluxe.Base
return CPlaylists.GetSong(playlistID, songIndex);
}
}
class CBpreviewPlayer : IPreviewPlayer
{
public void Play(float start = -1)
{
CPreviewPlayer.Play();
}
public void Load(CSong song, float start = 0f)
{
CPreviewPlayer.Load(song, start);
}
public void Stop()
{
CPreviewPlayer.Stop();
}
public void Pause()
{
CPreviewPlayer.Pause();
}
public CTexture GetCover()
{
return CPreviewPlayer.Cover;
}
public CTexture GetVideoTexture()
{
return CPreviewPlayer.VideoTexture;
}
public bool IsPlaying()
{
return CPreviewPlayer.IsPlaying;
}
public float GetLength()
{
return CPreviewPlayer.Length;
}
}
}
+69
View File
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VocaluxeLib.Utils.Player;
using VocaluxeLib.Draw;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
public static class CPreviewPlayer
{
private static CSongPlayer _Player = new CSongPlayer(true);
public static CTexture VideoTexture
{
get { return _Player.GetVideoTexture(); }
}
public static CTexture Cover
{
get { return _Player.Cover; }
}
public static bool IsPlaying
{
get { return _Player.IsPlaying; }
}
public static float Length
{
get { return _Player.Length; }
}
public static void Load(CSong song, float start = 0f)
{
if (song == null)
return;
if (start == 0f)
start = song.Preview.StartTime;
_Player.Load(song, start);
}
public static void Play(float start = -1)
{
if (start > -1)
_Player.Position = start;
_Player.Play();
}
public static void Pause()
{
_Player.TogglePause();
}
public static void Stop()
{
_Player.Stop();
}
public static void UpdateVolume()
{
_Player.Volume = CConfig.PreviewMusicVolume;
}
}
}
+1
View File
@@ -217,6 +217,7 @@
<ItemGroup>
<Compile Include="Base\CBackgroundMusic.cs" />
<Compile Include="Base\CPlaylistElement.cs" />
<Compile Include="Base\CPreviewPlayer.cs" />
<Compile Include="Base\CRecord.cs" />
<Compile Include="COSFunctions.cs" />
<Compile Include="Lib\Database\CCoverDB.cs" />