Results 1 to 3 of 3

Thread: play a video from youtube

  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default play a video from youtube

    Hi,
    This is my first try with Phonon ... so be patient

    I wrote this code:
    Qt Code:
    1. #include <QApplication>
    2. #include <QBoxLayout>
    3. #include <QWidget>
    4. #include <QUrl>
    5. #include <Phonon>
    6.  
    7. int main(int argc, char *argv[]){
    8. QApplication app(argc, argv);
    9. app.setApplicationName("myApp");
    10. QWidget *window = new QWidget;
    11. QWidget *video = new QWidget;
    12. Phonon::VideoPlayer *myPlayer= new Phonon::VideoPlayer(Phonon::VideoCategory, video);
    13. QVBoxLayout *layout = new QVBoxLayout;
    14. layout->addWidget(myPlayer);
    15. window->setLayout(layout);
    16. QUrl url("http://www.youtube.com/watch?v=p916yeFa2Xk");
    17. myPlayer->play(url);
    18. window->show();
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

    What's missing so that i can watch this beautiful video?

    Thanks

  2. #2
    Join Date
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: play a video from youtube

    You need to create a Media Object from the URL. Instead of :
    myPlayer->play(url);

    Try this:
    Phonon::MediaObject obj(url);
    myPlayer->play(obj);

  3. #3
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: play a video from youtube

    Hi
    I hace implemented this code ... But Phonon reference not found in header section in main file..

    Plz Help

Similar Threads

  1. youtube fullscreen effect for a widget
    By cyrfer in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2010, 12:57
  2. Downloading a video from youtube
    By Faster in forum Qt Programming
    Replies: 21
    Last Post: 28th November 2009, 12:46
  3. upload movie files to youtube
    By jay in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2009, 12:34
  4. Replies: 0
    Last Post: 29th May 2009, 13:00
  5. Play video in QT4 application
    By carlosmele in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2009, 22:24

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.