PDA

View Full Version : need help with design!!



boss_bhat
25th July 2006, 12:13
Hi all,

I am trying to embed a Movie player in the QWidget. Player is written in C++ and I am facing problems while controling the flow, here is the code i have written,

void MyFilmyWidget::start ()
{

// Start up the player
// Its better to pass the (w,h) to constructor we will use this size next,
myplayer = new NicePlayer(2,variable1,width(),height());

// Let's parse the headers
myplayer->parseheaders();

//Initializing the decoders
myplayer->initdecoders();

// handle the movie, now player will play the movie!!
myplayer->handleMovie();


}

Now if I call " emit myfilmywidget.start();" it works fine. But I don't know how to implement stop ? Because once myplayer->handleMovie() is called it plays the full movie and then controle comes back to the Qt. Do I have to use threads to solve this problem? I mean to say once I enter emit() I have to instantiate a QThread which envelopes all this code in the run() method some thing like this,

void MyFilmyWidget::start ()
{
thinThread= new MyThinThread;
thinThread.run();
}

class MyThinThread : public QThread
{
public:
void run();
};

void MyThinThread ::run()
{
//same code here!!
myplayer = new NicePlayer(2,variable1,width(),height());

}

and in the stop () method
void MyFilmyWidget::stop()
{
thinThread->/*sleep till resume is called*/

}
Is this right way??
Do you guys can suggest a way using which I can obtain finer controle over the player


Thanks in advance,
Boss

wysota
25th July 2006, 14:06
If there is no other way to control the animation, then you should use threads (provided that the player gives a possibility to pause or stop the animation). But if it's possible, you should avoid threads.

boss_bhat
25th July 2006, 14:25
player I have embedded plays video, once passed and it doesnt have any interface to controle the video, like stop. Is their any way I can achieve,

void MyFilmyWidget::start ()
{
thinThread= new MyThinThread;
thinThread.run();
//My program should continue when this call is made without waiting for the completion of video
}

I mean to say thread is executed concurrently and program flow continues when the video is executing?

wysota
25th July 2006, 14:36
I mean to say thread is executed concurrently and program flow continues when the video is executing?

Yes, but you're limiting yourself only to starting and killing the player. Maybe you could use some different movie player?