Playing video is as easy as playing audio; there's a Video type that supports playing the video and displaying the video on the display. Here's a video player that plays video when you click on it, and pauses and restarts the playback when you press the spacebar:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtMultimedia 5.12
Window {
visible: true
width: 800
height: 600
title: qsTr("Play Video")
Video {
id: video
width : 800
height : 600
source: "video.avi"
MouseArea {
anchors.fill: parent
onClicked: {
video.play()
}
}
focus: true
Keys.onSpacePressed:
video.playbackState == MediaPlayer.PlayingState ?
video.pause() :
video.play()
}
}
The preceding code produces the...