aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-02-19 12:45:54 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-02-19 12:45:54 +0000
commit4d574975cc7fd0c0ad57aad6d171258bbf59cbfa (patch)
treef265c36413ac965f9587ebc4fd485f024c1fd966 /Game
parente2b979737b34d2eb30524fd3e886971ff1f65eb9 (diff)
downloadusdx-4d574975cc7fd0c0ad57aad6d171258bbf59cbfa.tar.gz
usdx-4d574975cc7fd0c0ad57aad6d171258bbf59cbfa.tar.xz
usdx-4d574975cc7fd0c0ad57aad6d171258bbf59cbfa.zip
first steps towards loopable videos.
( http://trac2.assembla.com/usdx/ticket/5 ) Currently videos specified in the song, will loop if they are shorter than the mp3. this should become selectable, however at the moment it will always loop if the video is shorter. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@863 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UVideo.pas20
1 files changed, 18 insertions, 2 deletions
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index 66c0c8e6..1eab5d91 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -89,7 +89,7 @@ type
ScaledVideoWidth, ScaledVideoHeight: Real;
VideoAspect: Real;
VideoTextureU, VideoTextureV: Real;
- VideoTimeBase, VideoTime, LastFrameTime, TimeDifference: Extended;
+ VideoTimeBase, VideoTime, LastFrameTime, TimeDifference, flooptime: Extended;
WantedAudioCodecContext,
@@ -212,7 +212,7 @@ begin
if fVideoPaused then Exit;
- myTime := Time + fVideoSkipTime;
+ myTime := ( Time - flooptime ) + fVideoSkipTime;
TimeDifference := myTime - VideoTime;
DropFrame := False;
@@ -267,7 +267,23 @@ begin
while ( FrameFinished = 0 ) do
begin
if ( av_read_frame(VideoFormatContext, AVPacket) < 0 ) then
+ begin
+ // Record the Time we looped, this is used to keep the loops, in time. otherwise they speed
+ flooptime := time;
+
+ // Dont use SetPosition() it dosnt let us go back to frame 0... can we / should we fix this ??
+ fVideoSkipTime := 0;
+ VideoTime := 0;
+
+ // Free the packet we just got from av_read_frame
+ av_free_packet( @AVPacket );
+
+ // Seek to frame 0 in the video stream
+ av_seek_frame(VideoFormatContext,VideoStreamIndex,0,AVSEEK_FLAG_ANY);
break;
+ end;
+
+
// if we got a packet from the video stream, then decode it
if (AVPacket.stream_index=VideoStreamIndex) then
begin