Reputation:
I have added QVideoWidget as a child to QWidget, and I am trying to play local avi file, but without success. Here is the code:
#include "widget.h"
#include <QApplication>
#include <QtWidgets>
#include <QtMultimediaWidgets>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget window;
window.resize(320, 240);
window.setWindowTitle(QApplication::translate("childwidget", "Child widget"));
window.show();
QMediaPlayer *player = new QMediaPlayer;
QMediaPlaylist *playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl::fromLocalFile("/home/designer/Desktop/drop.avi"));
QVideoWidget *videoWidget = new QVideoWidget(&window);
player->setVideoOutput(videoWidget);
videoWidget->resize(320, 240);
videoWidget->show();
playlist->setCurrentIndex(1);
player->play();
return a.exec();
}
I included multimedia, multimediawidgets and widgets in my .pro file.
Also gstreamer packages are installed with sudo apt-get install gstreamer* libgstreamer* and version is 0.10.
I am running Debian Wheezy on VMWare and trying to build that code for i386 Desktop machine.
Am I missing something important so this code won't work? Only I get is black QVideoWidget window inside parrent QWidget.
Upvotes: 0
Views: 2228
Reputation: 11769
Your issue seem to be GStreamer-related. Please install a gst123 player (which is pure gstreamer-based player) and make sure it plays the file without printing errors. If it does not, QMediaPlayer will not play it either.
If gst123 does not work, it is either of:
gstreamer-plugins-good gstreamer-plugins-base gstreamer-plugins-ugly gstreamer-plugins-bad-orig-addon gstreamer-plugins-qt5 gstreamer-plugins-bad gstreamer-plugins-good-extra gstreamer-plugins-ugly-orig-addon gstreamer-plugins-libav
Make sure you install plugins for proper versions (if your machine has gstreamer_0.10 and gstreamer 1.x for example). Qt uses GStreamer 1.x
If you're using OpenSuSE, your GStreamer installation is crippled to be practically useless. You need to add Packman repository and reinstall all installed GStreamer packages with "vendor change".
For some videos the VDPAU driver breaks it in QMediaPlayer (while playing fine with gst123) - try to removing the gstreamer VDPAU plugin to check it.
Upvotes: 1
Reputation: 9648
This was a bit much for a comment, so I made it an answer. But what happens if you use a video that you know works?
Also I have tested the following minimal snippet (see the question about it here). Maybe after getting that to work, integrating the playlist can be done easily after.
int main( int argc, char **argv ){
QApplication app(argc, argv);
QMediaPlayer *media=new QMediaPlayer(0);
QVideoWidget *video=new QVideoWidget(0); //new QGLWidget()
media->setVideoOutput(video);
media->setMedia(QUrl::fromLocalFile("/tmp/avatar.mp4"));
media->play();
video->show();
return app.exec();
}
Upvotes: 1
Reputation: 4010
I think you forget set playlist to player:
player->setPlaylist(playlist);
Upvotes: 1