How to play a video using QML ?



  • I want to run a sample video using QML .
    When i am runnimng the following code :

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtMultimedia 5.5

    Window {
    visible: true
    width: 800
    height:600
    title: qsTr("Hello World")
    Rectangle{

    anchors.fill:parent
    width:800
    height:600
    color:"black"
    MouseArea{

     anchors.fill:parent
    

    }

     MediaPlayer {
         id: player
         source: "/video/VID_20170428_155730057.mp4"
         autoPlay: true
     }
    
     VideoOutput {
         id: videoOutput
         source: player
         anchors.fill: parent
     }
    

    }
    }

    It is displaying an error which shows:
    virtual memory exhausted: Cannot allocate memory
    make: *** [qrc_video.o] Error 1
    11:24:33: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Video_QML (kit: Desktop Qt 5.7.0 GCC 64bit)
    When executing step "Make"
    11:24:34: Elapsed time: 00:47.
    Can anyone help me how to get rid of this issue


  • Lifetime Qt Champion

    Hi,

    Did you put that video in a .qrc file ?



  • @SGaist yes !! i made a resource file and kept the video inside that in a file called videos.qrc


  • Lifetime Qt Champion

    Which size is that file ?


Log in to reply
 

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