QMediaPlayer doesn't play anything on Ubuntu 16.04 / Qt 5.6

只谈情不闲聊 提交于 2019-11-28 09:18:52

问题


I'm using the official Qt 5.6 SDK on Ubuntu 16.04 and when I try to play an mp3 file I just get:

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

The code is as simple as it gets:

mMediaPlayer->setMedia(QUrl::fromLocalFile(myMp3File));
mMediaPlayer->play();

This works on Android and it worked on my Ubuntu 14.04 machine before. What am I missing? All the required gstreamer (by documentation) stuff seems to be installed already by default, but it still doesn't work:

$ dpkg -l | grep gstream
ii  gir1.2-gstreamer-1.0                                 1.8.2-1~ubuntu1                                             amd64        GObject introspection data for the GStreamer library
ii  gstreamer1.0-alsa:amd64                              1.8.2-1ubuntu0.1                                            amd64        GStreamer plugin for ALSA
ii  gstreamer1.0-clutter-3.0                             3.0.18-1                                                    amd64        Clutter PLugin for GStreamer 1.0
ii  gstreamer1.0-fluendo-mp3:amd64                       0.10.32.debian-1                                            amd64        Fluendo mp3 decoder GStreamer 1.0 plugin
ii  gstreamer1.0-libav:amd64                             1.8.2-1~ubuntu1                                             amd64        libav plugin for GStreamer
ii  gstreamer1.0-plugins-bad:amd64                       1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "bad" set
ii  gstreamer1.0-plugins-bad-faad:amd64                  1.8.2-1ubuntu0.1                                            amd64        GStreamer faad plugin from the "bad" set
ii  gstreamer1.0-plugins-bad-videoparsers:amd64          1.8.2-1ubuntu0.1                                            amd64        GStreamer videoparsers plugin from the "bad" set
ii  gstreamer1.0-plugins-base:amd64                      1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "base" set
ii  gstreamer1.0-plugins-base-apps                       1.8.2-1ubuntu0.1                                            amd64        GStreamer helper programs from the "base" set
ii  gstreamer1.0-plugins-good:amd64                      1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "good" set
ii  gstreamer1.0-plugins-ugly:amd64                      1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "ugly" set
ii  gstreamer1.0-plugins-ugly-amr:amd64                  1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins from the "ugly" set
ii  gstreamer1.0-pulseaudio:amd64                        1.8.2-1ubuntu0.1                                            amd64        GStreamer plugin for PulseAudio
ii  gstreamer1.0-tools                                   1.8.2-1~ubuntu1                                             amd64        Tools for use with GStreamer
ii  gstreamer1.0-x:amd64                                 1.8.2-1ubuntu0.1                                            amd64        GStreamer plugins for X11 and Pango
ii  libgstreamer-plugins-bad1.0-0:amd64                  1.8.2-1ubuntu0.1                                            amd64        GStreamer development files for libraries from the "bad" set
ii  libgstreamer-plugins-base1.0-0:amd64                 1.8.2-1ubuntu0.1                                            amd64        GStreamer libraries from the "base" set
ii  libgstreamer-plugins-good1.0-0:amd64                 1.8.2-1ubuntu0.1                                            amd64        GStreamer development files for libraries from the "good" set
ii  libgstreamer1.0-0:amd64                              1.8.2-1~ubuntu1                                             amd64        Core GStreamer libraries and elements
ii  libreoffice-avmedia-backend-gstreamer                1:5.1.4-0ubuntu1                                            amd64        GStreamer backend for LibreOffice

...and of course my sounds work otherwise perfectly.


回答1:


First, run your application with QT_DEBUG_PLUGINS=1 to see plugin errors.

If you see errors about "libgstaudio-0.10.so.0", it's a GStreamer version problem. The official Qt binaries seems to need GStreamer 0.10.

Solutions I found :

  • Use the libqt shipped with your distribution, using your package manager : It's the best solution I found, since it's built with the right GStreamer version. I use different chroot to make packages for distributions that embed different GStreamer versions.
  • Compile Qt from source to enable Gstreamer 1.0 : Not tested
  • Install Gstreamer 0.10 : I don't recommend this option, or use a chroot with an older distribution if you need it.


来源:https://stackoverflow.com/questions/39563308/qmediaplayer-doesnt-play-anything-on-ubuntu-16-04-qt-5-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!