Video seek does not function
Unsolved
General and Desktop
-
Hey!
I am trying to play video and to rewind and fast forward.
I have followed the documentation of the Video object, but it does not seem to work.
For example, when I press the fast forward button, the video jumps to the beginning.What to do?
Code:
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import QtMultimedia 5.5 //Video player component Item { id: videoItem anchors.fill: parent Video{ id: video anchors.fill: parent source: xxx } //Control buttons RowLayout{ anchors.bottom: parent.bottom anchors.margins: 20 anchors.horizontalCenter: parent.horizontalCenter //Rewind to start RectangularButton{ id: rewindStartButton text: "Rewind Start" onClicked: { video.seek(0) } } //Rewind a few seconds RectangularButton{ id: slowRewindButton text: "Slow rewind" onClicked: { video.pause() video.seek(video.position - 1000) video.play() } } //Stop button RectangularButton{ id: stopButton text: "Stop" onClicked: video.stop() } //Play/pause button RectangularButton{ id: playButton text: "Play/Pause" onClicked: { video.playbackState == MediaPlayer.PlayingState ? video.pause() : video.play() } } //Slow forward RectangularButton{ id: slowForwardButton text: "Slow forward" onClicked: { video.pause() video.seek(video.position + 1000) video.play() } } //Forward to end RectangularButton{ id: forwardEndButton; text: "Forward end" onClicked: { video.seek(video.duration) } } } }
-
Hi
Which platform are you running your application on ?