QTMultimedia compilation for Raspberry Pi

2020-07-18 04:11发布

问题:

I just need to play simple audio wav or mp3 file from QT 5.1 application running on Raspberry Pi.

My console application is successfully building and deploying to pi.

However I'm getting a message when I try to play the file:

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

I try to play the file like this:

QMediaPlaylist * playlist = new QMediaPlaylist;
playlist->addMedia(QUrl::fromLocalFile(hall1_5min));
playlist->addMedia(QUrl::fromLocalFile(hall1_start));
playlist->setCurrentIndex(1);
QMediaPlayer * player = new QMediaPlayer;
player->setPlaylist(playlist);
player->play();

As I understand there is something wrong with my QTMultimedia compilation.. I need help with that. I've compiled with these instructions. I've installed some gstreamer packages as mentioned above, However, when I compile QTMultimedia module when running qmake - it doesn't detect gstreamer..

How can I compile QTMultimedia with explicitly specified gstreamer or other media service driver?

回答1:

If QtMultimedia is not being built, how can you expect it to work running the application?

That probably means you're still missing some dependencies or something else is wrong with your env. Maybe you didn't set pkgconfig paths correctly. You can also try with this guide I wrote: http://thebugfreeblog.blogspot.it/2013/03/bring-up-qt-501-on-raspberry-pi-with.html. I had issues with audio and gstreamer, but some time has passed and something might have changed since then.

If after building and deploying the QtMultimedia module and the gstreamer plugin you still get that, use the QT_DEBUG_PLUGIN env variable to get some logs.