Game Development Community

dev|Pro Game Development Curriculum

Theora Video Seek, Loop And Callback Support

by Neo Binedell · 11/12/2007 (1:44 pm) · 4 comments

Download Code File

A while ago I was contracted to add seeking to the theora video stuff but the client took the first code drop and that was the last I heard of them. Not a train smash at least as I can now release the code back to the GG community instead ;p

I refactored the theora code to be a bit more understandable and know more than I ever wanted to about the theora/ogg stuff and frankly don't have the time or inclination to clean it up further. The code as it stands seeks (using either a seek file or just from the start of the file) well enough and latency is ok but there are occasional sync issues and glitches, nothing that half an hour of playing with the code won't clear up though...

It supports seeking by time or frame, frame callbacks, end of stream callbacks, looping, etc. The code was created against the latest released TGB head code base so you can either just extract it over your old source or merge as needed.

The player can seek using a seek file that contains info to speed up searching and can be set to generate a seek file as well.

Hope it helps anyone that needs this kind of thing in the future, so enjoy....

Here is some example TS code for using it:

//
//   Loop callback
//
function VidPlayer::onMovieLoop( %this )
{
	echo( "MOVIE LOOPED!" );
}

//
//   Frame change callback
//
function VidPlayer::onMovieFrame( %this, %frame, %time )
{   
   %vtime = %this.getCurrentVTime();

   txtFrame.text = "frame: " @ %frame @ " time: " @ %time @ " vtime: " @ %vtime; 
}

//
//   Seek back a bit, call from e.g. button press
//
function doSeekBk()
{
   // Just move a few seconds back in time
   VidPlayer.setCurrentTime( VidPlayer.getCurrentTime() - 4 );   
}

//
//   Seek fwd a bit, call from e.g. button press
//
function doSeekFwd()
{
   // Just move a few seconds back in time
   VidPlayer.setCurrentTime( VidPlayer.getCurrentTime() + 4 );   
}

////////////////// MAIN /////////////////

VidPlayer.saveSeekFile  = false;
VidPlayer.theoraFile    = "game/data/video/test.ogg"; 
VidPlayer.seekFile      = "game/data/video/seek.txt";
VidPlayer.loop          = !VidPlayer.saveSeekFile;

VidPlayer.play();

#1
12/01/2007 (2:09 am)
Hi

How to use this resource in TGEA ?

Thanks
Bye
#2
12/07/2007 (9:14 pm)
Thanks for this Neo, I remember a lot of people asking how to do this in the forums. It could be handy someday.
#3
12/10/2007 (12:54 pm)
I tried to get this to work in TGE but I can't get this to work as it refers to a file:

#include "platform/threads/thread.h"

instead of:

#include "platform/platformThread.h"

when I change the header to the one I have it complains of missing functions in the thread class

Have you tried to put this into TGE?
#4
01/15/2009 (10:35 am)
Is this resource no longer available ?