本文介绍了QMediaPlayer在Ubuntu 16.04/Qt 5.6上不播放任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu 16.04上使用官方的Qt 5.6 SDK,当我尝试播放mp3文件时,我得到的是:

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"

代码非常简单:

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

这可以在Android上使用,并且以前可以在我的Ubuntu 14.04计算机上使用.我想念什么?默认情况下,所有必需的gstreamer(根据文档)似乎已经安装,但是仍然无法正常工作:

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.

推荐答案

首先,使用QT_DEBUG_PLUGINS = 1运行您的应用程序以查看插件错误.

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

如果看到有关"libgstaudio-0.10.so.0"的错误,则是GStreamer版本问题.官方的Qt二进制文件似乎需要GStreamer 0.10.

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.

我发现的解决方案:

  • 使用您的发行版附带的libqt,以及您的包管理器:这是我找到的最好的解决方案,因为它是使用正确的GStreamer版本构建的.我使用不同的chroot为嵌入了不同GStreamer版本的发行版制作软件包.
  • 从源代码编译Qt以启用Gstreamer 1.0 :未经测试
  • 安装Gstreamer 0.10:我不建议使用此选项,如果需要,请使用具有较旧发行版的chroot.
  • 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.

这篇关于QMediaPlayer在Ubuntu 16.04/Qt 5.6上不播放任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 23:56