How to use QMediaPlayer to play video ?

  • i use QMediaPlayer to play a mp3,it's ok ,but when i play video in QVideoWidget,but it's no audio and code is:
    player = new QMediaPlayer;

    videoWidget = new QVideoWidget;

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

  • 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": and try to apply the same solution.

  • 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 i don't know where is wrong?thank you

  • 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.

  • QMediaPlayer* player = new QMediaPlayer;
    QVideoWidget* vw = new QVideoWidget;
    QFile file("test1.avi");
    qDebug() << "Could not open file";
    DirectShowPlayerService::doRender: Unresolved error code 80040218,i want to know wherther QMediaPlayer can play localvideo and web video in windows 7 .

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.