Search code examples
qtqmlqt-quick

QT QML play Video 2 times (replay)


I would like to play my video 2 times,

When i call the function playVideo the video is play 1 time,

When the video is finish, i make my video element not visible.

Then when i come back to video, the video is not playing, the element is a big black rectangle.

How can i reset video player to play my video again ?

Video {
    id: video
    width: parent.width;
    height: parent.height;
    source: "../blow.mp4"
    z:500
    visible: false


    signal endOfMedia()

    onStatusChanged: {
        if(video.status == Video.EndOfMedia)
        {
            video.stop();
            video.visible = false
        }
    }
}

function playVideo(){
    video.visible = true
    video.play()
}

Solution

  • I've add this line and video is now playing 2 times :

    autoLoad: false