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. How to use QMediaPlayer to play video ?
Forum Updated to NodeBB v4.3 + New Features

How to use QMediaPlayer to play video ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 9.3k 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.
  • F Offline
    F Offline
    foxgod
    wrote on last edited by
    #1

    i use QMediaPlayer to play a mp3,it's ok ,but when i play video in QVideoWidget,but it's no audio and video.my code is:
    player = new QMediaPlayer;
    player->setMedia(QUrl::fromLocalFile("C:\11.mp4"));

    videoWidget = new QVideoWidget;
    player->setVideoOutput(videoWidget);
    player->setVolume(50);
    videoWidget->show();
    player->play();

    but when i complie ,DirectShowPlayerService::doRender: Unresolved error code 80040266 is cued ,release or debug are all cued.

    1 Reply Last reply
    1
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Based on the filepath of your mp4 I guess that the question is related to Windows. Which version of Qt do you use?

      Most probably the issue is caused because of the codecs. Please have a look at the similar issue for "Qt 4.7.2 and Qt Mobility":https://bugreports.qt-project.org/browse/QTMOBILITY-1461 and try to apply the same solution.

      http://anavi.org/

      1 Reply Last reply
      0
      • F Offline
        F Offline
        foxgod
        wrote on last edited by
        #3

        oh ,thanks you reply my qusetion,my QT version is 5.0.2 for window(MINGW).please tell me ,QMediaPlayer can play all format's video? when i play a file of mp3,i write c:\22.mp3,so i guess filepath is right, i didn't use QMediaPlayer.so i don't know where is wrong?thank you

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          To avoid the problem of typo you could ask the user the file to open with a file open dialog. There are default dialogs (QFileDialog) for it, so should take a minimum of work. You are able to test the QMediaPlayer that way and check out if it suits your needs.
          Greetz

          Greetz, Jeroen

          1 Reply Last reply
          0
          • F Offline
            F Offline
            foxgod
            wrote on last edited by
            #5

            QMediaPlayer* player = new QMediaPlayer;
            QVideoWidget* vw = new QVideoWidget;
            player->setVideoOutput(vw);
            QFile file("test1.avi");
            if(!file.open(QIODevice::ReadOnly))
            qDebug() << "Could not open file";
            player->setMedia(QUrl::fromLocalFile("test1.avi"));
            player->play();
            vwidget->show();
            DirectShowPlayerService::doRender: Unresolved error code 80040218,i want to know wherther QMediaPlayer can play localvideo and web video in windows 7 .

            1 Reply Last reply
            1

            • Login

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