Results 1 to 9 of 9

Thread: To Play Movie in QT 4

  1. #1
    Join Date
    Jan 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question To Play Movie in QT 4

    Hi,

    I am looking for an option where I can embed a movie (small) with my widget and play whenever required. Pls. let me know if its possible.

    Thanks in Advance

  2. #2
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: To Play Movie in QT 4

    Quote Originally Posted by Isa View Post
    Hi,

    I am looking for an option where I can embed a movie (small) with my widget and play whenever required. Pls. let me know if its possible.

    Thanks in Advance
    Dear Isa!
    You can use QX11EmbedContainer widget and play movie with the help of MPlayer application using with QProcess.
    Qt Code:
    1. QProcess *mp=new QProcess(0);
    2.  
    3. connect(mp, SIGNAL(finished(int)),this,SLOT(endPlayProcess()));
    4.  
    5. QString program = "mplayer";
    6. QStringList arguments;
    7. QString windowId=QString::number(winId());
    8. QString ratio="";
    9. ratio+="-monitoraspect "+QString::number(4)+":"+QString::number(3)+" ";
    10. arguments<<"-vo"<<"gl2" <<"-wid" << windowId << "-slave" <<mediaPath[currentIndex] << "n";
    11. mp->start(program,arguments);
    To copy to clipboard, switch view to plain text mode 
    In Qt there is no Movie Player widget.
    Last edited by ashukla; 21st January 2008 at 10:33. Reason: line missing
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  3. #3
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Lightbulb Re: To Play Movie in QT 4

    Here mediaPath[currentIndex] means file Name with path which you want to play.
    Last edited by ashukla; 21st January 2008 at 10:49.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  4. #4
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: To Play Movie in QT 4

    I have a problem embedding mplayer inside Qt Widget, in kde works fine, but it doesn't work under gnome, the player doesn't show.

    Qt Code:
    1. QProcess mplayerProcess = new QProcess;
    2. QString program = "mplayer";
    3. QStringList arguments;
    4. arguments << finalVideo << "-wid"<<QString::number(previewBox->winId())<<"-nosound";
    5. mplayerProcess->start(program,arguments);
    To copy to clipboard, switch view to plain text mode 

    previewBox is a GroupBox inside a QWidget.
    Any help ?

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To Play Movie in QT 4

    Have you seen Media Player example in Qt 4.4. It plays movie files using phonon

  6. #6
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: To Play Movie in QT 4

    Yes, use Phonon instead of XEmbed. It is included in Qt 4.4.0, and is meant for exactly this solution.

  7. #7
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: To Play Movie in QT 4

    Hi!!

    One question, Can i Play a video stream URL with Phonon?

    Thanks!

    Cheers.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

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

    Default Re: To Play Movie in QT 4

    Yes, Phonon-MediaSource takes a QUrl as its argument.

  9. #9
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: To Play Movie in QT 4

    Hi,

    I did:

    self.mediaObject = Phonon.MediaObject(self)
    self.webcamUrl = QUrl("http://gdnet.com.ar:8081")
    self.mediaObject.setCurrentSource(self.webcamUrl)
    And it complains "MediaObject.setCurrentSource() has an invalid type"
    I am using PyQt as well.
    I saw in the example that sets the media source for url like that, so i Don't know which is the error :S
    Even if I set an url to a ogg file, the same happens.

    Any tip? Thanks.

    Cheers.

    EDIT: never mind, i was doing it wrong. Now i wrote:

    self.mediaObject.setCurrentSource(Phonon.MediaSour ce(self.webcamUrl))
    Last edited by GuS; 2nd August 2008 at 12:37.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

Similar Threads

  1. To play mplayer in widget
    By Deepak Mishra in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2007, 16:42
  2. Play a movie in a widget
    By Deepak Mishra in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2007, 06:39
  3. Play gif file in QTextEdit field
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 15:28
  4. MP3 Sound / OGG Sound Play on GUI
    By patrik08 in forum Newbie
    Replies: 3
    Last Post: 1st September 2006, 19:01

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.