QIviMediaPlayer Class

Provides an interface to control a media player. More...

Header: #include <QIviMediaPlayer>
qmake: QT += ivimedia
Instantiated By: MediaPlayer
Inherits: QIviAbstractFeature

Public Types

enum PlayMode { Normal, RepeatTrack, RepeatAll, Shuffle }
enum PlayState { Playing, Paused, Stopped }

Properties

Public Functions

QIviMediaPlayer(QObject *parent = nullptr)
QVariant currentTrack() const
qint64 duration() const
bool isMuted() const
QIviMediaPlayer::PlayMode playMode() const
QIviPlayQueue *playQueue() const
QIviMediaPlayer::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(QIviMediaPlayer::PlayMode playMode)
void setPosition(qint64 position)
void setVolume(int volume)
void stop()

Signals

void currentTrackChanged(const QVariant &currentTrack)
void durationChanged(qint64 duration)
void mutedChanged(bool muted)
void playModeChanged(QIviMediaPlayer::PlayMode playMode)
void playStateChanged(QIviMediaPlayer::PlayState playState)
void positionChanged(qint64 position)
void volumeChanged(int volume)

Reimplemented Protected Functions

virtual void clearServiceObject() override
virtual void connectToServiceObject(QIviServiceObject *serviceObject) override

Detailed Description

The QIviMediaPlayer 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.

Member Type Documentation

enum QIviMediaPlayer::PlayMode

ConstantValueDescription
QIviMediaPlayer::Normal0Each item in the queue is played in sequential order. Usually the playback stops when the end of the queue is reached.
QIviMediaPlayer::RepeatTrack1Always 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.
QIviMediaPlayer::RepeatAll2When the end of the queue is reached, the first item starts to play.
QIviMediaPlayer::Shuffle3The item in the queue are played in an random order.

enum QIviMediaPlayer::PlayState

ConstantValueDescription
QIviMediaPlayer::Playing0The media player is currently playing an item.
QIviMediaPlayer::Paused1The playback is paused and can be continued at the same position.
QIviMediaPlayer::Stopped2The playback hasn't been started yet. Starting it, will always start from the beginning.

Property Documentation

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 &currentTrack)

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 : QIviMediaPlayer::PlayMode

Holds the current playback mode of the media player.

Access functions:

QIviMediaPlayer::PlayMode playMode() const
void setPlayMode(QIviMediaPlayer::PlayMode playMode)

Notifier signal:

void playModeChanged(QIviMediaPlayer::PlayMode playMode)

playQueue : QIviPlayQueue* const

Holds the play queue of this media player.

Access functions:

QIviPlayQueue *playQueue() const

See also QIviPlayQueue.

playState : const QIviMediaPlayer::PlayState

Holds the current playback state of the media player.

Access functions:

QIviMediaPlayer::PlayState playState() const

Notifier signal:

void playStateChanged(QIviMediaPlayer::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

QIviMediaPlayer::QIviMediaPlayer(QObject *parent = nullptr)

Constructs a QIviMediaPlayer.

The parent argument is passed on to the QIviAbstractFeature base class.

[slot] void QIviMediaPlayer::next()

Skips to the next track in the playQueue.

See also playMode.

[slot] void QIviMediaPlayer::pause()

Pauses the currently ongoing playback.

See also play() and stop().

[slot] void QIviMediaPlayer::play()

Starts to play the current track. If the playQueue is empty it's up to the backend to decide what to do.

See also pause() and stop().

[slot] void QIviMediaPlayer::previous()

Skips to the previous track in the playQueue.

See also playMode.

[slot] void QIviMediaPlayer::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 QIviMediaPlayer::stop()

Stops the currently ongoing playback.

See also play() and pause().

[override virtual protected] void QIviMediaPlayer::clearServiceObject()

Reimplements: QIviAbstractFeature::clearServiceObject().

[override virtual protected] void QIviMediaPlayer::connectToServiceObject(QIviServiceObject *serviceObject)

Reimplements: QIviAbstractFeature::connectToServiceObject(QIviServiceObject *serviceObject).

© 2020 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.