PDA

View Full Version : play a video from youtube



graciano
25th March 2010, 23:06
Hi,
This is my first try with Phonon ... so be patient :o

I wrote this code:


#include <QApplication>
#include <QBoxLayout>
#include <QWidget>
#include <QUrl>
#include <Phonon>

int main(int argc, char *argv[]){
QApplication app(argc, argv);
app.setApplicationName("myApp");
QWidget *window = new QWidget;
QWidget *video = new QWidget;
Phonon::VideoPlayer *myPlayer= new Phonon::VideoPlayer(Phonon::VideoCategory, video);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myPlayer);
window->setLayout(layout);
QUrl url("http://www.youtube.com/watch?v=p916yeFa2Xk");
myPlayer->play(url);
window->show();
return app.exec();
}


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

Thanks

skepticalgeek
26th March 2010, 06:17
You need to create a Media Object from the URL. Instead of :
myPlayer->play(url);

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

cuteatul
13th July 2011, 07:17
Hi
I hace implemented this code ... But Phonon reference not found in header section in main file..

Plz Help