Search code examples
c++qtqtmultimedia

How to play video with qt5


I'm trying to make a simple videoplayer using qt. However, I can't get the videowidget example that comes with qt to work, instead I get an error: "The QMediaPlayer object does not have a valid service". I'm using windows vista. Can I get the videos to play normally, even if that example isn't working? Is there any other simple way to test playing videos? Or is this a problem with qt?


Solution

  • This is expected on your Vista, unfortunately. See the relevant post from the maintainer:

    On Windows XP, Qt Multimedia uses DirectShow (and WMF for Windows Vista and later). The DirectShow plugin binary is not included in the Qt 5.0 package (only the WMF plugin is). You need to compile QtMultimedia yourself, or just the DirectShow plugin in qtmultimedia/src/plugins/directshow

    ... in the following report on the Qt issue tracker:

    Qt 5.0 and QMediaPlayer failure on Windows XP

    The steps to build it on your would be:

    • grab the tarball
    • unpack it
    • move into the qtmultimedia folder
    • run qmake -r
    • (n)make
    • (n)make install

    Please make sure qmake is properly in your PATH before doing this.