Important: Please read the Qt Code of Conduct -

QMediaPlayer stuck loading media

  • I'm encountering a problem where I can't play a video, in my application, on OS X. The following code is used to load the video file, and works fine on Windows:


    I connected the mediastatuschanged signal to this function:

    void ExcerciseCreationDialog::mediaStatusChanged(QMediaPlayer::MediaStatus status)
        qDebug()<<"mediastatus changed"<<status<<player_->currentMedia().canonicalUrl();

    which outputs "mediastatus changed QMediaPlayer::LoadingMedia QUrl("<correct url to video>")". Opening the offered url in Safari plays the video without problems.

    The weirdest thing is that below the dialog that is supposed to play the video with the above code, the other window may be showing this html in QWebView:

    html=QString("<html><body><video width=\"442\" height=\"247\" controls autoplay style=\"-webkit-transform:rotate(90deg); -webkit-media-controls-fullscreen-button: display=none\">")+
                        "<source src=\""+vidUrl.toString()+"\" type=\"video/mp4\"></video></body></html>"

    Which fails to play when first loaded, but opening and closing the above mentioned dialog makes the web view play the video correctly.

    What exactly am I missing here?

  • I'm not sure what happened with the code, but now it's finally giving me an error signal. The error and error string are QMediaPlayer::FormatError "Failed to load media"

    The media I'm attempting to load uses the file ending ".mp4". I finally thought of opening the media in Quicktime and, lo and behold, it won't open the file. It appears I'm dealing with a "Not a real operating system" error.

    EDIT: It appears that what happened was that I was trying to open a 0 byte file. Opening an .mp4 file with actual content still causes the MediaPlayer to get stuck in the LoadingMedia status.

Log in to reply