help with pause of video!

Frank

02-02-2010 08:40:06

Hi,
I have a problem with pausing a video.
I need to setup/initialize the video playing first, and play it later. I tried this with the demo code of ogrevideo plugin package (the project Demo_Player in the Solution TheoraVideoPlugin), with the following material:

material konqi
{
technique
{
pass
{
cull_software none
cull_hardware none
lighting off

texture_unit
{
texture_source ogg_video
{
filename konqi.ogg
precache 64
play_mode pause
}
}
}
}
}

but it doesn't work! The video cannot be paused, but played directly. (I didn't change anything in c code (player.cpp and .h files), so I don't paste these files here. )
How to pause a video in .material file? Could anyone give a hint?

Thank you very much!

Frank

Kreso

14-02-2010 23:20:44

Hi Frank,

I'm currently working on extending material file features. at this stage you can only specify which video can be played.
Are you using the trunk version or the current stable branch? (branches/monolith)

Frank

20-02-2010 08:54:05

Hi Kreso,

Thanks for your reply!

I'm using trunk version 96.
For video pausing issue, I'm using a walk-around solution currently: pausing and playing the video by calling TheoraVideoClip::pause() and TheoraVideoClip::play() in C++ codes. It works!
But I'm facing another problem: I cannot restart the video after it has already played. In my application the video needs to be played again and again.

Here is the codes:

void init(...) //preparation for playing the video
{
createQuad("video_1", "display_1", -0.5,1,1,-0.94, sceneMgr);

initAudioInterface();

Ogre::TheoraVideoManager* mgr = Ogre::TheoraVideoManager::getSingletonPtr();
mgr->setInputName("test_cz_1.ogg");
mgr->createDefinedTexture("display_1");

m_clip = mgr->getVideoClipByMaterialName("display_1"); //(TheoraVideoClip*)m_clip is a member variable of the class

m_clip->pause();
}

void play() //playing the video
{
m_clip->seek(0);
m_clip->play();
}

void createQuad(std::string name,std::string material_name,float left,float top,float right,float bottom, Ogre::SceneManager *sceneMgr)
{

Ogre::ManualObject* model = sceneMgr->createManualObject(name);
model->begin(material_name);

model->position(right,bottom,0); model->textureCoord(1,1);
model->position(right,top ,0); model->textureCoord(1,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(right,bottom,0); model->textureCoord(1,1);
model->position(left, bottom,0); model->textureCoord(0,1);

model->end();
// make the model 2D
model->setUseIdentityProjection(true);
model->setUseIdentityView(true);
// and atach it to the root node
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(model);

}

void initAudioInterface()
{
static Ogre::OpenAL_AudioInterfaceFactory* sAudioFactory;

if (sAudioFactory == 0)
{
sAudioFactory=new Ogre::OpenAL_AudioInterfaceFactory();

Ogre::TheoraVideoManager* mgr = Ogre::TheoraVideoManager::getSingletonPtr();
mgr->setAudioInterfaceFactory(sAudioFactory);
}
}


The runtime error is:
Run-Time Check Failure #3 - The variable 'th_granule' is being used without being initialized.

The seek() function in demo application (Demo_Player/player.cpp) works well, so I guess there is something wrong in my codes.

Could you kindly give some hints about how to use the seek() function?
And what version of Theora plugin is the most stable and fully-functional version?

I'd really appreciate it!

Frank

Kreso

20-02-2010 12:06:48

Hi Frank,

Yup, the old version of the plugin (revision 96) has had it's share of problems. The latest trunk revision works quite nice with libtheoraplayer, which is esentially this plugin transfered in a platform independent enviroment so non-ogre users can benefit from it.

the current trunk version is quite simplistic and uses libtheoraplayer's api's to control the playback. If you feel bold, you can check it out. Seeking and many other features have been greatly improved since the separation.

Compiling is simple, go to http://libtheoraplayer.sf.net and download the latest trunk version of libtheoraplayer and compile it againts libtheora,libvorbis and libogg (ptypes no longer needed)

then, use the genenerated dll and lib files to compile ogrevideo plugin. Currently in trunk revision 107 only the simple player demo works with Ogre.

To check out how you can seek and perform various ops with the plugin, check out libtheoraplayer's API reference.


if you get it to work (and there's no reason you shouldn't), let me know which features you'd need first so I can concentrate on implementing them first!

Frank

24-02-2010 08:57:03

Hi Kreso,

I've tried the version 107 + libtheoraplayer, but have some problems with the demo (Demo_Player):

1) 'Duration' and 'time position' are not displayed at the top-left corner of the window.
2) 'current FPS' at the bottom-left corner is not displayed.
3) all buttons except 'pause' don't work.
4) Scrollbar at the bottom of the window doesn't work. When I scroll the video, the seek() function is not called. So this problem does not evidence that seek() function doesn't work.

These problems are GUI-related, so I cannot check if pause and seek functions work well or not for version 107+libtheoraplayer.
Maybe my configuration caused the problems? My environment is: version 107 + libtheoraplayer + OGRE 1.6.4 + VisualStudio2005 + windows XP professional SP3

Thank you for your support!

Frank :-)

Kreso

24-02-2010 11:45:26

Hi Frank,

yup, I havent implemented that functionality in the player demo. I'll do that today or tommorow and get back to you. What's important is that you've been able to compile and run libtheoraplayer + ogrevideo? :)

Frank

25-02-2010 02:13:03

Hi Kreso,

Yup, it's great to be able to easily compile and run ogrevideo 107 and libtheoraplayer trunk head version.

Frank

Kreso

25-02-2010 16:14:47

i've made a few changes in the svn trunk for the simple demo example, I've added full seeking. I think you'll find the seeking performance quite impressive ;)
I'll take care of the rest of the demo's buttons and info labels as well as other demos soon.

Frank

26-02-2010 00:47:13

Thank you, Kreso! I'll try it !

Frank

03-03-2010 08:31:04

Hi Kreso,
After updating the package to 109, the seek() function in Demo_player works well.
But when I call seek() in my application, it doesn't work. Furthermore pause() doesn't work, too.

For version 96, I use the following code to pause a video:

m_clip = mgr->getVideoClipByMaterialName("display_1"); //if use getVideoClipByName(...) to get TheoraVideoClip, pause() doesn't function
m_clip->pause();


In version 109, getVideoClipByMaterialName(...) is not supported, and if I use getVideoClipByName(...) to get TheoraVideoClip, pause() doesn't function (in both version 96 and 109)!

I guess there must be something wrong in my code, because 'Demo_player' applications in version 96 and 109 work correctly.
I gave the codes in the previous post, could you help check what's wrong with it?

Thank you very much!

Frank

Kreso

03-03-2010 08:42:54

does getVideoClipByName give a null pointer or a valid video clip pointer?

I'll implement getVideoClipByMaterialName and check getVideoClipByName soon and let you know here once it's done;

can you past your current code, the one with the getVideoClipByName call;

Frank

04-03-2010 00:34:20

Hi Kreso,

The current code is almost the same as the one for ogreplugin version 96:

void init(...) //preparation for playing the video
{
......
createQuad("video_1", "display_1", -0.5,1,1,-0.94, sceneMgr);

initAudioInterface();

Ogre::OgreVideoManager* mgr = (Ogre::OgreVideoManager *)Ogre::OgreVideoManager::getSingletonPtr();
mgr->setInputName("test_cz_1.ogg");
mgr->createDefinedTexture("display_1");

TheoraVideoManager *theoraMgr = TheoraVideoManager::getSingletonPtr(); //cannot get VideoClip from OgreVideoManager, so get VideoClip from TheoraVideoManager
m_clip = theoraMgr->getVideoClipByName("test_cz_1.ogg"); //returns a valid clip pointer

m_clip->pause(); //doesn't work, the video is played directly
}

void play() //playing the video
{
m_clip->seek(0);
m_clip->play(); //the video is not played here
}

void createQuad(std::string name,std::string material_name,float left,float top,float right,float bottom, Ogre::SceneManager *sceneMgr)
{

Ogre::ManualObject* model = sceneMgr->createManualObject(name);
model->begin(material_name);

model->position(right,bottom,0); model->textureCoord(1,1);
model->position(right,top ,0); model->textureCoord(1,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(right,bottom,0); model->textureCoord(1,1);
model->position(left, bottom,0); model->textureCoord(0,1);

model->end();
// make the model 2D
model->setUseIdentityProjection(true);
model->setUseIdentityView(true);
// and atach it to the root node
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(model);

}

void initAudioInterface()
{
static Ogre::OpenAL_AudioInterfaceFactory* sAudioFactory;

if (sAudioFactory == 0)
{
sAudioFactory=new Ogre::OpenAL_AudioInterfaceFactory();

Ogre::TheoraVideoManager* mgr = Ogre::TheoraVideoManager::getSingletonPtr();
mgr->setAudioInterfaceFactory(sAudioFactory);
}
}


getVideoClipByName returns a valid video clip pointer.

Frank :)