November 2014
Beginner to intermediate
264 pages
5h 32m
English
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 Space bar:
import QtQuick 2.3
import QtMultimedia 5.0
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 Keys type emits signals for the various keys that are pressed; here, we're tying the spacePressed signal to a script that pauses and plays a video.
Most of the properties of Video are the ...
Read now
Unlock full access