I am a student writing a project using Qt. I need to play an audio file when the button is pushed, so I write the code:
void DrumsWindow::on_pushButton_dHH_clicked()
{
m_player = new QMediaPlayer(this);
m_playlist = new QMediaPlaylist(m_player);
m_player->setPlaylist(m_playlist);
m_playlist->addMedia(QUrl::fromLocalFile("sound/HH.wav"));
m_player->play();
}
But when I hit the pushbutton, it doesn't work, an error occures:
DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80040216 ()
Please, help me! What am I doing wrong?
P.S.: I was told to do the task without using resource files. Of course, this code works:
void DrumsWindow::on_pushButton_dHH_clicked()
{
m_player = new QMediaPlayer(this);
m_playlist = new QMediaPlaylist(m_player);
m_player->setPlaylist(m_playlist);
m_playlist->addMedia(QUrl("qrc:/aud/sound/HH.wav"));
m_player->play();
}
But I'm not allowed to use this way.
question from:
https://stackoverflow.com/questions/65886167/how-to-solve-qt-unresolved-error-code-0x80040216 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…