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

@@ -121,12 +121,6 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
protected int _PreviewSongStream { get; private set; }
protected int _PreviewVideoStream { get; private set; }
private CFading _VideoFading;
protected CTexture _Vidtex;
private SColorF _ColorInternal;
protected SColorF _Color
{
@@ -160,8 +154,6 @@ namespace VocaluxeLib.Menu.SongMenu
{
Visible = true;
_PartyModeID = partyModeID;
_PreviewVideoStream = -1;
_PreviewSongStream = -1;
_Theme = new SThemeSongMenu
{
SongMenuTileBoard =
@@ -354,7 +346,7 @@ namespace VocaluxeLib.Menu.SongMenu
{
if (!_Initialized)
return;
/*
if (_PreviewSongStream == -1 || _PreviewVideoStream == -1)
return;
@@ -380,7 +372,7 @@ namespace VocaluxeLib.Menu.SongMenu
_VideoFading = null;
}
}
}
}*/
}
public virtual void OnShow() {}
@@ -399,8 +391,8 @@ namespace VocaluxeLib.Menu.SongMenu
if (!_Initialized || !Visible)
return;
if (_PreviewVideoStream != -1)
CBase.Drawing.DrawTexture(_Vidtex, new SRectF(0, 0, 1280, 720, 0));
if (CBase.PreviewPlayer.IsPlaying())
CBase.Drawing.DrawTexture(CBase.PreviewPlayer.GetVideoTexture(), new SRectF(0, 0, 1280, 720, 0));
}
public bool IsMouseOverSelectedSong(SMouseEvent mEvent)
@@ -509,44 +501,23 @@ namespace VocaluxeLib.Menu.SongMenu
if (song == null)
return;
//TODO: Using prescan here causes Vocaluxe to hang a bit on loading the song but we need the length below
_PreviewSongStream = CBase.Sound.Load(Path.Combine(song.Folder, song.MP3FileName), true, true);
CBase.PreviewPlayer.Load(song);
float startposition = song.Preview.StartTime;
float length = CBase.Sound.GetLength(_PreviewSongStream);
float length = CBase.PreviewPlayer.GetLength();
if (song.Preview.Source == EDataSource.None)
startposition = length / 4f;
else if (startposition > length - 5f)
startposition = Math.Max(0f, Math.Min(length / 4f, length - 5f));
CBase.Sound.SetPosition(_PreviewSongStream, startposition);
CBase.Sound.Play(_PreviewSongStream);
CBase.Sound.SetStreamVolume(_PreviewSongStream, 0f);
CBase.Sound.Fade(_PreviewSongStream, 100f, 3f);
if (song.VideoFileName != "" && CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON)
{
_PreviewVideoStream = CBase.Video.Load(Path.Combine(song.Folder, song.VideoFileName));
if (_PreviewVideoStream == -1)
return;
CBase.Video.SetLoop(_PreviewVideoStream);
CBase.Video.Skip(_PreviewVideoStream, startposition, song.VideoGap);
_VideoFading = new CFading(0f, 1f, 3f);
}
CBase.PreviewPlayer.Play(startposition);
}
protected void _ResetPreview()
{
if (_PreviewSongStream >= 0)
CBase.Sound.Fade(_PreviewSongStream, 0f, 0.75f, EStreamAction.Close);
_PreviewSongStream = -1;
CBase.Video.Close(_PreviewVideoStream);
_PreviewVideoStream = -1;
CBase.Drawing.RemoveTexture(ref _Vidtex);
CBase.PreviewPlayer.Stop();
}
#region ThemeEdit
@@ -179,7 +179,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (songOptions.Selection.RandomOnly)
_PreviewNr = _SelectionNr;
if (_Length < 0 && CBase.Songs.IsInCategory() && CBase.Sound.GetLength(_PreviewSongStream) > 0)
if (_Length < 0 && CBase.Songs.IsInCategory() && CBase.PreviewPlayer.GetLength() > 0)
_UpdateLength(CBase.Songs.GetVisibleSong(_PreviewNr));
}
@@ -244,7 +244,7 @@ namespace VocaluxeLib.Menu.SongMenu
{
if (song == null)
return;
float time = CBase.Sound.GetLength(_PreviewSongStream);
float time = CBase.PreviewPlayer.GetLength();
if (Math.Abs(song.Finish) > 0.001)
time = song.Finish;
@@ -462,18 +462,20 @@ namespace VocaluxeLib.Menu.SongMenu
_TextBG.Draw();
if (_Vidtex != null && _PreviewVideoStream != -1)
CTexture vidtex = CBase.PreviewPlayer.GetVideoTexture();
if (vidtex != null)
{
if (_Vidtex.Color.A < 1)
if (vidtex.Color.A < 1)
_CoverBig.Draw(EAspect.Crop);
var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
RectangleF rect;
CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop);
CHelper.SetRect(bounds, out rect, vidtex.OrigAspect, EAspect.Crop);
var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds);
CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
CBase.Drawing.DrawTexture(vidtex, vidRect, vidtex.Color, vidRectBounds);
CBase.Drawing.DrawTextureReflection(vidtex, vidRect, vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
}
else
_CoverBig.Draw(EAspect.Crop);