QMediaPlayer Class ReferenceThe QMediaPlayer class allows the playing of a media source. More... #include <QMediaPlayer> This class is under development and is subject to change. Inherits QMediaObject. Public Types
Properties
Public Functions
Public Slots
Signals
Static Public Members
Additional Inherited Members
Detailed DescriptionThe QMediaPlayer class allows the playing of a media source. The QMediaPlayer class is a high level media playback class. It can be used to playback such content as songs, movies and internet radio. The content to playback is specified as a QMediaContent, which can be thought of as a main or canonical URL with addition information attached. When provided with a QMediaContent playback may be able to commence. player = new QMediaPlayer; connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3")); player->setVolume(50); player->play(); QVideoWidget can be used with QMediaPlayer for video rendering and QMediaPlaylist for accessing playlist functionality. player = new QMediaPlayer; playlist = new QMediaPlaylist(player); playlist->append(QUrl("http://example.com/movie1.mp4")); playlist->append(QUrl("http://example.com/movie2.mp4")); widget = new QVideoWidget(player); widget->show(); player->play(); See also QMediaObject, QMediaService, QVideoWidget, and QMediaPlaylist. Member Type Documentation
|
Constant | Value | Description |
---|---|---|
QMediaPlayer::NoError | 0 | No error has occurred. |
QMediaPlayer::ResourceError | 1 | A media resource couldn't be resolved. |
QMediaPlayer::FormatError | 2 | The format of a media resource isn't (fully) supported. Playback may still be possible, but without an audio or video component. |
QMediaPlayer::NetworkError | 3 | A network error occurred. |
QMediaPlayer::AccessDeniedError | 4 | There are not the appropriate permissions to play a media resource. |
QMediaPlayer::ServiceMissingError | 5 | A valid playback service was not found, playback cannot proceed. |
Constant | Value | Description |
---|---|---|
QMediaPlayer::LowLatency | 0x01 | The player is expected to be used with simple audio formats, but playback should start without significant delay. Such playback service can be used for beeps, ringtones, etc. |
The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.
Defines the status of a media player's current media.
Constant | Value | Description |
---|---|---|
QMediaPlayer::UnknownMediaStatus | 0 | The status of the media cannot be determined. |
QMediaPlayer::NoMedia | 1 | The is no current media. The player is in the StoppedState. |
QMediaPlayer::LoadingMedia | 2 | The current media is being loaded. The player may be in any state. |
QMediaPlayer::LoadedMedia | 3 | The current media has been loaded. The player is in the StoppedState. |
QMediaPlayer::StalledMedia | 4 | Playback of the current media has stalled due to insufficient buffering or some other temporary interruption. The player is in the PlayingState or PausedState. |
QMediaPlayer::BufferingMedia | 5 | The player is buffering data but has enough data buffered for playback to continue for the immediate future. The player is in the PlayingState or PausedState. |
QMediaPlayer::BufferedMedia | 6 | The player has fully buffered the current media. The player is in the PlayingState or PausedState. |
QMediaPlayer::EndOfMedia | 7 | Playback has reached the end of the current media. The player is in the StoppedState. |
QMediaPlayer::InvalidMedia | 8 | The current media cannot be played. The player is in the StoppedState. |
Defines the current state of a media player.
Constant | Value | Description |
---|---|---|
QMediaPlayer::PlayingState | 1 | The media player is currently playing content. |
QMediaPlayer::PausedState | 2 | The media player has paused playback, playback of the current track will resume from the position the player was paused at. |
QMediaPlayer::StoppedState | 0 | The media player is not playing content, playback will begin from the start of the current track. |
This property holds the percentage of the temporary buffer filled before playback begins.
When the player object is buffering; this property holds the percentage of the temporary buffer that is filled. The buffer will need to reach 100% filled before playback can resume, at which time the MediaStatus will be BufferedMedia.
Access functions:
int | bufferStatus () const |
Notifier signal:
void | bufferStatusChanged ( int percentFilled ) |
See also mediaStatus().
This property holds the duration of the current media.
The value is the total playback time in milliseconds of the current media. The value may change across the life time of the QMediaPlayer object and may not be available when initial playback begins, connect to the durationChanged() signal to receive status notifications.
Access functions:
qint64 | duration () const |
Notifier signal:
void | durationChanged ( qint64 duration ) |
This property holds a string describing the last error condition.
Access functions:
QString | errorString () const |
See also error().
This property holds the active media source being used by the player object.
The player object will use the QMediaContent for selection of the content to be played.
By default this property has a null QMediaContent.
Access functions:
QMediaContent | media () const |
void | setMedia ( const QMediaContent & media, QIODevice * stream = 0 ) |
Notifier signal:
void | mediaChanged ( const QMediaContent & media ) |
See also QMediaContent.
This property holds the status of the current media stream.
The stream status describes how the playback of the current stream is progressing.
By default this property is QMediaPlayer::NoMedia
Access functions:
MediaStatus | mediaStatus () const |
Notifier signal:
void | mediaStatusChanged ( QMediaPlayer::MediaStatus status ) |
See also state.
This property holds the muted state of the current media.
The value will be true if the playback volume is muted; otherwise false.
Access functions:
bool | isMuted () const |
void | setMuted ( bool muted ) |
Notifier signal:
void | mutingChanged ( bool muted ) |
This property holds the playback rate of the current media.
This value is a multiplier applied to the media's standard play rate. By default this value is 1.0, indicating that the media is playing at the standard pace. Values higher than 1.0 will increase the rate of play. Values less than zero can be set and indicate the media will rewind at the multiplier of the standard pace.
Not all playback services support change of the playback rate. It is framework defined as to the status and quality of audio and video while fast forwarding or rewinding.
Access functions:
qreal | playbackRate () const |
void | setPlaybackRate ( qreal rate ) |
Notifier signal:
void | playbackRateChanged ( qreal rate ) |
This property holds the playback position of the current media.
The value is the current playback position, expressed in milliseconds since the beginning of the media. Periodically changes in the position will be indicated with the signal positionChanged(), the interval between updates can be set with QMediaObject's method setNotifyInterval().
Access functions:
qint64 | position () const |
void | setPosition ( qint64 position ) |
Notifier signal:
void | positionChanged ( qint64 position ) |
This property holds the seek-able status of the current media.
If seeking is supported this property will be true; false otherwise. The status of this property may change across the life time of the QMediaPlayer object, use the seekableChanged signal to monitor changes.
Access functions:
bool | isSeekable () const |
Notifier signal:
void | seekableChanged ( bool seekable ) |
This property holds the media player's playback state.
By default this property is QMediaPlayer::Stopped
Access functions:
State | state () const |
Notifier signal:
void | stateChanged ( QMediaPlayer::State state ) |
See also mediaStatus(), play(), pause(), and stop().
This property holds the video availability status for the current media.
If available, the QVideoWidget class can be used to view the video. As the life time of QMediaPlayer can be longer than the playback of one QMediaContent, this property may change over time, the videoAvailabilityChanged signal can be used to monitor it's status.
Access functions:
bool | isVideoAvailable () const |
Notifier signal:
void | videoAvailabilityChanged ( bool videoAvailable ) |
See also QVideoWidget and QMediaContent.
This property holds the current playback volume.
The playback volume is a linear in effect and the value can range from 0 - 100, values outside this range will be clamped.
Access functions:
int | volume () const |
void | setVolume ( int volume ) |
Notifier signal:
void | volumeChanged ( int volume ) |
Construct a QMediaPlayer that uses the playback service from provider, parented to parent and with flags.
If a playback service is not specified the system default will be used.
Destroys the player object.
Signal the amount of the local buffer filled as a percentage by percentFilled.
Signal the duration of the content has changed to duration, expressed in milliseconds.
Returns the current error state.
Signals that an error condition has occurred.
See also errorString().
Returns the level of support a media player has for a mimeType and a set of codecs.
The flags argument allows additional requirements such as performance indicators to be specified.
Signals that the current playing content will be obtained from media.
See also media().
Signals that the status of the current media has changed.
See also mediaStatus().
Returns the stream source of media data.
This is only valid if a stream was passed to setMedia().
See also setMedia().
Signal the mute state has changed to muted.
Pause playing the current source.
Start or resume playing the current source.
Signals the playbackRate has changed to rate.
Signal the position of the content has changed to position, expressed in milliseconds.
Signals the seekable status of the player object has changed.
Signal the state of the Player object has changed.
Stop playing, and reset the play position to the beginning.
Signal the availability of visual content has changed to videoAvailable.
Signal the playback volume has changed to volume.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtmobility-1.0-tp | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com