简体   繁体   中英

Qt: no playback on linux

I have tried (I think) every possible way of playing audio in a Qt project, none of which have worked:

None of these solutions play WAV or MP3, and I have tried loading the files from a resource ( qrc:media/file.wav ) or simply from disk ( /full/path/to/file.wav ).

I think the problem is with codecs. QAudioDevice::supportedCodecs() returns an empty list. I'm on a linux system that has no problems playing audio/video (Ubuntu 14.04, usually playing in VLC... that uses its own codecs?).

Playing with QSound (WAV & MP3):

QSoundEffect(pulseaudio): Error decoding source

QMediaplayer (WAV): nothing happens

QMediaplayer (MP3):

GStreamer; Unable to play - "qrc:media/lowtone.mp3"

Qt uses specific media backends for each platform(link is qt5, but it was the same in Qt4). From the error it looks like your version is using GStreamer .

Check if the gstreamer dev packages on your distribution are well installed, because QAudioDevice::supportedCodecs must return at least audio/pcm . Work on the package setup until your test program show pcm . See https://wiki.qt.io/Building_Qt_for_Linux

You may also need to install plugins (also dev packages) before being able to play wav or mp3 using phonon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM