Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

c++ - QMediaPlayer resource error

I'm using Qt Creator 2.7.2 (Qt 5.1) on Windows 8 Pro x64. I'm having trouble with QMediaPlayer. There are some MP3 files on my PC which run fine on Windows Media Player, but QMediaPlayer can't play them. Following statement:

void MainWindow::onPlayerStateChanged(QMediaPlayer::State state)
{
    qDebug() << "onPlayerStateChanged" << state
             << media_player.error() << media_player.errorString();
    // ....
}

is the slot connected to media player's stateChanged signal throws following output:

onPlayerStateChanged QMediaPlayer::PlayingState QMediaPlayer::NoError "" 
DirectShowPlayerService::doRender: Unresolved error code 80040266
onPlayerStateChanged QMediaPlayer::StoppedState QMediaPlayer::ResourceError "" 
DirectShowPlayerService::doRender: Unresolved error code 80040266

Any idea what's wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It might have something to to with the ID3 tags of the file.

I had a similar problem: I was trying to play some MP3 files with QMediaPlayer. One of the files generated that error while the others played fine (on Windows 7). On Linux though, they all played fine.

So I ran the 'file' command on my MP3 files and noticed that the problematic MP3 file had a ID3 version 2.4.0 tag while all the others had ID3 version 2.3.0. I deleted the ID3 tag of that file completely using an ID3 tag editor and after that the file played successfully.

A wild guess here: DirectShow, which is used by QMediaPlayer as backend on Windows, chokes on ID3 version 2.4 and only recognizes older versions. And QMediaPlayer on Linux uses GStreamer as backend, which does not have that problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...