How to play a wma audio file using Qt or any other cpp framework on linux?

140 Views Asked by At

To make the code below work:

#include <QApplication>
#include <QPushButton>
#include <QMediaPlayer>
#include <iostream>

int main(int argc, char **argv) {
    QApplication application(argc, argv);
    QPushButton button("Click Me");
    button.show();

    auto player = new QMediaPlayer;
    player->setMedia(QUrl::fromLocalFile("/home/bj/m/y.wma"));
    player->setVolume(50);

    QObject::connect(&button, &QPushButton::clicked, [player](bool) {
        std::cout << "xxx" << std::endl;
        player->play();
    });
    return application.exec();
}

Now this code can play mp3 by installing gst-libav. But how to play wma?

1

There are 1 best solutions below

0
BaiJiFeiLong On

I solved. ugly plugin is required. sudo pacman -S gst-plugins-ugly