QIfMediaPlayerBackendInterface Class

The QIfMediaPlayerBackendInterface defines the interface for backends to the QIfMediaPlayer feature class. More...

Header: #include <QIfMediaPlayerBackendInterface>
qmake: QT += ifmedia
Inherits: QIfFeatureInterface

Public Functions

QIfMediaPlayerBackendInterface(QObject *parent = nullptr)
virtual void fetchData(const QUuid &identifier, int start, int count) = 0
virtual void insert(int index, const QVariant &item) = 0
virtual void move(int currentIndex, int newIndex) = 0
virtual void next() = 0
virtual void pause() = 0
virtual void play() = 0
virtual void previous() = 0
virtual void remove(int index) = 0
virtual void seek(qint64 offset) = 0
virtual void setCurrentIndex(int currentIndex) = 0
virtual void setMuted(bool muted) = 0
virtual void setPlayMode(QIfMediaPlayer::PlayMode playMode) = 0
virtual void setPosition(qint64 position) = 0
virtual void setVolume(int volume) = 0
virtual void stop() = 0

Signals

void canReportCountChanged(bool canReportCount = false)
void countChanged(int newLength = -1)
void currentIndexChanged(int currentIndex = -1)
void currentTrackChanged(const QVariant &currentTrack = QVariant())
void dataChanged(const QList<QVariant> &data, int start, int count)
void dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable)
void durationChanged(qint64 duration = -1)
void mutedChanged(bool muted = false)
void playModeChanged(QIfMediaPlayer::PlayMode playMode = QIfMediaPlayer::Normal)
void playStateChanged(QIfMediaPlayer::PlayState playState = QIfMediaPlayer::Stopped)
void positionChanged(qint64 position = -1)
void volumeChanged(int volume = -1)

Detailed Description

The QIfMediaPlayerBackendInterface is the interface used by QIfMediaPlayer

The interface is discovered by a QIfMediaPlayer object, which connects to it and sets it up.

<example of a fully featured backend>

Member Function Documentation

[explicit] QIfMediaPlayerBackendInterface::QIfMediaPlayerBackendInterface(QObject *parent = nullptr)

Constructs a backend interface.

The parent is sent to the QObject constructor.

[signal] void QIfMediaPlayerBackendInterface::canReportCountChanged(bool canReportCount = false)

This signal is emitted if the backend can return the final number of items (canReportCount) for a specific request. This makes it possible to support the QIfPlayQueue::DataChanged loading type. The number of items can then be returned by emitting the countChanged signal.

See also countChanged().

[signal] void QIfMediaPlayerBackendInterface::countChanged(int newLength = -1)

This signal is emitted once the backend knows about the new size of the play queue. The new number of items is returned as newLength.

This signal is expected to be emitted before the data is returned by emitting the dataFetched() signal.

See also fetchData() and dataFetched().

[signal] void QIfMediaPlayerBackendInterface::currentIndexChanged(int currentIndex = -1)

Emitted when the currently played playable item in the play queue changed. The index of the new current playable item will be passed as currentIndex.

[signal] void QIfMediaPlayerBackendInterface::currentTrackChanged(const QVariant &currentTrack = QVariant())

Emitted when the currently played playable item changed. The new playable item will be passed as currentTrack.

[signal] void QIfMediaPlayerBackendInterface::dataChanged(const QList<QVariant> &data, int start, int count)

This signal is emitted whenever the play queue changes, e.g. by a insert, remove or a move operation. The data argument holds the new data which will replace the data starting at start until count.

If data is empty the rows identified by the range of start and count will be removed. If count is 0, data will be inserted at start.

For inserting a new item, the item is passed in data and start is used for where the item should be inserted, the count argument needs to be 0 as we don't want to replace existing data:

QList<ExampleItem> list;
ExampleItem item = ExampleItem();
list.insert(index, item);
QVariantList items = { QVariant::fromValue(item) };
emit dataChanged(items, index, 0);

Removing an item is very similar, start is used to indicate which item and count to indicate how much:

list.removeAt(index);
emit dataChanged(QVariantList(), index, 1);

See also insert(), remove(), and move().

[signal] void QIfMediaPlayerBackendInterface::dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable)

This signal is emitted as a result of a call to fetchData() and returns the requested data to the QIfPlayQueue instance identified by identifier. The arguments start holds the index where the data starts, moreAvailable holds whether there is more data available. To retrieve this data, use a new fetchData() call.

See also fetchData() and dataFetched().

[signal] void QIfMediaPlayerBackendInterface::durationChanged(qint64 duration = -1)

Emitted when the duration of the currently playing playable item changed. The new duration will be passed as duration in ms.

[pure virtual] void QIfMediaPlayerBackendInterface::fetchData(const QUuid &identifier, int start, int count)

This function is called whenever new playable items needs to be retrieved by the QIfPlayQueue.

The parameters start and count define the range of data to be fetched. This method is expected to emit the dataFetched() signal when the new data is ready. Use identifier to identify the calling QIfPlayQueue instance.

See also dataFetched().

[pure virtual] void QIfMediaPlayerBackendInterface::insert(int index, const QVariant &item)

Adds the playable item identitifed by item into the play queue at index.

See also dataChanged().

[pure virtual] void QIfMediaPlayerBackendInterface::move(int currentIndex, int newIndex)

Moves the playable item at position currentIndex of the play queue to the new position newIndex.

See also dataChanged().

[signal] void QIfMediaPlayerBackendInterface::mutedChanged(bool muted = false)

Emitted when the player changes its mute state. The player is muted when muted is set to true.

[pure virtual] void QIfMediaPlayerBackendInterface::next()

Skips to the next playable item.

[pure virtual] void QIfMediaPlayerBackendInterface::pause()

Pauses the playback of the current playable item.

See also play() and stop().

[pure virtual] void QIfMediaPlayerBackendInterface::play()

Starts playing the current playable item.

See also pause() and stop().

[signal] void QIfMediaPlayerBackendInterface::playModeChanged(QIfMediaPlayer::PlayMode playMode = QIfMediaPlayer::Normal)

Emitted when the play mode changed. The new play mode will be passed as playMode.

[signal] void QIfMediaPlayerBackendInterface::playStateChanged(QIfMediaPlayer::PlayState playState = QIfMediaPlayer::Stopped)

Emitted when the play state changed. The new play state will be passed as playState.

[signal] void QIfMediaPlayerBackendInterface::positionChanged(qint64 position = -1)

Emitted when the position of the currently playing playable item changed. The new position will be passed as position in ms.

[pure virtual] void QIfMediaPlayerBackendInterface::previous()

Skips to the previous playable item.

[pure virtual] void QIfMediaPlayerBackendInterface::remove(int index)

Removes the playable item at position index from the play queue.

See also dataChanged().

[pure virtual] void QIfMediaPlayerBackendInterface::seek(qint64 offset)

Seeks the current playable item using offset in ms.

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.

[pure virtual] void QIfMediaPlayerBackendInterface::setCurrentIndex(int currentIndex)

Sets the currentIndex of the play-queue to the given index. If a valid index is passed, the function should update the current playable item and emit the corresponding change signals

See also currentIndexChanged, currentTrackChanged, and durationChanged.

[pure virtual] void QIfMediaPlayerBackendInterface::setMuted(bool muted)

When muted is set to true, the player will be muted and un-muted otherwise.

See also mutedChanged.

[pure virtual] void QIfMediaPlayerBackendInterface::setPlayMode(QIfMediaPlayer::PlayMode playMode)

Sets playMode as the new playback mode for the player. If a valid playMode is passed, the function should emit the corresponding change signal.

See also playModeChanged.

[pure virtual] void QIfMediaPlayerBackendInterface::setPosition(qint64 position)

Sets the position of the currently playing item. If a valid position is passed, the function should emit the corresponding change signals

See also positionChanged.

[pure virtual] void QIfMediaPlayerBackendInterface::setVolume(int volume)

Sets the current player volume. The value needs to be between 0 and 100.

See also volumeChanged.

[pure virtual] void QIfMediaPlayerBackendInterface::stop()

Stops playing the current playable item.

See also play() and stop().

[signal] void QIfMediaPlayerBackendInterface::volumeChanged(int volume = -1)

Emitted when the volume of this player changed. The new volume of the player will be passed as volume.

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