Trying to play a video .... such a problem

  • Hi everybody !

    I'm trying to make a QML plugin which can play a video. So I tryed some things :

    • using Multimedia Toolkit : but I am under Windows OS (XP for developping and 7 for the execution)
    • using Qt5.0 (great job guys ;)) on 7 looks great, but it still don't work on XP. Moreover QtQuick 2.0 have change the OpenGL version ... it can't work with my app ...
    • using Phonon : it's a good widget, but when I add OpenGL, perfs are soooo bad ....
    • using QMovie : I can't open a video file format :| just images are supported ....

    So ...

    Does anybody has the same problem or a resolution of this one (like the creation of a plugin ....) ?

    Thank you guys !

  • Moderators

    You don't have to create anything. MultimediaPlayer, Audio and Video are the things ("link":

  • In fact, I have already try QT5.0 with QtQuick 2.0 .... but it isn't compatible with my app : I really need to use OpenGL as it was in the last version ...

    Moreover : this doesn't work on my Win XP ....

  • I have done this recently based on Qt4.8/QtQuick1 using the VLC libraries (QtMediaHub was a good guidance on how to do this). Note that a VLC installation on Windows already contains the required VLC-Sdk. For me this works flawlessly on an XP machine. You can take a look at my code here: This is of course work in progress...

    I tried to mimic the behavior of the MediaPlayer and VideoOutput components that are provided by QtQuick2.

    If you're buidling on a Windows machine don't forget to setup the paths to the VLC-Sdk in the file. On Linux you propably will have to install the vlc sdk separately.


  • Thank you so much mrcdrc ! This works quite well ... But I still face some problems ....

    First, the video output has to be the last thing that my QML file draw otherelse my video won't be played (qml error message : main vout display error: Failed to set on top.).

    Then, if I try to insert an Image object, my video don't play anymore ... Like a non-managed exception in qmlviewer, my app close and this qml error message : main vout display error: Failed to set on top.

    Have you ever face this bug ? And do you have any lead to resolve this problem ?

    Thank you folks !

  • Actually, the error message "main vout display error: Failed to set on top" is related to vlc. When i noticed it first, i googled a bit and found people stating that it can safely be ignored...
    Are you using QGLWidget as i proposed in the provided example code? I meanwhile changed this to be conditionally invoked only if at least OpenGL 2.1 is present, i otherwise experienced significant performance hits on an older XP machine.

    I did something like:

    if(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) {
    QGLWidget *glw = new QGLWidget;

    So far i wasn't able to reproduce your problem when placing an 'Image {...}' on top - it shows up as expected while video is playing...

    Maybe you can provide a stripped down code snipped to see if i can reproduce the problem (and possibly fix it).


  • Ok, well I made a C++ plugin which use your abstractmediaplayer, videooutput, videopresenter and your videoplayer. This plugin is a DLL file which expose my VideoPlayer and VideoOutput types.

    Then, I made a Main.qml which contains @Rectangle
    id: player
    source: "D:/Aspen.avi"
    autoPlay: true
    function togglePlayback() {
    if(!player.playing) {
    }else if(!player.paused)

        height: root.height
            width: parent.width
            height: parent.height
            fillMode: Image.PreserveAspectFit
            source: "img/toto.png"
        VideoOutput {
            id: videoOutput
            source: player
            anchors.fill: parent
            fillMode: VideoOutput.PreserveAspectFit
            smooth: true


    This main imports the VideoOutput & VideoPlayer with a qmldir. When I load an Image, my VS Just in Time debogger is warning me and asks me if I want to debug my app .... But I don't know why... When I delete the Image tag, my Video runs as I want...

    Thank you !

  • Hey guys ! I don't know what happend but my plugin works quite well ! I just add some QDebug (I think that I previously have a compilation bug ...) and now my video is playing quite well !!

    Thank you so much !

  • Hey Oliv,

    this is great news!

    I meanwhile tried your Main.qml example with my non-plugin based code and it worked as expected. No matter were i place the VideoOutput element, with or without the Image element - makes no difference. So it really might be compiler related (my builds are all based on gcc - linux&win32).


  • Erf, actually, I have a bad news...

    The video works... but just when my computer want it... So I can't tell what is my new bug... I will try to find an explanation or something...

    Thank you guys !

Log in to reply

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