Playing Video in QML
I am able to play audio in QML without any errors or interruptions. However, when I wrote this code and tried to play video in QML, the video stops and program quits unexpectedly. Each time it starts running but at some point it crashes. Rarely it plays all the way until the end. When I play video in a Qt application it runs flawlessly but in QML it crashes. I also followed "this post":http://kunalmaemo.blogspot.com/2011/08/using-phonon-video-player-from-qml.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/kunalmaemo+(Qt,+Maemo+and+other+stuff)# but the video crashes also. I believe that the additional class (widget.h) mentioned in the blog is not necessary. Here is my code:
class QmlVideo : public QDeclarativeItem
explicit QmlVideo(QDeclarativeItem *parent = 0);
#endif // QMLVIDEO_H @
QmlVideo::QmlVideo(QDeclarativeItem *parent) :
myWidget = new QWidget();
player = new Phonon::VideoPlayer(Phonon::VideoCategory, myWidget);
proxy = new QGraphicsProxyWidget(this); proxy->setWidget(myWidget); player->mediaObject()->setCurrentSource(Phonon::MediaSource("File Path")); player->play();
Q_DECL_EXPORT int main(int argc, char *argv)
QScopedPointer<QApplication> app(createApplication(argc, argv));
qmlRegisterType<QmlVideo>("qmlVideo", 1, 0, "QmlVideo"); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/HybridNew/main.qml")); viewer.showExpanded(); return app->exec();
@import QtQuick 1.0
import qmlVideo 1.0
I also tried several other examples of working code for implementing phonon video in QML but it seems that while it works for other people it crashes on my computer for no clear reason!
can u please post the code for playing audio, which u mentioned u have successfully implemented and explain a lil bit ?
Any chance of a backtrace? I tried it, works ok for me.
QtRookie, did you ever get this to work? I am having trouble with the same code getting phonon to play the stream "v4l2://///dev/video2" (which it successfully displays in Qt) in QML