QtMultimedia flac support

1.3k Views Asked by At

im trying to use Qt library QtMultiMedia to play music. I want it to support .flac format as well. I'm running Windows 8.1, i installed flac codecs from http://xiph.org/dshow/ . BTW it works perfectly with mp3s .

Sample code:

QMediaPlaylist plst;
plst.addMedia(QUrl::fromLocalFile("path/file.flac"));
QMediaPlayer pl;
pl.setPlaylist(plst);
pl.play();

It does not play anything.

1

There are 1 best solutions below

0
On

I tried it without QMediaPlaylist and it worked...

QMediaContent content(QUrl::fromLocalFile("ABSOLUTE_PATH_TO_FILE"));
QMediaPlayer* player = new QMediaPlayer();
player->setMedia(content);

player->play();

I tested you code and it didn't work... even with absolute Path.

MAYBE OPTIONAL!!! ==>

I got a gstreamer error message which I inspected and ended up in learning gstreamer... even more error messages with 0.10 and 1.0. So I installed everything depending on gstreamer (both versions) and with the last update I was finally able to play sound in both versions

sudo apt-get install gstreamer1.0-plugins-* gstreamer0.10-plugins-*

<== MAYBE OPTIONAL END

Your code still didn't work. So I compared...

I used pointers!

QMediaPlaylist* plst = new QMediaPlaylist();
plst->addMedia(QUrl::fromLocalFile("ABSOLUTE_PATH_TO_FILE"));

QMediaPlayer *pl = new QMediaPlayer();
pl->setPlaylist(plst);

pl->play();

Now it works! (don't ask me why...).

To sum it up: Pointers and Absolute Path [maybe gstreamer-plugins...]

This is only a solution for Debian...

Can you tell me if it works in Windows?

How did you solve it?

If you close the application while still playing you get a SegFault.