简体   繁体   中英

Video plays a portion repeatedly when I implement in qml

I have a video player make in qml. Slider value is binded to Mediaplayer's position as I need to show slider moving along with the video.

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 ""

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. Is there a solution to this?

The issue is on android platform and I solved by below code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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