![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QMediaPlayer class allows the playing of a media files. More...
#include <qmediaplayer.h>
Public Types | |
enum | PlaybackState { StoppedState , PlayingState , PausedState } |
Defines the current state of a media player. More... | |
enum | MediaStatus { NoMedia , LoadingMedia , LoadedMedia , StalledMedia , BufferingMedia , BufferedMedia , EndOfMedia , InvalidMedia } |
\qmlproperty enumeration QtMultimedia::MediaPlayer::playbackState More... | |
enum | Error { NoError , ResourceError , FormatError , NetworkError , AccessDeniedError } |
\qmlproperty enumeration QtMultimedia::MediaPlayer::mediaStatus More... | |
enum | Loops { Infinite = -1 , Once = 1 } |
Some predefined constants for the \l loops property. More... | |
enum class | PitchCompensationAvailability { AlwaysOn , Available , Unavailable } |
Public Slots | |
void | play () |
\qmlmethod QtMultimedia::MediaPlayer::play() | |
void | pause () |
\qmlmethod QtMultimedia::MediaPlayer::pause() | |
void | stop () |
\qmlmethod QtMultimedia::MediaPlayer::stop() | |
void | setPosition (qint64 position) |
void | setPlaybackRate (qreal rate) |
void | setSource (const QUrl &source) |
\qmlproperty url QtMultimedia::MediaPlayer::source | |
void | setSourceDevice (QIODevice *device, const QUrl &sourceUrl=QUrl()) |
Sets the current source device. | |
void | setPitchCompensation (bool) const |
Sets the state (enabled or disabled) of pitch compensation. | |
void | setPlaybackOptions (const QPlaybackOptions &options) |
void | resetPlaybackOptions () |
Public Slots inherited from QObject | |
void | deleteLater () |
\threadsafe |
Signals | |
void | sourceChanged (const QUrl &media) |
Signals that the media source has been changed to media. | |
void | playbackStateChanged (QMediaPlayer::PlaybackState newState) |
void | mediaStatusChanged (QMediaPlayer::MediaStatus status) |
Signals that the status of the current media has changed. | |
void | durationChanged (qint64 duration) |
Signals the duration of the content has changed to duration, expressed in milliseconds. | |
void | positionChanged (qint64 position) |
Signals the position of the content has changed to position, expressed in milliseconds. | |
void | hasAudioChanged (bool available) |
Signals the availability of audio content has changed to available. | |
void | hasVideoChanged (bool videoAvailable) |
Signals the availability of visual content has changed to videoAvailable. | |
void | bufferProgressChanged (float progress) |
Signals the amount of the local buffer filled as a number between 0 and 1. | |
void | seekableChanged (bool seekable) |
Signals the seekable status of the player object has changed. | |
void | playingChanged (bool playing) |
void | playbackRateChanged (qreal rate) |
Signals the playbackRate has changed to rate. | |
void | loopsChanged () |
void | metaDataChanged () |
void | videoOutputChanged () |
void | audioOutputChanged () |
Q_REVISION (6, 8) void audioBufferOutputChanged() | |
void | tracksChanged () |
void | activeTracksChanged () |
void | errorChanged () |
void | errorOccurred (QMediaPlayer::Error error, const QString &errorString) |
\qmlsignal QtMultimedia::MediaPlayer::errorOccurred(error, errorString) | |
void | pitchCompensationChanged (bool) |
void | playbackOptionsChanged () |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. |
Public Member Functions | |
QMediaPlayer (QObject *parent=nullptr) | |
Constructs a QMediaPlayer instance as a child of {parent}. | |
~QMediaPlayer () override | |
Destroys the player object. | |
QList< QMediaMetaData > | audioTracks () const |
QList< QMediaMetaData > | videoTracks () const |
QList< QMediaMetaData > | subtitleTracks () const |
int | activeAudioTrack () const |
int | activeVideoTrack () const |
int | activeSubtitleTrack () const |
void | setActiveAudioTrack (int index) |
void | setActiveVideoTrack (int index) |
void | setActiveSubtitleTrack (int index) |
void | setAudioBufferOutput (QAudioBufferOutput *output) |
QAudioBufferOutput * | audioBufferOutput () const |
void | setAudioOutput (QAudioOutput *output) |
QAudioOutput * | audioOutput () const |
void | setVideoOutput (QObject *) |
QObject * | videoOutput () const |
void | setVideoSink (QVideoSink *sink) |
Sets sink to be the QVideoSink instance to retrieve video data. | |
QVideoSink * | videoSink () const |
Returns the QVideoSink instance. | |
QUrl | source () const |
const QIODevice * | sourceDevice () const |
Returns the stream source of media data. | |
PlaybackState | playbackState () const |
MediaStatus | mediaStatus () const |
qint64 | duration () const |
Returns the duration of the current media in ms. | |
qint64 | position () const |
Returns the current position inside the media being played back in ms. | |
bool | hasAudio () const |
bool | hasVideo () const |
float | bufferProgress () const |
Returns a number between 0 and 1 when buffering data. | |
QMediaTimeRange | bufferedTimeRange () const |
Returns a QMediaTimeRange describing the currently buffered data. | |
bool | isSeekable () const |
Returns true if the media is seekable. | |
qreal | playbackRate () const |
Returns the current playback rate. | |
bool | isPlaying () const |
int | loops () const |
\qmlproperty int QtMultimedia::MediaPlayer::loops | |
void | setLoops (int loops) |
Error | error () const |
Returns the current error state. | |
QString | errorString () const |
bool | isAvailable () const |
Returns true if the media player is supported on this platform. | |
QMediaMetaData | metaData () const |
PitchCompensationAvailability | pitchCompensationAvailability () const |
\qmlproperty enumeration QtMultimedia::MediaPlayer::pitchCompensationAvailability | |
bool | pitchCompensation () const |
Returns the state of pitch compensation. | |
QPlaybackOptions | playbackOptions () const |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | isQmlObjectType () const |
Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership(). | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
void | killTimer (Qt::TimerId id) |
template<typename T> | |
T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T> | |
QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T> | |
T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T> | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . |
Properties | |
QUrl | source |
the active media source being used by the player object. | |
qint64 | duration |
\qmlproperty int QtMultimedia::MediaPlayer::duration | |
qint64 | position |
\qmlproperty int QtMultimedia::MediaPlayer::position | |
float | bufferProgress |
\qmlproperty real QtMultimedia::MediaPlayer::bufferProgress | |
bool | hasAudio |
\qmlproperty bool QtMultimedia::MediaPlayer::hasAudio | |
bool | hasVideo |
\qmlproperty bool QtMultimedia::MediaPlayer::hasVideo | |
bool | seekable |
\qmlproperty bool QtMultimedia::MediaPlayer::seekable | |
bool | playing |
\qmlproperty bool QtMultimedia::MediaPlayer::playing | |
qreal | playbackRate |
\qmlproperty real QtMultimedia::MediaPlayer::playbackRate | |
int | loops |
Determines how often the media is played before the player stops. | |
PlaybackState | playbackState |
Returns the \l{QMediaPlayer::}{PlaybackState}. | |
MediaStatus | mediaStatus |
the status of the current media stream. | |
QMediaMetaData | metaData |
\qmlproperty mediaMetaData QtMultimedia::MediaPlayer::metaData | |
Error | error |
a string describing the last error condition. | |
QString | errorString |
\qmlproperty string QtMultimedia::MediaPlayer::errorString | |
QObject * | videoOutput |
\qmlproperty VideoOutput QtMultimedia::MediaPlayer::videoOutput | |
QAudioOutput * | audioOutput |
\qmlproperty AudioOutput QtMultimedia::MediaPlayer::audioOutput | |
QAudioBufferOutput * | audioBufferOutput |
\qmlproperty QAudioBufferOutput QtMultimedia::MediaPlayer::audioBufferOutput | |
QList< QMediaMetaData > | audioTracks |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::audioTracks | |
QList< QMediaMetaData > | videoTracks |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::videoTracks | |
QList< QMediaMetaData > | subtitleTracks |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::subtitleTracks | |
int | activeAudioTrack |
\qmlproperty int QtMultimedia::MediaPlayer::activeAudioTrack | |
int | activeVideoTrack |
Returns the currently active video track. | |
int | activeSubtitleTrack |
Returns the currently active subtitle track. | |
PitchCompensationAvailability pitchCompensationAvailability READ pitchCompensationAvailability CONSTANT Q_PROPERTYbool | pitchCompensation |
\qmlproperty bool QtMultimedia::MediaPlayer::pitchCompensation | |
QPlaybackOptions | playbackOptions |
\qmlproperty playbackOptions MediaPlayer::playbackOptions | |
Properties inherited from QObject | |
QString | objectName |
the name of this object |
Friends | |
class | QPlatformMediaPlayer |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1, typename Func2> | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1, typename Func2> | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1, typename Func2> | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1> | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Protected Attributes inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Related Symbols inherited from QObject | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) |
The QMediaPlayer class allows the playing of a media files.
\inmodule QtMultimedia
The QMediaPlayer class is a high level media playback class. It can be used to playback audio of video media files. The content to playback is specified as a QUrl object.
QVideoWidget can be used with QMediaPlayer for video rendering.
Definition at line 23 of file qmediaplayer.h.
enum QMediaPlayer::Error |
\qmlproperty enumeration QtMultimedia::MediaPlayer::mediaStatus
This property holds the status of media loading. It can be one of the following:
\table \header
\qmlproperty enumeration QtMultimedia::MediaPlayer::error
This property holds the error state of the audio. It can be one of the following.
\table \header
Defines a media player error condition.
\value NoError No error has occurred. \value ResourceError A media resource couldn't be resolved. \value FormatError The format of a media resource isn't (fully) supported. Playback may still be possible, but without an audio or video component. \value NetworkError A network error occurred. \value AccessDeniedError There are not the appropriate permissions to play a media resource.
Enumerator | |
---|---|
NoError | |
ResourceError | |
FormatError | |
NetworkError | |
AccessDeniedError |
Definition at line 92 of file qmediaplayer.h.
enum QMediaPlayer::Loops |
Some predefined constants for the \l loops property.
\value Infinite Loop forever. \value Once Play the media once (the default).
Enumerator | |
---|---|
Infinite | |
Once |
Definition at line 102 of file qmediaplayer.h.
\qmlproperty enumeration QtMultimedia::MediaPlayer::playbackState
This property holds the state of media playback. It can be one of the following:
\table \header
\qmlsignal QtMultimedia::MediaPlayer::playbackStateChanged()
This signal is emitted when the \l playbackState property is altered.
\qmlsignal QtMultimedia::MediaPlayer::playingChanged()
This signal is emitted when the \l playing property changes.
Defines the status of a media player's current media.
\value NoMedia The is no current media. The player is in the StoppedState. \value LoadingMedia The current media is being loaded. The player may be in any state. \value LoadedMedia The current media has been loaded. The player is in the StoppedState. \value StalledMedia Playback of the current media has stalled due to insufficient buffering or some other temporary interruption. The player is in the PlayingState or PausedState. \value BufferingMedia 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. \value BufferedMedia The player has fully buffered the current media. The player is in the PlayingState or PausedState. \value EndOfMedia Playback has reached the end of the current media. The player is in the StoppedState. \value InvalidMedia The current media cannot be played. The player is in the StoppedState.
Enumerator | |
---|---|
NoMedia | |
LoadingMedia | |
LoadedMedia | |
StalledMedia | |
BufferingMedia | |
BufferedMedia | |
EndOfMedia | |
InvalidMedia |
Definition at line 79 of file qmediaplayer.h.
|
strong |
Availablility of pitch compensation.
Different backends have different behavior regarding pitch compensation when changing playback rate.
\value AlwaysOn The media player is always performing pitch compensation. \value Available The media player can be configured to use pitch compensation. If pitch compensation is available on the current platform, it will be enabled by default, but users can disable if needed. \value Unavailable The media player is not able to perform pitch compensation on the current platform.
Enumerator | |
---|---|
AlwaysOn | |
Available | |
Unavailable |
Definition at line 109 of file qmediaplayer.h.
Defines the current state of a media player.
\value StoppedState The media player is not playing content, playback will begin from the start of the current track. \value PlayingState The media player is currently playing content. This indicates the same as the \l playing property. \value PausedState The media player has paused playback, playback of the current track will resume from the position the player was paused at.
Enumerator | |
---|---|
StoppedState | |
PlayingState | |
PausedState |
Definition at line 71 of file qmediaplayer.h.
|
explicit |
Constructs a QMediaPlayer instance as a child of {parent}.
Definition at line 247 of file qmediaplayer.cpp.
|
override |
Destroys the player object.
Definition at line 267 of file qmediaplayer.cpp.
int QMediaPlayer::activeAudioTrack | ( | ) | const |
Definition at line 898 of file qmediaplayer.cpp.
int QMediaPlayer::activeSubtitleTrack | ( | ) | const |
Definition at line 946 of file qmediaplayer.cpp.
|
signal |
int QMediaPlayer::activeVideoTrack | ( | ) | const |
Definition at line 922 of file qmediaplayer.cpp.
QAudioBufferOutput * QMediaPlayer::audioBufferOutput | ( | ) | const |
Definition at line 750 of file qmediaplayer.cpp.
QAudioOutput * QMediaPlayer::audioOutput | ( | ) | const |
Definition at line 794 of file qmediaplayer.cpp.
|
signal |
QList< QMediaMetaData > QMediaPlayer::audioTracks | ( | ) | const |
Definition at line 823 of file qmediaplayer.cpp.
QMediaTimeRange QMediaPlayer::bufferedTimeRange | ( | ) | const |
Returns a QMediaTimeRange describing the currently buffered data.
When streaming media from a remote source, different parts of the media file can be available locally. The returned QMediaTimeRange object describes the time ranges that are buffered and available for immediate playback.
Definition at line 387 of file qmediaplayer.cpp.
float QMediaPlayer::bufferProgress | ( | ) | const |
Returns a number between 0 and 1 when buffering data.
0 means that there is no buffered data available, playback is usually stalled in this case. Playback will resume once the buffer reaches 1, meaning enough data has been buffered to be able to resume playback.
bufferProgress() will always return 1 for local files.
Definition at line 372 of file qmediaplayer.cpp.
|
signal |
Signals the amount of the local buffer filled as a number between 0 and 1.
qint64 QMediaPlayer::duration | ( | ) | const |
Returns the duration of the current media in ms.
Returns 0 if the media player doesn't have a valid media file or stream. For live streams, the duration usually changes during playback as more data becomes available.
Definition at line 344 of file qmediaplayer.cpp.
Signals the duration of the content has changed to duration, expressed in milliseconds.
QMediaPlayer::Error QMediaPlayer::error | ( | ) | const |
Returns the current error state.
Definition at line 496 of file qmediaplayer.cpp.
|
signal |
|
signal |
\qmlsignal QtMultimedia::MediaPlayer::errorOccurred(error, errorString)
This signal is emitted when an error has occurred. The errorString parameter may contain more detailed information about the error.
Signals that an error condition has occurred, with errorString containing a description of the error.
QString QMediaPlayer::errorString | ( | ) | const |
Definition at line 513 of file qmediaplayer.cpp.
bool QMediaPlayer::hasAudio | ( | ) | const |
Definition at line 403 of file qmediaplayer.cpp.
|
signal |
Signals the availability of audio content has changed to available.
bool QMediaPlayer::hasVideo | ( | ) | const |
Definition at line 419 of file qmediaplayer.cpp.
|
signal |
Signals the availability of visual content has changed to videoAvailable.
bool QMediaPlayer::isAvailable | ( | ) | const |
Returns true if the media player is supported on this platform.
Definition at line 1066 of file qmediaplayer.cpp.
bool QMediaPlayer::isPlaying | ( | ) | const |
Definition at line 437 of file qmediaplayer.cpp.
bool QMediaPlayer::isSeekable | ( | ) | const |
Returns true if the media is seekable.
Most file based media files are seekable, but live streams usually are not.
Definition at line 431 of file qmediaplayer.cpp.
int QMediaPlayer::loops | ( | ) | const |
\qmlproperty int QtMultimedia::MediaPlayer::loops
Determines how often the media is played before the player stops. Set to MediaPlayer::Infinite to loop the current media file forever.
The default value is 1
. Setting this property to 0
has no effect.
Definition at line 478 of file qmediaplayer.cpp.
|
signal |
QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus | ( | ) | const |
Definition at line 331 of file qmediaplayer.cpp.
|
signal |
Signals that the status of the current media has changed.
QMediaMetaData QMediaPlayer::metaData | ( | ) | const |
Definition at line 1093 of file qmediaplayer.cpp.
|
signal |
|
slot |
\qmlmethod QtMultimedia::MediaPlayer::pause()
Pauses playback of the media.
Sets the \l playbackState property to PausedState, and changes \l playing to false
.
Pause playing the current source.
Definition at line 556 of file qmediaplayer.cpp.
bool QMediaPlayer::pitchCompensation | ( | ) | const |
Returns the state of pitch compensation.
Definition at line 1123 of file qmediaplayer.cpp.
QMediaPlayer::PitchCompensationAvailability QMediaPlayer::pitchCompensationAvailability | ( | ) | const |
\qmlproperty enumeration QtMultimedia::MediaPlayer::pitchCompensationAvailability
Returns availability of pitch compensation of the current backend.
Indicates the availability of pitch compensation of the MediaPlayer
on the current backend. The enumeration PitchCompensationAvailability
is scoped.
\qmlenumeratorsfrom QMediaPlayer::PitchCompensationAvailability
The pitch compensation availability of the current QtMultimedia backend.
Indicates the availability of pitch compensation of the QMediaPlayer on the current backend.
For more information, see \l{QMediaPlayer::PitchCompensationAvailability}.
Definition at line 1186 of file qmediaplayer.cpp.
|
signal |
|
slot |
\qmlmethod QtMultimedia::MediaPlayer::play()
Starts or resumes playback of the media.
Sets the \l playbackState property to PlayingState, and changes \l playing to true
.
Start or resume playing the current source.
Definition at line 532 of file qmediaplayer.cpp.
QPlaybackOptions QMediaPlayer::playbackOptions | ( | ) | const |
Definition at line 1217 of file qmediaplayer.cpp.
|
signal |
qreal QMediaPlayer::playbackRate | ( | ) | const |
Returns the current playback rate.
Definition at line 446 of file qmediaplayer.cpp.
Signals the playbackRate has changed to rate.
QMediaPlayer::PlaybackState QMediaPlayer::playbackState | ( | ) | const |
Definition at line 316 of file qmediaplayer.cpp.
|
signal |
|
signal |
qint64 QMediaPlayer::position | ( | ) | const |
Returns the current position inside the media being played back in ms.
Returns 0 if the media player doesn't have a valid media file or stream. For live streams, the duration usually changes during playback as more data becomes available.
Definition at line 357 of file qmediaplayer.cpp.
Signals the position of the content has changed to position, expressed in milliseconds.
|
signal |
|
slot |
Definition at line 1230 of file qmediaplayer.cpp.
|
signal |
Signals the seekable status of the player object has changed.
void QMediaPlayer::setActiveAudioTrack | ( | int | index | ) |
Definition at line 952 of file qmediaplayer.cpp.
void QMediaPlayer::setActiveSubtitleTrack | ( | int | index | ) |
Definition at line 974 of file qmediaplayer.cpp.
void QMediaPlayer::setActiveVideoTrack | ( | int | index | ) |
Definition at line 963 of file qmediaplayer.cpp.
void QMediaPlayer::setAudioBufferOutput | ( | QAudioBufferOutput * | output | ) |
Definition at line 728 of file qmediaplayer.cpp.
void QMediaPlayer::setAudioOutput | ( | QAudioOutput * | output | ) |
Definition at line 775 of file qmediaplayer.cpp.
void QMediaPlayer::setLoops | ( | int | loops | ) |
Definition at line 484 of file qmediaplayer.cpp.
|
slot |
Sets the state (enabled or disabled) of pitch compensation.
This only has an effect if the audio pitch compensation can be configured on the backend at runtime.
Definition at line 1135 of file qmediaplayer.cpp.
|
slot |
Definition at line 1223 of file qmediaplayer.cpp.
Definition at line 597 of file qmediaplayer.cpp.
Definition at line 586 of file qmediaplayer.cpp.
\qmlproperty url QtMultimedia::MediaPlayer::source
This property holds the source URL of the media.
Sets the current source.
Setting the media to a null QUrl will cause the player to discard all information relating to the current media source and to cease all I/O operations related to that media. Setting the media will stop the playback.
Definition at line 634 of file qmediaplayer.cpp.
Sets the current source device.
The media data will be read from device. The sourceUrl can be provided to resolve additional information about the media, mime type etc. The device must be open and readable.
For macOS the device should also be seek-able.
Definition at line 663 of file qmediaplayer.cpp.
Definition at line 1010 of file qmediaplayer.cpp.
void QMediaPlayer::setVideoSink | ( | QVideoSink * | sink | ) |
Sets sink to be the QVideoSink instance to retrieve video data.
Definition at line 1029 of file qmediaplayer.cpp.
QUrl QMediaPlayer::source | ( | ) | const |
Definition at line 287 of file qmediaplayer.cpp.
Signals that the media source has been changed to media.
const QIODevice * QMediaPlayer::sourceDevice | ( | ) | const |
Returns the stream source of media data.
This is only valid if a stream was passed to setSource().
Definition at line 302 of file qmediaplayer.cpp.
|
slot |
\qmlmethod QtMultimedia::MediaPlayer::stop()
Stops playback of the media.
Sets the \l playbackState property to StoppedState, and changes \l playing to false
.
Stop playing, and reset the play position to the beginning.
Definition at line 578 of file qmediaplayer.cpp.
QList< QMediaMetaData > QMediaPlayer::subtitleTracks | ( | ) | const |
Definition at line 875 of file qmediaplayer.cpp.
|
signal |
QObject * QMediaPlayer::videoOutput | ( | ) | const |
Definition at line 1004 of file qmediaplayer.cpp.
|
signal |
QVideoSink * QMediaPlayer::videoSink | ( | ) | const |
Returns the QVideoSink instance.
Definition at line 1039 of file qmediaplayer.cpp.
QList< QMediaMetaData > QMediaPlayer::videoTracks | ( | ) | const |
Definition at line 848 of file qmediaplayer.cpp.
|
friend |
Definition at line 233 of file qmediaplayer.h.
|
readwrite |
\qmlproperty int QtMultimedia::MediaPlayer::activeAudioTrack
This property holds the track number of the currently active audio track. Set to {-1} to disable audio track.
The default property value is {0}: the first audio track.
Returns the currently active audio track.
By default, the first available audio track will be chosen.
Set index to -1
to disable all audio tracks.
Definition at line 51 of file qmediaplayer.h.
|
readwrite |
Returns the currently active subtitle track.
This property holds the track number of the currently active subtitle track. Set to {-1} to disable subtitle track.
The default property value is {-1}: no subtitles active.
Set index to -1
to disable subtitles.
Subtitles are disabled by default.
Definition at line 55 of file qmediaplayer.h.
|
readwrite |
Returns the currently active video track.
This property holds the track number of the currently active video audio track. Set to {-1} to disable video track.
The default property value is {0}: the first video track.
By default, the first available audio track will be chosen.
Set index to -1
to disable all video tracks.
Definition at line 53 of file qmediaplayer.h.
|
read |
\qmlproperty QAudioBufferOutput QtMultimedia::MediaPlayer::audioBufferOutput
This property holds the target audio buffer output.
Normal usage of MediaPlayer from QML should not require using this property.
The output audio buffer used by the media player.
Sets an audio buffer output to the media player.
If \l QAudioBufferOutput is specified and the media source contains an audio stream, the media player, it will emit the signal \l{QAudioBufferOutput::audioBufferReceived} with audio buffers containing decoded audio data. At the end of the audio stream, QMediaPlayer
emits an empty \l QAudioBuffer.
QMediaPlayer
emits outputs audio buffers at the same time as it pushes the matching data to the audio output if it's specified. However, the sound can be played with a small delay due to audio bufferization.
The format of emitted audio buffers is taken from the specified output or from the matching audio stream if the output returns an invalid format. Emitted audio data is not scaled depending on the current playback rate.
Potential use cases of utilizing QAudioBufferOutput
with QMediaPlayer
might be: \list
1
, you may scale the output image dimensions, or image update interval according to the requirements of the visualizer. Definition at line 45 of file qmediaplayer.h.
|
readwrite |
\qmlproperty AudioOutput QtMultimedia::MediaPlayer::audioOutput
This property holds the target audio output. Accepts one AudioOutput elements.
The audio output device used by the media player.
The current audio output to be used when playing back media. Setting a new audio output will replace the currently used output.
Setting this property to nullptr
will disable any audio output.
Definition at line 42 of file qmediaplayer.h.
|
read |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::audioTracks
This property holds a list of metadata. Each index refers to an audio track.
The metadata holds properties describing the individual tracks. For audio tracks the \l{QMediaMetaData}{Language} is usually the most important property.
Lists the set of available audio tracks inside the media.
The QMediaMetaData returned describes the properties of individual tracks.
Different audio tracks can for example contain audio in different languages.
Definition at line 47 of file qmediaplayer.h.
|
read |
\qmlproperty real QtMultimedia::MediaPlayer::bufferProgress
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. When the buffer is filled, MediaPlayer.Buffered
is true. When buffer progress is between 0.0
and 1.0
, MediaPlayer.Buffering
is set to {true}.
A value lower than 1.0
implies that the property MediaPlayer.StalledMedia
is {true}.
the percentage of the temporary buffer filled before playback begins or resumes, from 0
. (empty) to 1
. (full).
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 start or resume, at which time mediaStatus() will return BufferedMedia or BufferingMedia. If the value is anything lower than 100
, mediaStatus() will return StalledMedia.
Definition at line 29 of file qmediaplayer.h.
|
read |
\qmlproperty int QtMultimedia::MediaPlayer::duration
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 set to {0}.
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.
Definition at line 27 of file qmediaplayer.h.
|
read |
a string describing the last error condition.
Definition at line 39 of file qmediaplayer.h.
|
read |
\qmlproperty string QtMultimedia::MediaPlayer::errorString
This property holds a string describing the current error condition in more detail.
This property holds a string describing the current error condition in more detail.
Definition at line 40 of file qmediaplayer.h.
|
read |
\qmlproperty bool QtMultimedia::MediaPlayer::hasAudio
This property holds whether the media contains audio.
This property holds whether the media contains audio.
Definition at line 30 of file qmediaplayer.h.
|
read |
\qmlproperty bool QtMultimedia::MediaPlayer::hasVideo
This property holds whether the media contains video.
This property holds whether the media contains video.
Definition at line 31 of file qmediaplayer.h.
|
readwrite |
Determines how often the media is played before the player stops.
Set to QMediaPlayer::Infinite to loop the current media file forever.
The default value is 1
. Setting this property to 0
has no effect.
Definition at line 35 of file qmediaplayer.h.
|
read |
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
Definition at line 37 of file qmediaplayer.h.
|
read |
\qmlproperty mediaMetaData QtMultimedia::MediaPlayer::metaData
Returns meta data for the current media used by the media player.
Meta data can contain information such as the title of the video or its creation date.
Returns meta data for the current media used by the media player.
Meta data can contain information such as the title of the video or its creation date.
Definition at line 38 of file qmediaplayer.h.
|
readwrite |
\qmlproperty bool QtMultimedia::MediaPlayer::pitchCompensation
This property holds whether pitch compensation is enabled.
The pitch compensation status of the media player.
Indicates whether pitch compensation is enabled. When enabled, changing the playback rate will not affect the pitch of the audio signal.
By default is {true} if pitch compensation, is available, else
{false}.
Definition at line 59 of file qmediaplayer.h.
|
readwrite |
\qmlproperty playbackOptions MediaPlayer::playbackOptions
This property exposes the \l playbackOptions API that gives low-level control of media playback options. Although we strongly recommend to rely on the default settings of \l MediaPlayer, this API can be used to optimize media playback for specific use cases where the default options are not ideal.
Playback options take effect the next time \l MediaPlayer::source is changed.
Advanced playback options used to configure media playback and decoding.
This property exposes the \l QPlaybackOptions API that gives low-level control of media playback options. Although we strongly recommend to rely on the default settings of \l QMediaPlayer, this API can be used to optimize media playback for specific use cases where the default options are not ideal.
Playback options take effect the next time \l QMediaPlayer::setSource() is called.
Definition at line 67 of file qmediaplayer.h.
|
readwrite |
\qmlproperty real QtMultimedia::MediaPlayer::playbackRate
This property holds the rate at which media is played at as a multiple of the normal rate.
For more information, see \l{QMediaPlayer::playbackRate}.
Defaults to {1.0}.
the playback rate of the current media.
This value is a multiplier applied to the media's standard playback rate. By default this value is 1.0, indicating that the media is playing at the standard speed. Values higher than 1.0 will increase the playback speed, while values between 0.0 and 1.0 results in slower playback. Negative playback rates are not supported.
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.
Definition at line 34 of file qmediaplayer.h.
|
read |
Returns the \l{QMediaPlayer::}{PlaybackState}.
Definition at line 36 of file qmediaplayer.h.
|
read |
\qmlproperty bool QtMultimedia::MediaPlayer::playing
Indicates whether the media is currently playing.
Whether the media is playing.
Definition at line 33 of file qmediaplayer.h.
|
readwrite |
\qmlproperty int QtMultimedia::MediaPlayer::position
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 positionChanged() signal.
If the \l seekable property is true, this property can be set to milliseconds.
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 positionChanged() signal.
If the \l seekable property is true, this property can be set to milliseconds.
Definition at line 28 of file qmediaplayer.h.
|
read |
\qmlproperty bool QtMultimedia::MediaPlayer::seekable
This property holds whether the \l position of the media can be changed.
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.
Definition at line 32 of file qmediaplayer.h.
|
readwrite |
the active media source being used by the player object.
The player object will use the QUrl for selection of the content to be played.
By default this property has a null QUrl.
Setting this property to a null QUrl will cause the player to discard all information relating to the current media source and to cease all I/O operations related to that media.
Definition at line 26 of file qmediaplayer.h.
|
read |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::subtitleTracks
This property holds a list of metadata. Each index refers to a subtitle track.
The metadata holds properties describing the individual tracks. For subtitle tracks the \l{QMediaMetaData}{Language} is usually the most important property.
Lists the set of available subtitle tracks inside the media.
The QMediaMetaData returned describes the properties of individual tracks.
Definition at line 49 of file qmediaplayer.h.
|
readwrite |
\qmlproperty VideoOutput QtMultimedia::MediaPlayer::videoOutput
This property holds the target video output. Accepts one VideoOutput elements.
The video output to be used by the media player.
A media player can only have one video output attached, so setting this property will replace the previously connected video output.
Setting this property to nullptr
will disable video output.
Definition at line 41 of file qmediaplayer.h.
|
read |
\qmlproperty list<mediaMetaData> QtMultimedia::MediaPlayer::videoTracks
This property holds a list of metadata. Each index refers to a video track.
The metadata holds properties describing the individual tracks.
Lists the set of available video tracks inside the media.
The QMediaMetaData returned describes the properties of individual tracks.
Definition at line 48 of file qmediaplayer.h.