<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qml-multimedia.qdoc --> <title>Qt Multimedia QML API | Qt Multimedia 5.12.2</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtmultimedia-index.html">Qt Multimedia</a></td><td >Qt Multimedia QML API</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtmultimedia-index.html">Qt 5.12.2 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#overview">Overview</a></li> <li class="level1"><a href="#types">Types</a></li> <li class="level2"><a href="#audio">Audio</a></li> <li class="level2"><a href="#camera">Camera</a></li> <li class="level2"><a href="#video">Video</a></li> <li class="level2"><a href="#soundeffect">SoundEffect</a></li> <li class="level1"><a href="#multimedia-qml-types">Multimedia QML Types</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">Qt Multimedia QML API</h1> <span class="subtitle"></span> <!-- $$$qml-multimedia.html-description --> <div class="descr"> <a name="details"></a> <a name="overview"></a> <h2 id="overview">Overview</h2> <p>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.</p> <a name="types"></a> <h2 id="types">Types</h2> <a name="audio"></a> <h3 >Audio</h3> <p><a href="qml-multimedia.html#audio">Audio</a> is an easy way to add audio playback to a Qt Quick scene. Qt Multimedia provides properties for control, methods (functions) and signals.</p> <p>The code extract below shows the creation and use of an Audio instance.</p> <pre class="qml"> </pre> <p>The snippet above shows how the inclusion of <i>playMusic</i> enables audio features on the type that contains it. So that when the parent's MouseArea is clicked the <a href="qml-qtmultimedia-audio.html#play-method">play()</a> method of Audio is run. Other typical audio control methods are available such as <a href="qml-qtmultimedia-audio.html#pause-method">pause()</a> and <a href="qml-qtmultimedia-audio.html#stop-method">stop()</a>.</p> <p>Much of the getting / setting of <a href="qml-multimedia.html#audio">Audio</a> parameters is done through properties. These include</p> <div class="table"><table class="generic" width="70%"> <thead><tr class="qt-style"><th >Property</th><th >Description</th></tr></thead> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#source-prop">source</a></td><td >The source URL of the media.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#autoLoad-prop">autoLoad</a></td><td >Indicates if loading of media should begin immediately.</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#playing-signal">playing</a></td><td >Indicates that the media is playing.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#paused-signal">paused</a></td><td >The media is paused.</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#status-prop">status</a></td><td >The status of media loading.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#duration-prop">duration</a></td><td >Amount of time in milliseconds the media will play.</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#position-prop">position</a></td><td >Current position in the media in milliseconds of play.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#volume-prop">volume</a></td><td >Audio output volume: from 0.0 (silent) to 1.0 (maximum)</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#muted-prop">muted</a></td><td >Indicates audio is muted.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#bufferProgress-prop">bufferProgress</a></td><td >Indicates how full the data buffer is: 0.0 (empty) to 1.0 (full).</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#seekable-prop">seekable</a></td><td >Indicates whether the audio position can be changed.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#playbackRate-prop">playbackRate</a></td><td >The rate at which audio is played at as a multiple of the normal rate.</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#error-prop">error</a></td><td >An error code for the error state including NoError</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#errorString-prop">errorString</a></td><td >A description of the current error condition.</td></tr> </table></div> <p>The set of signals available allow the developer to create custom behavior when the following events occur,</p> <div class="table"><table class="generic" width="70%"> <thead><tr class="qt-style"><th >Signal</th><th >Description</th></tr></thead> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#playing-signal">playing</a></td><td >Called when playback is started, or when resumed from paused state.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#paused-signal">paused</a></td><td >Called when playback is paused.</td></tr> <tr valign="top" class="odd"><td ><a href="qml-qtmultimedia-audio.html#stopped-signal">stopped</a></td><td >Called when playback is stopped.</td></tr> <tr valign="top" class="even"><td ><a href="qml-qtmultimedia-audio.html#error-prop">error</a></td><td >Called when the specified error occurs.</td></tr> </table></div> <a name="camera"></a> <h3 >Camera</h3> <p><a href="qml-multimedia.html#camera">Camera</a> enables still image and video capture using QML. It has a number of properties that help setting it up.</p> <p>The details of using a <a href="qml-multimedia.html#camera">Camera</a> are described in further depth in the <a href="cameraoverview.html">Camera Overview</a> and in the corresponding reference documentation.</p> <a name="video"></a> <h3 >Video</h3> <p>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 <a href="qml-multimedia.html#video">Video</a> shares many of the property names, methods and signals. Here is the equivalent sample code to implement video playback in a scene</p> <pre class="qml"> </pre> <p>There are similar features like play() with new features specific to video.</p> <p>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.</p> <p>Most of the differences will obviously be about video control and information. There are many properties associated with <a href="qml-multimedia.html#video">Video</a>, most of them deal with meta-data, control of the video media and aspects of presentation.</p> <a name="soundeffect"></a> <h3 >SoundEffect</h3> <p><a href="qml-multimedia.html#soundeffect">SoundEffect</a> provides a way to play short sound effects, like in video games. Multiple sound effect instances can be played simultaneously. You should use <a href="qml-multimedia.html#audio">Audio</a> for music playback.</p> <pre class="qml"> </pre> <p>In the above sample the sound effect will be played when the MouseArea is clicked.</p> <p>For a complete description of this type, see <a href="qml-multimedia.html#soundeffect">SoundEffect</a></p> <a name="multimedia-qml-types"></a> <h2 id="multimedia-qml-types">Multimedia QML Types</h2> <div class="table"><table class="annotated"> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-audio.html">Audio</a></p></td><td class="tblDescr"><p>Add audio playback to a scene</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-camera.html">Camera</a></p></td><td class="tblDescr"><p>Access viewfinder frames, and take photos and movies</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-cameracapture.html">CameraCapture</a></p></td><td class="tblDescr"><p>An interface for capturing camera images</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-cameraexposure.html">CameraExposure</a></p></td><td class="tblDescr"><p>An interface for exposure related camera settings</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-cameraflash.html">CameraFlash</a></p></td><td class="tblDescr"><p>An interface for flash related camera settings</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-camerafocus.html">CameraFocus</a></p></td><td class="tblDescr"><p>An interface for focus related camera settings</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-cameraimageprocessing.html">CameraImageProcessing</a></p></td><td class="tblDescr"><p>An interface for camera capture related settings</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-camerarecorder.html">CameraRecorder</a></p></td><td class="tblDescr"><p>Controls video recording with the Camera</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-mediaplayer.html">MediaPlayer</a></p></td><td class="tblDescr"><p>Add media playback to a scene</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-playlist.html">Playlist</a></p></td><td class="tblDescr"><p>For specifying a list of media to be played</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-playlistitem.html">PlaylistItem</a></p></td><td class="tblDescr"><p>Defines an item in a Playlist</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-qtmultimedia.html">QtMultimedia</a></p></td><td class="tblDescr"><p>Provides a global object with useful functions from Qt Multimedia</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-radio.html">Radio</a></p></td><td class="tblDescr"><p>Access radio functionality from a QML application</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-radiodata.html">RadioData</a></p></td><td class="tblDescr"><p>Access RDS data from a QML application</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-soundeffect.html">SoundEffect</a></p></td><td class="tblDescr"><p>Type provides a way to play sound effects in QML</p></td></tr> <tr class="even topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-torch.html">Torch</a></p></td><td class="tblDescr"><p>Simple control over torch functionality</p></td></tr> <tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtmultimedia-videooutput.html">VideoOutput</a></p></td><td class="tblDescr"><p>Render video or camera viewfinder</p></td></tr> </table></div> </div> <!-- @@@qml-multimedia.html --> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> 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. </p> </div> </body> </html>