简体   繁体   English

当我在qml中实现时,视频会反复播放一部分

[英]Video plays a portion repeatedly when I implement in qml

I have a video player make in qml. 我在qml中有一个视频播放器。 Slider value is binded to Mediaplayer's position as I need to show slider moving along with the video. 滑块值绑定到Mediaplayer的位置,因为我需要显示滑块与视频一起移动。

Also I need to move the video position to the slider position if slider is moved manually. 如果手动移动滑块,我还需要将视频位置移动到滑块位置。

I wrote the below code, but i get warning and video is playing each small portion repeatedly when slide bar is moved. 我写了下面的代码,但是我得到警告,并且当滑动条移动时,视频反复播放每个小部分。

warning is: qt-reserved-files/qml/QtQuick/Controls/Slider.qml:199:5: QML RangeModel: Binding loop detected for property "" 警告是: qt-reserved-files / qml / QtQuick / Controls / Slider.qml:199:5:QML RangeModel:为属性“”检测到绑定循环

MediaPlayer {
    id: idVideo
}

Slider {
    id: idSlider
    anchors.bottom: idrow.top
    anchors.right: parent.right
    anchors.rightMargin: 85
    width: 400
    value: idVideo.position // for slider to move along with movie
    minimumValue: 0
    maximumValue: idVideo.duration

    // for movie to move as slider is moved to manually.
    onValueChanged: { 
        idVideo.seek(idSlider.value)
    }
}

If I do not set onValueChanged movie will not seek as slider bar is moved. 如果我不设置onValueChanged,则电影将不会随着滑块的移动而移动。 Is there a solution to this? 有针对这个的解决方法吗?

The issue is on android platform and I solved by below code: 问题在android平台上,我通过以下代码解决了:

onPressedChanged: {
    idVideo.seek(idSlider.value)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM