我有一个用 qml 制作的视频播放器。滑块值绑定到 Mediaplayer 的位置,因为我需要显示滑块与视频一起移动。
如果手动移动滑块,我还需要将视频位置移动到滑块位置。
我写了下面的代码,但是当滑动条移动时,我收到警告并且视频正在重复播放每个小部分。
警告是: 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)
}
}
如果我不设置onValueChanged电影将不会在滑块移动时搜索。有针对这个的解决方法吗?