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. [SOLVED] QMediaPlayer plays local videos, but doesn't play remote videos
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QMediaPlayer plays local videos, but doesn't play remote videos

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.6k Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    QtYury
    wrote on last edited by
    #1

    Windows 7 + Qt 5.1.0 mingw
    QMediaPlayer plays local videos, but doesn't play remote videos. Local video file is the same as remote one. QMediaPlayer sets status QMediaPlayer::InvalidMedia shortly after start.
    Here is the code:
    @
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QWidget wgt;
    QMediaPlayer *mediaPlayer = new QMediaPlayer(&wgt, QMediaPlayer::StreamPlayback);
    QVideoWidget *videoWidget = new QVideoWidget(&wgt);
    
    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(videoWidget);
    
    wgt.setLayout(layout);
    
    mediaPlayer->setVideoOutput(videoWidget);
    mediaPlayer->setMedia(QUrl("http://mng.ivbn.net/mng/uploads/empty.mp4")); /* DOESN'T WORK! */
    //mediaPlayer->setMedia(QUrl::fromLocalFile("C:/Users/Yury/Downloads/empty.mp4")); /* WORKS! */
    mediaPlayer->play();
    
    wgt.resize(640, 480);
    wgt.show();
    
    return app.exec();
    

    }
    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      are you sure you have the QtNetwork module and linked against it?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtYury
        wrote on last edited by
        #3

        I have

        @
        QT += network
        @

        in my project file. To be completely sure, I've added example http://qt-project.org/doc/qt-5.1/qtnetwork/http.html to my project. The example works fine.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          QtYury
          wrote on last edited by
          #4

          I found that
          @
          mediaPlayer->currentNetworkConfiguration()
          @

          returns empty QNetworkConfiguration. My network connection is ok, and running
          @
          QNetworkConfigurationManager ncm;
          foreach (QNetworkConfiguration nc, ncm.allConfigurations(QNetworkConfiguration::Active))
          {
          qDebug() << nc.name() << nc.identifier();
          }
          @

          gives me two active connections. But trying to set this active connections to my mediaPlayer fails:
          @
          mediaPlayer->setNetworkConfigurations(ncm.allConfigurations(QNetworkConfiguration::Active));
          qDebug() << mediaPlayer->currentNetworkConfiguration().identifier(); // empty string!
          @

          The documentation of QMediaPlayer states:
          "QNetworkConfiguration QMediaPlayer::currentNetworkConfiguration() const

          Returns the current network access point in use. If a default contructed QNetworkConfiguration is returned this feature is not available or that none of the current supplied configurations are in use."

          So, I have two possible reasons of my problem.

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QtYury
            wrote on last edited by
            #5

            I tried to play different file formats - mov and ts. It works! Perhaps the problem is related to the codecs in my system.
            It takes a lot of time before the video starts, but that's another story )

            SOLVED!

            1 Reply Last reply
            0

            • Login

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