Game Development Community

Looping a Theora Video

by Neil Marshall · in Torque Game Engine · 11/18/2005 (7:52 am) · 36 replies

How would I go about looping a theora video?

or avi I guess. I just want my menu system to be non-static.
Page«First 1 2 Next»
#21
01/10/2007 (2:14 am)
Hi,Guys.I have a very similar problem.When the video playback come to an end,Is there any signature I could capture?Just something like the following:
function MyVideoCtrl::onEnd(%this)
{
}
Perhaps,some modification in code is needed.But I am still new to code modification,Is there anyone kind enough to write the available code.Very Thanks!
I have read the posts above,I think some modification will locate in the onRender( ), Right? And how?

void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect)
{
const RectI rect(offset, mBounds.extent);

if(mTheoraTexture.isReady() && mTheoraTexture.isPlaying())
{
mTheoraTexture.refresh();
dglClearBitmapModulation();
dglDrawBitmapStretch(mTheoraTexture, rect);
}
else
{
if(mTheoraTexture.isReady())
{
mDone = true;

//==============================
//Maybe some code will be added here,right?
//==============================


if( mLoop )
{
setFile(mFilename); // Play the animation again.
}
}

dglDrawRectFill(rect, mBackgroundColor); // black rect
}

renderChildControls(offset, updateRect);
}
#22
01/10/2007 (2:28 am)
I hate the flash too. The thought I had was to be able to control the play head - so to speak - add a few black frames at the beginning and end of the vid and never jump to the head or tail. This should eliminate the flashing. Haven't tried it yet.

Anyone interested in writing an extension for the Theora player???
#23
01/25/2007 (10:42 am)
Winsoft:

I accomplished this with the following snippets. Of course you need to declare the boolean in constructor and header.

This code exposes a function in the script end MyTheoraVideo::onDone(%this)

void GuiTheoraCtrl::setFile(const char* szFilename)
{
mDone = false;
mDoneDispatched = false;
if(szFilename && szFilename[0])
mTheoraTexture.setFile(szFilename, true);
}

void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect)
{
const RectI rect(offset, mBounds.extent);

if(mTheoraTexture.isReady() && mTheoraTexture.isPlaying())
{
mTheoraTexture.refresh();
dglClearBitmapModulation();
dglDrawBitmapStretch(mTheoraTexture, rect);
}
else
{
if(mTheoraTexture.isReady())
{
mDone = true;

if (!mDoneDispatched)
{
mDoneDispatched = true;
Con::executef(this, 1, "onDone");
}
}

dglDrawRectFill(rect, mBackgroundColor); // black rect
}

renderChildControls(offset, updateRect);
}
#24
01/25/2007 (10:53 am)
The other thing I've been trying to implement it pausing the video and starting it at the beginning without reloading the file.
#25
01/25/2007 (1:14 pm)
Also, has anyone successfully played back an 800x600 video of good quality at 30fps? If so, how'd you do it and what settings / codecs did you use with ffmpeg2theora ?
#26
01/25/2007 (3:42 pm)
How would I got about implementing a function like...

// Torquescript
          PlayTheoraVideo(starthere, endhere, loop);
#27
03/01/2007 (9:32 am)
Here's an update i did and tested under ubuntu 6.10 that plays back a video and loops it without flashing and speed seems ok. Enjoy.

diff -ur TorqueGameEngineSDK-Linux-1-5-0/engine/gui/shiny/guiTheoraCtrl.cc tge_sdk/engine/gui/shiny/guiTheoraCtrl.cc
--- TorqueGameEngineSDK-Linux-1-5-0/engine/gui/shiny/guiTheoraCtrl.cc	2006-10-24 17:30:08.000000000 -0400
+++ tge_sdk/engine/gui/shiny/guiTheoraCtrl.cc	2007-03-01 12:28:00.000000000 -0500
@@ -17,7 +17,9 @@
 {

    mFilename      = StringTable->insert("");

    mDone          = false;

-   mStopOnSleep   = false;

+   mStopOnSleep   = false;
+   mDone          = false;
+   mLoop          = false;
    mBackgroundColor.set(0,0,0);

 }

 

@@ -36,6 +38,7 @@
 	addField("done",        TypeBool,      Offset(mDone,              GuiTheoraCtrl));

    addField("stopOnSleep", TypeBool,      Offset(mStopOnSleep,       GuiTheoraCtrl));

    addField("backgroundColor", TypeColorI,Offset(mBackgroundColor,   GuiTheoraCtrl));

+    addField("loop",        TypeBool,      Offset(mLoop,              GuiTheoraCtrl));
 

    endGroup("Playback");

 }

@@ -57,9 +60,12 @@
 

 void GuiTheoraCtrl::setFile(const char* szFilename)

 {

-	mDone = false;

+	mDone = false;
+	mDoneDispatched = false;
+

+	mFilename = StringTable->insert(szFilename);
 	if(szFilename && szFilename[0])

-		mTheoraTexture.setFile(szFilename, true);

+		mTheoraTexture.setFile(szFilename, true, true);

 }

 

 void GuiTheoraCtrl::stop()

@@ -99,17 +105,25 @@
 	{

 		mTheoraTexture.refresh();

 		dglClearBitmapModulation();

-		dglDrawBitmapStretch(mTheoraTexture, rect);

+		dglDrawBitmapStretch(mTheoraTexture, rect);
+		renderChildControls(offset, updateRect);

 	}

 	else

 	{

-		if(mTheoraTexture.isReady())

-			mDone = true;

-

- 		dglDrawRectFill(rect, mBackgroundColor); // black rect

+		if(mTheoraTexture.isReady()) {

+            if (mLoop) {
+                dglDrawBitmapStretch(mTheoraTexture, rect);
+                renderChildControls(offset, updateRect);
+                mTheoraTexture.setFile(mFilename, true, true);
+            } else {
+                mDone = true;
+                if (!mDoneDispatched) {
+                    mDoneDispatched = true;
+                    Con::executef(this, 1, "onDone");
+                }
+            }
+		}
 	}

-

-	renderChildControls(offset, updateRect);

 }

 

 //----------------------------------------------------------------------------

diff -ur TorqueGameEngineSDK-Linux-1-5-0/engine/gui/shiny/guiTheoraCtrl.h tge_sdk/engine/gui/shiny/guiTheoraCtrl.h
--- TorqueGameEngineSDK-Linux-1-5-0/engine/gui/shiny/guiTheoraCtrl.h	2006-10-24 17:30:08.000000000 -0400
+++ tge_sdk/engine/gui/shiny/guiTheoraCtrl.h	2007-03-01 12:25:36.000000000 -0500
@@ -37,6 +37,9 @@
 
    /// Are we done with playback?
    bool mDone;
+   bool mLoop;
+   bool mDoneDispatched;
+
 
    /// Our background color.
    ColorI mBackgroundColor;
#28
03/01/2007 (11:31 pm)
Benoit Touchette, your code run OK, thanks!.
#29
03/02/2007 (2:58 am)
Acehart@ What platform did you test it on
#30
08/15/2007 (1:25 pm)
Thats weird
im sure the original version of this feature i submitted had working looping without flashing
some of the stuff was changed, polished, a few helper pieces added by the GG guys and a few bugs apparently too ;)
#31
08/15/2007 (4:47 pm)
I can't remember if my video flashes - I'll have to check. I think I brute forced it - but I've updated tgb a few times, so I don't think I implemented any code changes are a while. Are people getting the flashing with TGB or TGE?
#32
04/02/2008 (8:38 am)
@ Benoit......or anyone.
Your code is incomplete, mDoneDispatched? gives errors, a minor fix if just added to the class. Also in your stop() function, you have a block of code with opening braces followed by an else statement. What is the if statement?
One last thing, your calling a function in script via Con::executef(this, 1, "onDone"); does this function in script do anything in specific? or is it just a notification?
Thx.
#33
04/02/2008 (8:46 am)
I did a bunch of stuff with theora which some might find useful.
You can either use the whole thing or pick out pieces as needed.
You can find it HERE
#34
04/02/2008 (8:55 am)
Hey, thanks for the tip, just one issue though, at the bottom of your "HERE" source I'm having the same issues as Ryan Deluz did. Any ideas?
#35
04/02/2008 (9:02 am)
You mean the thread stuff? Only saw that now actually (Ive been away from GG a bit).

Won't have time for a while to look at it (and as the resource says, not much inclination either ;p)
#36
06/04/2008 (2:08 pm)
I just gotta say this: THANK YOU! The last update worked great in 1.5.2/
Page«First 1 2 Next»