AnsweredAssumed Answered

Can't play MP3s on iMX6 Solo using QMediaPlayer on Qt5

Question asked by ralph__ on Oct 8, 2014
Latest reply on Oct 28, 2014 by gusarambula

I'm trying to play back MP3 files on my iMX6 Solo evaluation board using Qt. I can already play MP3s using mplayer and also using gstreamer with any of the following command lines:

 

mplayer /usr/sample.mp3

gst-launch filesrc location=/usr/sample.mp3 ! mad ! alsasink  

gst-launch filesrc location=/usr/sample.mp3 ! mp3parse ! ffdec_mp3 ! alsasink

 

However, when I try to use Qt5 (with ALSA and Pulseaudio support enabled) I can only play back wav files. For example, this code works fine:

 

qDebug() << "Play /usr/sample.wav.\n";

QMediaPlayer* player1 = new QMediaPlayer;

player1->setMedia(QUrl::fromLocalFile("/usr/sample.wav"));

player1->setVolume(100);

player1->play();

sleep(10);

delete(player1);

 

But this code gives me an error:

 

qDebug() << "Play /usr/sample.mp3.\n";

QMediaPlayer* player2 = new QMediaPlayer;

player2->setMedia(QUrl::fromLocalFile("/usr/sample.mp3"));

player2->setVolume(100);

player2->play();

sleep(20);

delete(player2);

 

The error message I get back is:

 

GStreamer; Unable to play - "file:///usr/sample.mp3"

 

Does anyone know what is going wrong or how to specify which sinks to use to Qt?

 

Some more information that might help is the output of "gst-inspect-0.10 | grep imx":

 

beep.imx: ac3: ac3

beep.imx: 3ca: ac3

beep.imx:  beepdec: beep audio decoder

isink.imx:  mfw_isink: IPU-based video sink

tvsrc.imx:  tvsrc: v4l2 based tv src

vpu.imx:  vpudec: VPU-based video decoder

vpu.imx:  vpuenc: VPU-based video encoder

aiur.imx: webm: webm

aiur.imx:  aiurdemux: aiur universal demuxer

ipucsc.imx:  mfw_ipucsc: IPU-based video converter

v4lsrc.imx:  mfw_v4lsrc: v4l2 based camera src

v4lsink.imx:  mfw_v4lsink: v4l2 video sink

 

There is no mp3 codec there. Could this be the problem? Looking at other people's builds, they all seem to have this line:

 

beep.imx:  beepdec.mp3: MP3 decoder

 

Thanks.

Ralph

Outcomes