Results 1 to 4 of 4

Thread: need help with design!!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default need help with design!!

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: need help with design!!

    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.

  3. #3
    Join Date
    Jun 2006
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: need help with design!!

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: need help with design!!

    Quote Originally Posted by boss_bhat
    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?

Similar Threads

  1. Three Tier Database Programming - Design Pattern
    By sunil.thaha in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2011, 04:00
  2. Replies: 10
    Last Post: 2nd December 2010, 07:10
  3. Design Patterns in Qt
    By bits in forum General Discussion
    Replies: 11
    Last Post: 11th May 2007, 09:13
  4. A Design Issue...
    By nupul in forum Qt Programming
    Replies: 6
    Last Post: 4th May 2006, 17:41
  5. Need some advice for design decision
    By BeS in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2006, 23:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.