MediaPlayer QML Type
Add media playback to a scene. More...
Import Statement: | import QtMultimedia 5.4 |
Properties
- autoLoad : bool
- autoPlay : bool
- availability : enumeration
- bufferProgress : real
- duration : int
- error : enumeration
- errorString : string
- hasAudio : bool
- hasVideo : bool
- loops : int
- metaData.albumArtist : variant
- metaData.albumTitle : variant
- metaData.audioBitRate : variant
- metaData.audioCodec : variant
- metaData.author : variant
- metaData.averageLevel : variant
- metaData.category : variant
- metaData.channelCount : variant
- metaData.chapterNumber : variant
- metaData.comment : variant
- metaData.composer : variant
- metaData.conductor : variant
- metaData.contributingArtist : variant
- metaData.copyright : variant
- metaData.coverArtUrlLarge : variant
- metaData.coverArtUrlSmall : variant
- metaData.date : variant
- metaData.description : variant
- metaData.director : variant
- metaData.genre : variant
- metaData.keywords : variant
- metaData.language : variant
- metaData.leadPerformer : variant
- metaData.lyrics : variant
- metaData.mediaType : variant
- metaData.mood : variant
- metaData.parentalRating : variant
- metaData.peakValue : variant
- metaData.pixelAspectRatio : variant
- metaData.posterUrl : variant
- metaData.publisher : variant
- metaData.ratingOrganization : variant
- metaData.resolution : variant
- metaData.sampleRate : variant
- metaData.size : variant
- metaData.subTitle : variant
- metaData.title : variant
- metaData.trackCount : variant
- metaData.trackNumber : variant
- metaData.userRating : variant
- metaData.videoBitRate : variant
- metaData.videoCodec : variant
- metaData.videoFrameRate : variant
- metaData.writer : variant
- metaData.year : variant
- muted : bool
- playbackRate : real
- playbackState : enumeration
- position : int
- seekable : bool
- source : url
- status : enumeration
- volume : real
Signals
- error(error, errorString)
- paused()
- playbackStateChanged()
- playing()
- stopped()
Methods
Detailed Description
MediaPlayer is part of the QtMultimedia 5.0 module.
import QtQuick 2.0 import QtMultimedia 5.0 Text { text: "Click Me!"; font.pointSize: 24; width: 150; height: 50; MediaPlayer { id: playMusic source: "music.wav" } MouseArea { id: playArea anchors.fill: parent onPressed: { playMusic.play() } } }
You can use MediaPlayer by itself to play audio content (like Audio), or you can use it in conjunction with a VideoOutput for rendering video.
import QtQuick 2.0 import QtMultimedia 5.0 Item { MediaPlayer { id: mediaplayer source: "groovy_video.mp4" } VideoOutput { anchors.fill: parent source: mediaplayer } MouseArea { id: playArea anchors.fill: parent onPressed: mediaplayer.play(); } }
See also VideoOutput.
Property Documentation
This property indicates if loading of media should begin immediately.
Defaults to true, if false media will not be loaded until playback is started.
This property controls whether the media will begin to play on start up.
Defaults to false
. If set to true
, the value of autoLoad will be overwritten to true
.
Returns the availability state of the media player.
This is one of:
Value | Description |
---|---|
Available | The media player is available to use. |
Busy | The media player is usually available, but some other process is utilizing the hardware necessary to play media. |
Unavailable | There are no supported media playback facilities. |
ResourceMissing | There is one or more resources missing, so the media player cannot be used. It may be possible to try again at a later time. |
This property holds how much of the data buffer is currently filled, from 0.0
(empty) to 1.0
(full).
Playback can start or resume only when the buffer is entirely filled, in which case the status is MediaPlayer.Buffered
or MediaPlayer.Buffering
. A value lower than 1.0
implies that the status is MediaPlayer.Stalled
.
See also status.
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.
This property holds the error state of the audio. It can be one of:
Value | Description |
---|---|
NoError | There is no current error. |
ResourceError | The audio cannot be played due to a problem allocating resources. |
FormatError | The audio format is not supported. |
NetworkError | The audio cannot be played due to network issues. |
AccessDenied | The audio cannot be played due to insufficient permissions. |
ServiceMissing | The audio cannot be played because the media service could not be instantiated. |
This property holds a string describing the current error condition in more detail.
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
.
metaData.albumArtist : variant |
This property holds the name of the principal artist of the album the media belongs to.
See also QMediaMetaData.
metaData.albumTitle : variant |
This property holds the title of the album the media belongs to.
See also QMediaMetaData.
metaData.audioBitRate : variant |
This property holds the bit rate of the media's audio stream in bits per second.
See also QMediaMetaData.
metaData.audioCodec : variant |
This property holds the encoding of the media audio stream.
See also QMediaMetaData.
metaData.author : variant |
This property holds the author of the media.
See also QMediaMetaData.
metaData.averageLevel : variant |
This property holds the average volume level of the media.
See also QMediaMetaData.
metaData.category : variant |
This property holds the category of the media
See also QMediaMetaData.
metaData.channelCount : variant |
This property holds the number of channels in the media's audio stream.
See also QMediaMetaData.
metaData.chapterNumber : variant |
This property holds the chapter number of the media.
See also QMediaMetaData.
metaData.comment : variant |
This property holds a user comment about the media.
See also QMediaMetaData.
metaData.composer : variant |
This property holds the composer of the media.
See also QMediaMetaData.
metaData.conductor : variant |
This property holds the conductor of the media.
See also QMediaMetaData.
metaData.contributingArtist : variant |
This property holds the names of artists contributing to the media.
See also QMediaMetaData.
metaData.copyright : variant |
This property holds the media's copyright notice.
See also QMediaMetaData.
metaData.coverArtUrlLarge : variant |
This property holds the URL of a large cover art image.
See also QMediaMetaData.
metaData.coverArtUrlSmall : variant |
This property holds the URL of a small cover art image.
See also QMediaMetaData.
metaData.date : variant |
This property holds the date of the media.
See also QMediaMetaData.
metaData.description : variant |
This property holds a description of the media.
See also QMediaMetaData.
metaData.director : variant |
This property holds the director of the media.
See also QMediaMetaData.
metaData.genre : variant |
This property holds the genre of the media.
See also QMediaMetaData.
metaData.keywords : variant |
This property holds a list of keywords describing the media.
See also QMediaMetaData.
metaData.language : variant |
This property holds the language of the media, as an ISO 639-2 code.
See also QMediaMetaData.
metaData.leadPerformer : variant |
This property holds the lead performer in the media.
See also QMediaMetaData.
metaData.lyrics : variant |
This property holds the lyrics to the media.
See also QMediaMetaData.
metaData.mediaType : variant |
This property holds the type of the media.
See also QMediaMetaData.
metaData.mood : variant |
This property holds the mood of the media.
See also QMediaMetaData.
metaData.parentalRating : variant |
This property holds the parental rating of the media.
See also QMediaMetaData.
metaData.peakValue : variant |
This property holds the peak volume of media's audio stream.
See also QMediaMetaData.
metaData.pixelAspectRatio : variant |
This property holds the pixel aspect ratio of an image or video.
See also QMediaMetaData.
metaData.posterUrl : variant |
This property holds the URL of a poster image.
See also QMediaMetaData.
metaData.publisher : variant |
This property holds the publisher of the media.
See also QMediaMetaData.
metaData.ratingOrganization : variant |
This property holds the name of the rating organization responsible for the parental rating of the media.
See also QMediaMetaData.
metaData.resolution : variant |
This property holds the dimension of an image or video.
See also QMediaMetaData.
metaData.sampleRate : variant |
This property holds the sample rate of the media's audio stream in hertz.
See also QMediaMetaData.
metaData.size : variant |
This property property holds the size of the media in bytes.
See also QMediaMetaData.
metaData.subTitle : variant |
This property holds the sub-title of the media.
See also QMediaMetaData.
metaData.title : variant |
This property holds the title of the media.
See also QMediaMetaData.
metaData.trackCount : variant |
This property holds the number of tracks on the album containing the media.
See also QMediaMetaData.
metaData.trackNumber : variant |
This property holds the track number of the media.
See also QMediaMetaData.
metaData.userRating : variant |
This property holds a user rating of the media in the range of 0 to 100.
See also QMediaMetaData.
metaData.videoBitRate : variant |
This property holds the bit rate of the media's video stream in bits per second.
See also QMediaMetaData.
metaData.videoCodec : variant |
This property holds the encoding of the media's video stream.
See also QMediaMetaData.
metaData.videoFrameRate : variant |
This property holds the frame rate of the media's video stream.
See also QMediaMetaData.
metaData.writer : variant |
This property holds the writer of the media.
See also QMediaMetaData.
metaData.year : variant |
This property holds the year of release of the media.
See also QMediaMetaData.
This property holds the rate at which audio is played at as a multiple of the normal rate.
Defaults to 1.0.
This property holds the state of media playback. It can be one of:
- PlayingState - the media is currently playing.
- PausedState - playback of the media has been suspended.
- StoppedState - playback of the media is yet to begin.
This property holds whether position of the audio 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.
This property holds the status of media loading. It can be one of:
- NoMedia - no media has been set.
- Loading - the media is currently being loaded.
- Loaded - the media has been loaded.
- Buffering - the media is buffering data.
- Stalled - playback has been interrupted while the media is buffering data.
- Buffered - the media has buffered data.
- EndOfMedia - the media has played to the end.
- InvalidMedia - the media cannot be played.
- UnknownStatus - the status of the media is unknown.
This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
Defaults to 1.0.
Signal Documentation
error(error, errorString) |
This signal is emitted when an error has occurred. The errorString parameter may contain more detailed information about the error.
The corresponding handler is onError
.
This signal is emitted when the playbackState property is altered.
The corresponding handler is onPlaybackStateChanged
.
This signal is emitted when playback is started or resumed.
The corresponding handler is onPlaying
.
Method Documentation
Pauses playback of the media.
Sets the playbackState property to PausedState.
Starts playback of the media.
Sets the playbackState property to PlayingState.
Stops playback of the media.
Sets the playbackState property to StoppedState.
© 2015 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.