I want to play an audio file (tested .wav, .mp3, .flac)using QMediaPlayer from the console application on embedded iMX8 device with Yocto HardKnott system. I'm testing code from Qt doc. It work's fine on PC, but it doesn't on the embedded device. It stuck with Media Status: QMediaPlayer::LoadingMedia
without any error. I guess that it's something in the system. Playing media from console it's possible using aplay
command. What can be a reason? How can I fix it?
QMediaPlayer *player = new QMediaPlayer;
QObject::connect(player, &QMediaPlayer::positionChanged, [=](qint64 position){
qDebug()<< "Current position: " << position;
});
QObject::connect(player, &QMediaPlayer::mediaStatusChanged, [=](QMediaPlayer::MediaStatus status){
qDebug()<< "Media Status: " << status;
});
player->setMedia(QUrl::fromLocalFile("/home/root/test.wav"));
player->setVolume(100);
player->play();
I tried debug Qt plugins on my platform, but I don't see any problem
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/mediaservice" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/mediaservice/libgstaudiodecoder.so"
Found metadata in lib /usr/lib/plugins/mediaservice/libgstaudiodecoder.so, metadata=
{
"IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0",
"MetaData": {
"Keys": [
"gstreameraudiodecode"
],
"Services": [
"org.qt-project.qt.audiodecode"
]
},
"archreq": 0,
"className": "QGstreamerAudioDecoderServicePlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("gstreameraudiodecode")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/mediaservice/libgstcamerabin.so"
Found metadata in lib /usr/lib/plugins/mediaservice/libgstcamerabin.so, metadata=
{
"IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0",
"MetaData": {
"Keys": [
"gstreamercamerabin"
],
"Services": [
"org.qt-project.qt.camera"
]
},
"archreq": 0,
"className": "CameraBinServicePlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("gstreamercamerabin")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/mediaservice/libgstmediacapture.so"
Found metadata in lib /usr/lib/plugins/mediaservice/libgstmediacapture.so, metadata=
{
"IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0",
"MetaData": {
"Keys": [
"gstreamermediacapture"
],
"Services": [
"org.qt-project.qt.audiosource"
]
},
"archreq": 0,
"className": "QGstreamerCaptureServicePlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("gstreamermediacapture")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/mediaservice/libgstmediaplayer.so"
Found metadata in lib /usr/lib/plugins/mediaservice/libgstmediaplayer.so, metadata=
{
"IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0",
"MetaData": {
"Keys": [
"gstreamermediaplayer"
],
"Services": [
"org.qt-project.qt.mediaplayer"
]
},
"archreq": 0,
"className": "QGstreamerPlayerServicePlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("gstreamermediaplayer")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/platform-benchmark_app/bin/mediaservice" ...
loaded library "/usr/lib/plugins/mediaservice/libgstmediaplayer.so"
QMediaPluginLoader: loaded plugins for key "org.qt-project.qt.mediaplayer" : ("gstreamermediaplayer")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/resourcepolicy" ...
QFactoryLoader::QFactoryLoader() checking directory path "/opt/platform-benchmark_app/bin/resourcepolicy" ...
The problem was in the system image and lack of gstreamer1.0 packets. It works separately, but it doesn't with Qt Multimedia. The solution is to add packet group gstreamer1.0 and gstreamer1.0-full to fsl image recipe.
CORE_IMAGE_EXTRA_INSTALL += " \
...
packagegroup-fsl-gstreamer1.0 \
packagegroup-fsl-gstreamer1.0-full \
...
"