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