Improved video loading
This commit is contained in:
1 parent
389aecd772
commit
ac8b7dc940
3 files changed
+14
-43
No files matched your search
@@ -55,13 +55,8 @@ namespace Vocaluxe.Base
|
|||||||
get { return _VideoEnabled; }
|
get { return _VideoEnabled; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_VideoEnabled && value)
|
if (_VideoEnabled == value)
|
||||||
return;
|
return;
|
||||||
if (!_VideoEnabled && !value)
|
|
||||||
return;
|
|
||||||
if (_VideoEnabled && !value)
|
|
||||||
ToggleVideo();
|
|
||||||
if (!_VideoEnabled && value)
|
|
||||||
ToggleVideo();
|
ToggleVideo();
|
||||||
_VideoEnabled = value;
|
_VideoEnabled = value;
|
||||||
}
|
}
|
||||||
@@ -438,22 +433,11 @@ namespace Vocaluxe.Base
|
|||||||
public static void ToggleVideo()
|
public static void ToggleVideo()
|
||||||
{
|
{
|
||||||
if (_Video != -1)
|
if (_Video != -1)
|
||||||
{
|
|
||||||
if (_VideoEnabled)
|
|
||||||
{
|
|
||||||
_VideoEnabled = false;
|
|
||||||
CVideo.Close(_Video);
|
|
||||||
_Video = -1;
|
|
||||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (CVideo.Finished(_Video))
|
|
||||||
{
|
{
|
||||||
CVideo.Close(_Video);
|
CVideo.Close(_Video);
|
||||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
||||||
_Video = -1;
|
_Video = -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
_LoadVideo();
|
_LoadVideo();
|
||||||
}
|
}
|
||||||
@@ -485,19 +469,17 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
private static void _LoadVideo()
|
private static void _LoadVideo()
|
||||||
{
|
{
|
||||||
if (_Video == -1)
|
if (_Video != -1 || String.IsNullOrEmpty(_CurrentPlaylistElement.VideoFilePath))
|
||||||
{
|
return;
|
||||||
_Video = CVideo.Load(_CurrentPlaylistElement.VideoFilePath);
|
_Video = CVideo.Load(_CurrentPlaylistElement.VideoFilePath);
|
||||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||||
CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
CVideo.Skip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
||||||
else
|
else
|
||||||
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
CVideo.Skip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||||
_VideoEnabled = true;
|
|
||||||
_FadeTimer.Reset();
|
_FadeTimer.Reset();
|
||||||
_FadeTimer.Start();
|
_FadeTimer.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class CPlaylistElement
|
class CPlaylistElement
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -203,11 +203,8 @@ namespace Vocaluxe.Base
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty);
|
xmlReader.GetValue("//root/Videos/" + _Skins[skinIndex].VideoList[i].Name, out value, String.Empty);
|
||||||
SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value};
|
//Do not load video yet
|
||||||
sk.VideoIndex = CVideo.Load(Path.Combine(_Skins[skinIndex].Path, sk.Value));
|
SSkinElement sk = new SSkinElement {Name = _Skins[skinIndex].VideoList[i].Name, Value = value, VideoIndex = -1, Texture = null};
|
||||||
CVideo.SetLoop(sk.VideoIndex, true);
|
|
||||||
CVideo.Pause(sk.VideoIndex);
|
|
||||||
sk.Texture = null;
|
|
||||||
_Skins[skinIndex].VideoList[i] = sk;
|
_Skins[skinIndex].VideoList[i] = sk;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -87,10 +87,14 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
if (!File.Exists(fileName))
|
if (!File.Exists(fileName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Do this here as one may want to get the length afterwards!
|
|
||||||
_FileOpened = _DoOpen();
|
|
||||||
|
|
||||||
_FileName = fileName;
|
_FileName = fileName;
|
||||||
|
|
||||||
|
//Do this here as one may want to get the length afterwards!
|
||||||
|
if (!_DoOpen())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_FileOpened = true;
|
||||||
|
|
||||||
_Thread.Priority = ThreadPriority.Normal;
|
_Thread.Priority = ThreadPriority.Normal;
|
||||||
_Thread.Name = Path.GetFileName(fileName);
|
_Thread.Name = Path.GetFileName(fileName);
|
||||||
_Thread.Start();
|
_Thread.Start();
|
||||||
@@ -105,8 +109,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
|
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
|
||||||
{
|
{
|
||||||
videoTime = 0;
|
videoTime = 0;
|
||||||
if (!_FileOpened)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (_Paused)
|
if (_Paused)
|
||||||
return false;
|
return false;
|
||||||
@@ -118,9 +120,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
_SetTime += _LoopTimer.ElapsedMilliseconds / 1000f;
|
_SetTime += _LoopTimer.ElapsedMilliseconds / 1000f;
|
||||||
videoTime = _SetTime;
|
videoTime = _SetTime;
|
||||||
|
|
||||||
_LoopTimer.Stop();
|
_LoopTimer.Restart();
|
||||||
_LoopTimer.Reset();
|
|
||||||
_LoopTimer.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,9 +160,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
#region Threading
|
#region Threading
|
||||||
private void _Skip()
|
private void _Skip()
|
||||||
{
|
{
|
||||||
if (!_FileOpened)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_VideoSkipTime = _Gap;
|
_VideoSkipTime = _Gap;
|
||||||
_SkipTime = _Start + _Gap;
|
_SkipTime = _Start + _Gap;
|
||||||
_BeforeLoop = false;
|
_BeforeLoop = false;
|
||||||
@@ -215,7 +212,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
{
|
{
|
||||||
//EventDecode.Set();
|
//EventDecode.Set();
|
||||||
while (!_Terminated)
|
while (!_Terminated)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
//if (EventDecode.WaitOne(10))
|
//if (EventDecode.WaitOne(10))
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
@@ -241,7 +237,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
_Copy();
|
_Copy();
|
||||||
Thread.Sleep(1);
|
Thread.Sleep(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_Free();
|
_Free();
|
||||||
}
|
}
|
||||||
@@ -314,7 +309,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
{
|
{
|
||||||
const int framedropcount = 4;
|
const int framedropcount = 4;
|
||||||
|
|
||||||
if (!_FileOpened || _NewFrame)
|
if (_NewFrame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_Paused || _NoMoreFrames || _BufferFull)
|
if (_Paused || _NoMoreFrames || _BufferFull)
|
||||||
@@ -452,9 +447,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
|
|
||||||
private void _UploadNewFrame(ref CTexture frame)
|
private void _UploadNewFrame(ref CTexture frame)
|
||||||
{
|
{
|
||||||
if (!_FileOpened)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (_MutexFramebuffer)
|
lock (_MutexFramebuffer)
|
||||||
{
|
{
|
||||||
int num = _FindFrame();
|
int num = _FindFrame();
|
||||||
|
|||||||
Reference in new issue
Block a user