用于展示指定视频的方便类型。 更多...
import 语句: | import QtMultimedia |
继承: | Item |
视频
is a convenience type combining the functionality of a
MediaPlayer
和
VideoOutput
into one. It provides simple video playback functionality without having to declare multiple types.
The following is sample code to implement video playback in a scene.
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() Keys.onLeftPressed: video.seek(video.position - 5000) Keys.onRightPressed: video.seek(video.position + 5000) }
The source file,
video.avi
, plays when you click the parent of
MouseArea
. The video plays in an area of 800 by 600 pixels, and its
id
property has the value
video
.
Notice that because signals for the Keys have been defined pressing the:
Video supports un-transformed, stretched, and uniformly scaled video presentation. For a description of stretched uniformly scaled presentation, see the fillMode property description.
另请参阅 MediaPlayer and VideoOutput .
bufferProgress : real |
This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 (full).
duration : int |
This property holds the duration of the media in milliseconds.
If the media doesn't have a fixed duration (a live stream for example) this will be 0.
error : enumeration |
This property holds the error state of the video. It can be one of:
errorString : string |
This property holds a string describing the current error condition in more detail.
fillMode : enumeration |
Set this property to define how the video is scaled to fit the target area.
Because this type is for convenience in QML, it does not support enumerations directly, so enumerations from
VideoOutput
are used to access the available fill modes.
The default fill mode is preserveAspectFit.
hasAudio : bool |
This property holds whether the current media has audio content.
hasVideo : bool |
This property holds whether the current media has video content.
metaData : mediaMetaData |
This property holds the meta data for the current media.
见 MediaPlayer.metaData for details about each meta data key.
另请参阅 mediaMetaData .
muted : bool |
This property holds whether the audio output is muted.
orientation : int |
The orientation of the
视频
in degrees. Only multiples of 90 degrees is supported, that is 0, 90, 180, 270, 360, etc.
playbackRate : real |
This property holds the rate at which video is played at as a multiple of the normal rate.
playbackState : enumeration |
This read only property indicates the playback state of the media.
The default state is MediaPlayer .StoppedState.
position : int |
This property holds the current playback position in milliseconds.
To change this position, use the seek() 方法。
另请参阅 seek() .
seekable : bool |
This property holds whether the playback position of the video can be changed.
If true, calling the seek() method will cause playback to seek to the new position.
source : url |
This property holds the source URL of the media.
volume : real |
This property holds the audio volume.
The volume is scaled linearly from
0.0
(无声) 到
1.0
(full volume). Values outside this range will be clamped.
默认音量为
1.0
.
UI volume controls should usually be scaled nonlinearly. For example, using a logarithmic scale will produce linear changes in perceived loudness, which is what a user would normally expect from a volume control. See QAudio::convertVolume() 了解更多细节。
paused () |
This signal is emitted when playback is paused.
注意:
相应处理程序是
onPaused
.
playing () |
This signal is emitted when playback is started or continued.
注意:
相应处理程序是
onPlaying
.
stopped () |
This signal is emitted when playback is stopped.
注意:
相应处理程序是
onStopped
.
pause () |
Pauses playback of the media.
play () |
Starts playback of the media.
seek ( offset ) |
若 seekable property is true, seeks the current playback position to offset .
Seeking may be asynchronous, so the position property may not be updated immediately.
stop () |
Stops playback of the media.