Qt Multimedia QML API¶
A QML API for the Qt Multimedia module.
The Qt Multimedia module gives developers a simplified way to use audio and video playback, and access camera functionality. The Multimedia QML API provides a QML friendly interface to these features.
Audio is an easy way to add audio playback to a Qt Quick scene. Qt Multimedia provides properties for control, methods (functions) and signals.
The code extract below shows the creation and use of an Audio instance.
The snippet above shows how the inclusion of playMusic enables audio features on the type that contains it. So that when the parent’s MouseArea is clicked the
play()method of Audio is run. Other typical audio control methods are available such as
Much of the getting / setting of Audio parameters is done through properties. These include
The source URL of the media.
Indicates if loading of media should begin immediately.
Indicates that the media is playing.
The media is paused.
The status of media loading.
Amount of time in milliseconds the media will play.
Current position in the media in milliseconds of play.
Audio output volume: from 0.0 (silent) to 1.0 (maximum)
Indicates audio is muted.
Indicates how full the data buffer is: 0.0 (empty) to 1.0 (full).
Indicates whether the audio position can be changed.
The rate at which audio is played at as a multiple of the normal rate.
An error code for the error state including
A description of the current error condition.
The set of signals available allow the developer to create custom behavior when the following events occur,
Called when playback is started, or when resumed from paused state.
Called when playback is paused.
Called when playback is stopped.
Called when the specified error occurs.
Adding video playback, with sound, to a Qt Quick scene is also easy. The process is very similar to that of Audio above, in fact Video shares many of the property names, methods and signals. Here is the equivalent sample code to implement video playback in a scene
There are similar features like
play()with new features specific to video.
In the above sample when the parent of MouseArea is clicked, an area of 800x600 pixels with an id of ‘video’, the source “video.avi” will play in that area. Notice also that signals for the Keys have been defined so that a spacebar will toggle the pause button; the left arrow will move the current position in the video to 5 seconds previously; and the right arrow will advance the current position in the video by 5 seconds.
Most of the differences will obviously be about video control and information. There are many properties associated with Video , most of them deal with meta-data, control of the video media and aspects of presentation.
In the above sample the sound effect will be played when the MouseArea is clicked.
For a complete description of this type, see SoundEffect
Multimedia QML Types¶
A convenience type for showing a specified video.
Add audio playback to a scene.
Add media playback to a scene.
Access viewfinder frames, and take photos and movies.
An interface for capturing camera images.
An interface for exposure related camera settings.
An interface for flash related camera settings.
An interface for focus related camera settings.
An interface for camera capture related settings.
Controls video recording with the Camera.
Provides a global object with useful functions from Qt Multimedia.
Defines an item in a Playlist.
For specifying a list of media to be played.
Access radio functionality from a QML application.
Access RDS data from a QML application.
Simple control over torch functionality.
The SoundEffect type provides a way to play sound effects in QML.
Render video or camera viewfinder.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.