Video QML Type
A convenience type for showing a specified video. More...
Import Statement: | import QtMultimedia 5.15 |
Inherits: |
Properties
- audioRole : enumeration
- autoLoad : bool
- autoPlay : bool
- availability : enumeration
- bufferProgress : real
- customAudioRole : string
- duration : int
- error : enumeration
- errorString : string
- fillMode : enumeration
- flushMode : enumeration
- hasAudio : bool
- hasVideo : bool
- loops : int
- metaData : object
- muted : bool
- notifyInterval : int
- orientation : int
- playbackRate : real
- playbackState : enumeration
- playlist : Playlist
- position : int
- seekable : bool
- source : url
- status : enumeration
- volume : real
Signals
Methods
- pause()
- play()
- seek(offset)
- stop()
- supportedAudioRoles()
Detailed Description
Video
is a convenience type combining the functionality of a MediaPlayer and a VideoOutput into one. It provides simple video playback functionality without having to declare multiple types.
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) }
Video
supports untransformed, stretched, and uniformly scaled video presentation. For a description of stretched uniformly scaled presentation, see the fillMode property description.
See also MediaPlayer and VideoOutput.
Property Documentation
audioRole : enumeration |
This property holds the role of the audio stream. It can be set to specify the type of audio being played, allowing the system to make appropriate decisions when it comes to volume, routing or post-processing.
The audio role must be set before setting the source property.
Supported values can be retrieved with supportedAudioRoles().
The value can be one of:
- MediaPlayer.UnknownRole - the role is unknown or undefined.
- MediaPlayer.MusicRole - music.
- MediaPlayer.VideoRole - soundtrack from a movie or a video.
- MediaPlayer.VoiceCommunicationRole - voice communications, such as telephony.
- MediaPlayer.AlarmRole - alarm.
- MediaPlayer.NotificationRole - notification, such as an incoming e-mail or a chat request.
- MediaPlayer.RingtoneRole - ringtone.
- MediaPlayer.AccessibilityRole - for accessibility, such as with a screen reader.
- MediaPlayer.SonificationRole - sonification, such as with user interface sounds.
- MediaPlayer.GameRole - game audio.
- MediaPlayer.CustomRole - The role is specified by customAudioRole.
customAudioRole is cleared when this property is set to anything other than CustomRole.
This property was introduced in Qt 5.6.
autoLoad : bool |
This property indicates if loading of media should begin immediately.
Defaults to true, if false media will not be loaded until playback is started.
autoPlay : bool |
This property determines whether the media should begin playback automatically.
Setting to true
also sets autoLoad to true
. The default is false
.
availability : enumeration |
Returns the availability state of the video instance.
This is one of:
Value | Description |
---|---|
MediaPlayer.Available | The video player is available to use. |
MediaPlayer.Busy | The video player is usually available, but some other process is utilizing the hardware necessary to play media. |
MediaPlayer.Unavailable | There are no supported video playback facilities. |
MediaPlayer.ResourceMissing | There is one or more resources missing, so the video player cannot be used. It may be possible to try again at a later time. |
bufferProgress : real |
This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 (full).
customAudioRole : string |
This property holds the role of the audio stream when the backend supports audio roles unknown to Qt. It can be set to specify the type of audio being played, allowing the system to make appropriate decisions when it comes to volume, routing or post-processing.
The audio role must be set before setting the source property.
audioRole is set to CustomRole when this property is set.
This property was introduced in Qt 5.11.
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:
- MediaPlayer.NoError - there is no current error.
- MediaPlayer.ResourceError - the video cannot be played due to a problem allocating resources.
- MediaPlayer.FormatError - the video format is not supported.
- MediaPlayer.NetworkError - the video cannot be played due to network issues.
- MediaPlayer.AccessDenied - the video cannot be played due to insufficient permissions.
- MediaPlayer.ServiceMissing - the video cannot be played because the media service could not be instantiated.
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.
- VideoOutput.Stretch - the video is scaled to fit
- VideoOutput.PreserveAspectFit - the video is scaled uniformly to fit without cropping
- VideoOutput.PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
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.
flushMode : enumeration |
Set this property to define what Video
should show when playback is finished or stopped.
- VideoOutput.EmptyFrame - clears video output.
- VideoOutput.FirstFrame - shows the first valid frame.
- VideoOutput.LastFrame - shows the last valid frame.
The default flush mode is EmptyFrame.
This property was introduced in Qt 5.15.
hasAudio : bool |
This property holds whether the current media has audio content.
hasVideo : bool |
This property holds whether the current media has video content.
loops : int |
This property holds the number of times the media is played. A value of 0
or 1
means the media will be played only once; set to MediaPlayer.Infinite
to enable infinite looping.
The value can be changed while the media is playing, in which case it will update the remaining loops to the new value.
The default is 1
.
This property was introduced in Qt 5.9.
This property holds the meta data for the current media.
See MediaPlayer.metaData for details about each meta data key.
See also QMediaMetaData.
muted : bool |
This property holds whether the audio output is muted.
notifyInterval : int |
The interval at which notifiable properties will update.
The notifiable properties are position and bufferProgress.
The interval is expressed in milliseconds, the default value is 1000.
This property was introduced in Qt 5.9.
orientation : int |
The orientation of the Video
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.
- MediaPlayer.PlayingState - the media is playing
- MediaPlayer.PausedState - the media is paused
- MediaPlayer.StoppedState - the media is stopped
The default state is MediaPlayer.StoppedState.
playlist : Playlist |
This property holds the playlist used by the media player.
Setting the playlist property resets the source to an empty string.
This property was introduced in Qt 5.6.
position : int |
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.
Setting the source property clears the current playlist, if any.
status : enumeration |
This property holds the status of media loading. It can be one of:
- MediaPlayer.NoMedia - no media has been set.
- MediaPlayer.Loading - the media is currently being loaded.
- MediaPlayer.Loaded - the media has been loaded.
- MediaPlayer.Buffering - the media is buffering data.
- MediaPlayer.Stalled - playback has been interrupted while the media is buffering data.
- MediaPlayer.Buffered - the media has buffered data.
- MediaPlayer.EndOfMedia - the media has played to the end.
- MediaPlayer.InvalidMedia - the media cannot be played.
- MediaPlayer.UnknownStatus - the status of the media cannot be determined.
volume : real |
This property holds the audio volume.
The volume is scaled linearly from 0.0
(silence) to 1.0
(full volume). Values outside this range will be clamped.
The default volume is 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 QtMultimedia.convertVolume() for more details.
Signal Documentation
This signal is emitted when playback is paused.
The corresponding handler is onPaused
.
Note: The corresponding handler is onPaused
.
This signal is emitted when playback is started or continued.
The corresponding handler is onPlaying
.
Note: The corresponding handler is onPlaying
.
This signal is emitted when playback is stopped.
The corresponding handler is onStopped
.
Note: The corresponding handler is onStopped
.
Method Documentation
Returns a list of supported audio roles.
If setting the audio role is not supported, an empty list is returned.
This method was introduced in Qt 5.6.
See also audioRole.