QIfMediaPlayer Class
Provides an interface to control a media player. More...
Header: | #include <QIfMediaPlayer> |
qmake: | QT += ifmedia |
In QML: | MediaPlayer |
Inherits: | QIfAbstractFeature |
Public Types
enum | PlayMode { Normal, RepeatTrack, RepeatAll, Shuffle } |
enum | PlayState { Playing, Paused, Stopped } |
Properties
|
Public Functions
QIfMediaPlayer(QObject *parent = nullptr) | |
QVariant | currentTrack() const |
qint64 | duration() const |
bool | isMuted() const |
QIfMediaPlayer::PlayMode | playMode() const |
QIfPlayQueue * | playQueue() const |
QIfMediaPlayer::PlayState | playState() const |
qint64 | position() const |
int | volume() const |
Public Slots
void | next() |
void | pause() |
void | play() |
void | previous() |
void | seek(qint64 offset) |
void | setMuted(bool muted) |
void | setPlayMode(QIfMediaPlayer::PlayMode playMode) |
void | setPosition(qint64 position) |
void | setVolume(int volume) |
void | stop() |
Signals
void | currentTrackChanged(const QVariant ¤tTrack) |
void | durationChanged(qint64 duration) |
void | mutedChanged(bool muted) |
void | playModeChanged(QIfMediaPlayer::PlayMode playMode) |
void | playStateChanged(QIfMediaPlayer::PlayState playState) |
void | positionChanged(qint64 position) |
void | volumeChanged(int volume) |
Reimplemented Protected Functions
virtual void | clearServiceObject() override |
virtual void | connectToServiceObject(QIfServiceObject *serviceObject) override |
Detailed Description
The QIfMediaPlayer provides methods to control a media player. This media player can be local or even a remote device you are connected to e.g. over bluetooth.
By default the autoDiscovery is turned to Automatic for this feature and most likely will connect to a local media player instance.
Uses qtifmedia
as configurationId for QIfConfiguration based settings.
Member Type Documentation
enum QIfMediaPlayer::PlayMode
Constant | Value | Description |
---|---|---|
QIfMediaPlayer::Normal | 0 | Each item in the queue is played in sequential order. Usually the playback stops when the end of the queue is reached. |
QIfMediaPlayer::RepeatTrack | 1 | Always repeat the current item. It should still be possible to change the current item using next() and previous(), but this depends on the implementation of the backend. |
QIfMediaPlayer::RepeatAll | 2 | When the end of the queue is reached, the first item starts to play. |
QIfMediaPlayer::Shuffle | 3 | The item in the queue are played in an random order. |
enum QIfMediaPlayer::PlayState
Constant | Value | Description |
---|---|---|
QIfMediaPlayer::Playing | 0 | The media player is currently playing an item. |
QIfMediaPlayer::Paused | 1 | The playback is paused and can be continued at the same position. |
QIfMediaPlayer::Stopped | 2 | The playback hasn't been started yet. Starting it, will always start from the beginning. |
Property Documentation
[read-only]
currentTrack : const QVariant
Holds the current track represented as QVariant.
Note: This will be replaced by soon.
Access functions:
QVariant | currentTrack() const |
Notifier signal:
void | currentTrackChanged(const QVariant ¤tTrack) |
[read-only]
duration : const qint64
Holds the total duration of the current song in seconds.
Access functions:
qint64 | duration() const |
Notifier signal:
void | durationChanged(qint64 duration) |
muted : bool
This property holds whether the audio output is muted.
Access functions:
bool | isMuted() const |
void | setMuted(bool muted) |
Notifier signal:
void | mutedChanged(bool muted) |
See also volume.
playMode : QIfMediaPlayer::PlayMode
Holds the current playback mode of the media player.
Access functions:
QIfMediaPlayer::PlayMode | playMode() const |
void | setPlayMode(QIfMediaPlayer::PlayMode playMode) |
Notifier signal:
void | playModeChanged(QIfMediaPlayer::PlayMode playMode) |
[read-only]
playQueue : QIfPlayQueue* const
Holds the play queue of this media player.
Access functions:
QIfPlayQueue * | playQueue() const |
See also QIfPlayQueue.
[read-only]
playState : const QIfMediaPlayer::PlayState
Holds the current playback state of the media player.
Access functions:
QIfMediaPlayer::PlayState | playState() const |
Notifier signal:
void | playStateChanged(QIfMediaPlayer::PlayState playState) |
position : qint64
Holds the position of the current song of the media player in seconds.
Access functions:
qint64 | position() const |
void | setPosition(qint64 position) |
Notifier signal:
void | positionChanged(qint64 position) |
volume : int
Holds the sound volume level (0..100)
Access functions:
int | volume() const |
void | setVolume(int volume) |
Notifier signal:
void | volumeChanged(int volume) |
See also muted.
Member Function Documentation
[explicit]
QIfMediaPlayer::QIfMediaPlayer(QObject *parent = nullptr)
Constructs a QIfMediaPlayer.
The parent argument is passed on to the QIfAbstractFeature base class.
[override virtual protected]
void QIfMediaPlayer::clearServiceObject()
Reimplements: QIfAbstractFeature::clearServiceObject().
[override virtual protected]
void QIfMediaPlayer::connectToServiceObject(QIfServiceObject *serviceObject)
Reimplements: QIfAbstractFeature::connectToServiceObject(QIfServiceObject *serviceObject).
[slot]
void QIfMediaPlayer::next()
Skips to the next track in the playQueue.
See also playMode.
[slot]
void QIfMediaPlayer::pause()
Pauses the currently ongoing playback.
[slot]
void QIfMediaPlayer::play()
Starts to play the current track. If the playQueue is empty it's up to the backend to decide what to do.
[slot]
void QIfMediaPlayer::previous()
Skips to the previous track in the playQueue.
See also playMode.
[slot]
void QIfMediaPlayer::seek(qint64 offset)
Seeks into the current track using offset.
The offset can be positive or negative to either seek forward or backward. A successful seek will result in a change of the position property.
[slot]
void QIfMediaPlayer::stop()
Stops the currently ongoing playback.
© 2024 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.