Playing video clips
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 same as of Audio
, except that there's no metaData
property. It's a subclass of Item
, so the usual positioning properties such as anchors
, x
...