Problem with Qt Multimedia
-
@SGaist
this
is MainWindow.mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QtMultimedia/QMediaPlayer> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: QMediaPlayer *player = new QMediaPlayer(this); Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
-
@6EQUJ5 ,
Could you please try to run some media player that has already had in Qt package
Qt5.8.0\Examples\Qt-5.8\multimedia\video\qmlvideo
Qt5.8.0\Examples\Qt-5.8\multimediawidgets\playerYou should ensure that the Multimedia backend is available on your system or not?
Best regards,
Khoa -
@KhoaTran-Programmer With qmlvideo when I tried to play a video it logged me out again. With player it logged me out the moment I ran it.
Why do I get logged out when I try to run multimedia based Qt programs? And how do I ensure the multimedia back end is available on my system and install the multimedia backend?
-
You should start by testing with your distribution provided Qt to ensure that everything is working correctly.
-
How to ensure the multimedia backend is available or not? I try 2 methods before:
- Use default application of Qt(qmlvideo, player, ...)
-> If one of them can run well, we can conclude it's OK - Download Qt everywhere package and install(I try on Linux Embedded)
-> When building Qt Multimedia component, qmake will automatically detect the backend, if it's not available some error info will display
For your information, multimedia backend is not same for each OS
- Windows: Directshow -> it's always available in Windows
- Linux: Gstreamer -> Most, if not all, Linux distributions provide packages of GStreamer. You should find these in your distribution's package repository.
- QNX: ???
- Android: StageFight(maybe)
Since your OS is Linux(Debian 8), so please confirm Gstreamer firstly. The fastest way, open termial and run some Gstreamer command line tools:
$ gst-inspect-1.0
$ gst-launch-1.0For set up Gstreamer on Linux, please refer to:
https://gstreamer.freedesktop.org/documentation/installing/on-linux.htmlBest regards,
Khoa - Use default application of Qt(qmlvideo, player, ...)
-
@KhoaTran-Programmer On https://gstreamer.freedesktop.org/documentation/installing/on-linux.html the instructions for Debian installation is this:
Install GStreamre on Ubuntu or Debian Run the following command: apt-get install ....
Which I'm not sure about. I tried running
sudo aptitude install gstreamer
which didn't work. Then after typing insudo aptitude install gstreamer
and pressing TAB a bunch of packages came up which I don't know which to install.Can you clarify how to install on Debian?
-
@6EQUJ5 You should install all the GStreamer plug-in packages.
But I don't think it is related to the installed GStreamer packages: if something needed is missing you will not be able to play a media file, but you should not be logged off. -
@KhoaTran-Programmer The Gstreamer command line tools doesn't work (no such command exists according to terminal even with sudo). But, trying to install the Gstreamer plugins such as
gstreamer1.0-plugins-base
withsudo apt-get install gstreamer1.0-plugins-base
tells me it's already installed.@jsulm What do you mean "any" media player? The examples on Qt or any media player that is installed? If you mean any old media player GNOME MPlayer works.
@SGaist Aren't I doing that already? By using this version: Qt 5.8.0 for Linux 64-bit (766 MB)
-
@6EQUJ5 I don't have Debian here. But you should be able to find out what is needed. No need to install QtCreator from Debian as you already have it. On Ubuntu you can install qt5-default, don't know whether it is same on Debian.
-
@jsulm I uninstalled Qt with the maintenance tool. Then installed with
sudo aptitude install qt5-default
and qtcreator withsudo aptitude install qtcreator
.But, now I get this error
Project ERROR: Unknown module(s) in QT: multimedia
. In the .pro file I haveQT += multimedia
. I used the same code to test as way above.