Qt MediaPlayer doesn't play audio
-
Hi and welcome to devnet,
You are using a relative path to your file. Is it located beside your application executable ?
-
@SGaist said in Qt MediaPlayer doesn't play audio:
Is it located beside your application executable ?
Yes, I have also tried to use qt resource files but the sound still doesn't play
@ABouncyMi When you remove set AudioOuptut does it play?
Is there any message in the application output?
You can check this as well https://evileg.com/en/post/155/ -
@ABouncyMi When you remove set AudioOuptut does it play?
Is there any message in the application output?
You can check this as well https://evileg.com/en/post/155/@Ronel_qtmaster
I've changed that, unfortunately it has the same output as before.Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () "file::/audio/bgm.m4a" ""
-
@Ronel_qtmaster
I've changed that, unfortunately it has the same output as before.Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () Error 20 (this feature has not been implemented yet) in function AVolute::GetProductInfoT::<lambda_3920e95365a48b95dd51020986e9e351>::operator () "file::/audio/bgm.m4a" ""
@ABouncyMi then you have a bug https://bugreports.qt.io/browse/QTBUG-79799
Did you try with Qmake?or simple qt exemple with qmake?It could be a problem with cmake
-
@ABouncyMi then you have a bug https://bugreports.qt.io/browse/QTBUG-79799
Did you try with Qmake?or simple qt exemple with qmake?It could be a problem with cmake
@Ronel_qtmaster said in Qt MediaPlayer doesn't play audio:
@ABouncyMi then you have a bug https://bugreports.qt.io/browse/QTBUG-79799
Did you try with Qmake?or simple qt exemple with qmake?It could be a problem with cmake
I tried Qmake, the same bug, but strangely the qt mediaplayer example in qt creator examples is working well, also I do not have an alien computer or msi sonic radar installed on my computer
-
@Ronel_qtmaster said in Qt MediaPlayer doesn't play audio:
@ABouncyMi then you have a bug https://bugreports.qt.io/browse/QTBUG-79799
Did you try with Qmake?or simple qt exemple with qmake?It could be a problem with cmake
I tried Qmake, the same bug, but strangely the qt mediaplayer example in qt creator examples is working well, also I do not have an alien computer or msi sonic radar installed on my computer
@ABouncyMi then it is an error in your code.Now try to open your file from QFileDialog.
QString video = QFileDialog::getOpenFileName(this);
Then set that string as the url of your video and remove Audio output -
@ABouncyMi then it is an error in your code.Now try to open your file from QFileDialog.
QString video = QFileDialog::getOpenFileName(this);
Then set that string as the url of your video and remove Audio output@Ronel_qtmaster said in Qt MediaPlayer doesn't play audio:
@ABouncyMi then it is an error in your code.Now try to open your file from QFileDialog.
QString video = QFileDialog::getOpenFileName(this);
Then set that string as the url of your video and remove Audio outputThanks for the code but it still doesn't play the audio. I'm beginning to think if it's a problem with windows or my audio driver.
P.S. why is it video when I am trying to play an audio? -
@Ronel_qtmaster said in Qt MediaPlayer doesn't play audio:
@ABouncyMi then it is an error in your code.Now try to open your file from QFileDialog.
QString video = QFileDialog::getOpenFileName(this);
Then set that string as the url of your video and remove Audio outputThanks for the code but it still doesn't play the audio. I'm beginning to think if it's a problem with windows or my audio driver.
P.S. why is it video when I am trying to play an audio?@ABouncyMi did you install klitecodec for audios and videos codecs?
-
@ABouncyMi did you install klitecodec for audios and videos codecs?
@Ronel_qtmaster
No, I only installed the extra Multimedia package from qt maintenance tool -
@Ronel_qtmaster
No, I only installed the extra Multimedia package from qt maintenance tool@ABouncyMi
As @Ronel_qtmaster said, I think you have to download/install any required codes, I don't think the Qt multimedia package supplies those, it expects to find them installed! -
@Ronel_qtmaster
No, I only installed the extra Multimedia package from qt maintenance tool -
@Ronel_qtmaster
Successfully installed k-lite codecs standard with default options, is there anything else I can do? There still isn't any sound -
@Ronel_qtmaster
Successfully installed k-lite codecs standard with default options, is there anything else I can do? There still isn't any sound@ABouncyMi is it at least playing? Try to create mediaplayer when a button is pressed for example, not in the constructor
-
@Ronel_qtmaster Unfortunately I can hear no sound from the application, the installation exited with no errors and I tried restarting.
I then tried using a pushbutton like this:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QFileDialog> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); screamer = new QMediaPlayer(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString video = QFileDialog::getOpenFileName(this); qDebug() << QUrl::fromLocalFile(video).toString(); screamer->setSource(QUrl::fromLocalFile(video)); screamer->play(); qDebug() << screamer->errorString(); }
No sound :(
This is surely the hardest problem I had experienced with qt -
@Ronel_qtmaster Unfortunately I can hear no sound from the application, the installation exited with no errors and I tried restarting.
I then tried using a pushbutton like this:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QFileDialog> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); screamer = new QMediaPlayer(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString video = QFileDialog::getOpenFileName(this); qDebug() << QUrl::fromLocalFile(video).toString(); screamer->setSource(QUrl::fromLocalFile(video)); screamer->play(); qDebug() << screamer->errorString(); }
No sound :(
This is surely the hardest problem I had experienced with qt@ABouncyMi could you try this?
void MainWindow::on_pushButton_clicked()
{
screamer = new QMediaPlayer(this);
QString video = QFileDialog::getOpenFileName(this);
qDebug() << QUrl::fromLocalFile(video).toString();
screamer->setSource(QUrl::fromLocalFile(video));
screamer->play();
qDebug() << screamer->errorString();
} -
@Ronel_qtmaster Unfortunately I can hear no sound from the application, the installation exited with no errors and I tried restarting.
I then tried using a pushbutton like this:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QFileDialog> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); screamer = new QMediaPlayer(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString video = QFileDialog::getOpenFileName(this); qDebug() << QUrl::fromLocalFile(video).toString(); screamer->setSource(QUrl::fromLocalFile(video)); screamer->play(); qDebug() << screamer->errorString(); }
No sound :(
This is surely the hardest problem I had experienced with qt@ABouncyMi remove screamer line in the constructor
-
One thing: QMediaPlayer is asynchronous so checking the error string right after calling play is useless.
Use the error signal and stateChanged.
-
One thing: QMediaPlayer is asynchronous so checking the error string right after calling play is useless.
Use the error signal and stateChanged.
@SGaist I tried using the https://doc.qt.io/qt-5/qmediaplayer.html#error-1 method, it gives out the error:
mainwindow.cpp:25:23: No matching function for call to 'of' qoverload.h:44:27: candidate template ignored: failed template argument deduction qoverload.h:32:27: candidate template ignored: could not match 'R (QMediaPlayer::Error)' against 'Error () const' qoverload.h:61:27: candidate template ignored: could not match 'R (*)(QMediaPlayer::Error)' against 'Error (QMediaPlayer::*)() const'
-
One thing: QMediaPlayer is asynchronous so checking the error string right after calling play is useless.
Use the error signal and stateChanged.
@SGaist I found that there isn't a stateChanged() function so I used this:
void MainWindow::on_pushButton_clicked() { screamer = new QMediaPlayer(this); QString video = QFileDialog::getOpenFileName(this); qDebug() << QUrl::fromLocalFile(video).toString(); screamer->setSource(QUrl::fromLocalFile(video)); screamer->play(); // connect(screamer, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error()), // [=](QMediaPlayer::Error error){ // qDebug() << error; // }); connect(screamer, &QMediaPlayer::playbackStateChanged, this, &MainWindow::on_playbackState_changed); qDebug() << screamer->errorString(); } void MainWindow::on_playbackState_changed() { qDebug() << screamer->errorString(); }
the output still shows a blank string ""