QMediaPlayer : media stays in UnknownMediaStatus

694 views Asked by At

I created a QMediaPlayer, passed video address to it and it won't play. I checked the mediaStatus and player state, they all stays 0 all the time. The basic idea is:

QMediaPlayer player = new QMediaPlayer();
cout << player.mediaStatus(); // should print 1: NoMedia but is 0: UnknownMediaStatus

player.setVideoOutput(some_constructed_video_widget);
cout << player.mediaStatus(); // should print 1: NoMedia but is 0: UnknownMediaStatus

player.setMedia(QUrl::fromLocalFile("path/to/test/video/test.mp4"));
cout << player.mediaStatus(); // should print 2: LoadingMedia but is 0: UnknownMediaStatus

player.play();
cout << player.mediaStatus(); // should print 3: LoadedMedia but is 0: UnknownMediaStatus
                              // and of course, no video gets played

The mediaStatus is simply a enum: MediaStatus { UnknownMediaStatus, NoMedia, LoadingMedia, LoadedMedia, ..., InvalidMedia }

The questions are:

  1. What may be causing this problem and how to fix that?

  2. What are all the cases that a QMediaPlayer::mediaStatus() will return an QMediaPlayer::UnknownMediaStatus (please be conclusive)?


Edit with more information: The following is the output I get for the following code. Anyone has any idea what the error message means and how to fix that?

code:

int main(int argc, char *argv[])
{
    QMediaPlayer * temp = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
    std::cout << "Constructed: " << temp->mediaStatus() << std::endl;
    temp->setMedia(QUrl::fromLocalFile("path/to/video/test.mp4"));
    std::cout << "SetMedia: " << temp->mediaStatus() << std::endl;
    temp->play();
    std::cout << "Play: " << temp->mediaStatus() << std::endl;
-> debug breakpoint here
    ......
}

output:

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
Constructed: 0
SetMedia: 0
Play: 0

I am using Mac 10.9 and Qt 5.3.0, but I do not think the mac/qt version matters for this problem.

0

There are 0 answers