Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer stuck loading media

QMediaPlayer stuck loading media

Scheduled Pinned Locked Moved Unsolved General and Desktop
osxqmediaplayer
2 Posts 1 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hertzy
    wrote on 7 Mar 2016, 14:40 last edited by
    #1

    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:

    ui->videoStackedWidget->setCurrentIndex(0);
    playlist_->clear();
    playlist_->addMedia(QUrl::fromLocalFile(vidfilename));
    ui->videoWidget->show();
    playlist_->setCurrentIndex(0);
    player_->play();
    

    I connected the mediastatuschanged signal to this function:

    void ExcerciseCreationDialog::mediaStatusChanged(QMediaPlayer::MediaStatus status)
    {
        qDebug()<<"mediastatus changed"<<status<<player_->currentMedia().canonicalUrl();
    
        switch(status){
        //...
        }
    
        if(player_->error()!=QMediaPlayer::NoError){
            qDebug()<<player_->errorString();
        }
    }
    

    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?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hertzy
      wrote on 8 Mar 2016, 14:27 last edited by Hertzy 3 Aug 2016, 14:38
      #2

      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.

      1 Reply Last reply
      0

      1/2

      7 Mar 2016, 14:40

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved