开发者

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 开发者_如何学JAVAto 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()
}


I cannot test it at the moment, but maybe you just have to "rewind" the video by setting position to 0:

function playVideo() {
    video.visible = true;
    video.position = 0;  // back to start
    video.play();
}


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

autoLoad: false
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜