MediaPlayer QML Type

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

Import Statement: import QtInterfaceFramework.Media 1.0
Instantiates: QIfMediaPlayer
Inherits:

AbstractFeature

Properties

Methods

Detailed Description

The MediaPlayer 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 InterfaceFrameworkConfiguration based settings.

Property Documentation

configurationId : string

Holds the id to determine which configuration this feature belongs to.

Once the id has been set, it is possible to change certain values using the InterfaceFrameworkConfiguration API.

Note: Values set in the matching InterfaceFrameworkConfiguration can override the initial values set during the component creation.

See also InterfaceFrameworkConfiguration.


currentTrack : object [read-only]

Holds the current track represented as QVariant.

Note: This will be replaced by soon.


discoveryMode : enumeration

Holds the mode that is used for the autoDiscovery

Available values are:

ConstantDescription
NoAutoDiscoveryNo auto discovery is done and the ServiceObject needs to be set manually.
AutoDiscoveryTries to find a production backend with a matching interface and falls back to a simulation backend if not found.
LoadOnlyProductionBackendsOnly tries to load a production backend with a matching interface.
LoadOnlySimulationBackendsOnly tries to load a simulation backend with a matching interface.

If necessary, auto discovery is started once the feature creation is completed.

Note: If you change this property after the feature is instantiated, make sure to call startAutoDiscovery() to search for a new service object.


discoveryResult : enumeration [read-only]

The result of the last autoDiscovery

Available values are:

ConstantDescription
NoResultIndicates that no auto discovery was started because the feature has already assigned a valid ServiceObject.
ErrorWhileLoadingAn error has happened while searching for a backend with a matching interface.
ProductionBackendLoadedA production backend was loaded, as a result of auto discovery.
SimulationBackendLoadedA simulation backend was loaded, as a result of auto discovery.

duration : int [read-only]

Holds the total duration of the current song in seconds.


isInitialized : bool [read-only]

Indicates whether the feature has been initialized with all the values from the backend.

The property is true once the backend sends the QIfFeatureInterface::initializationDone signal to indicate that all values have now been initialized with values from the backend.

See also isValid and QIfFeatureInterface::initializationDone.


isValid : bool [read-only]

Indicates whether the feature is ready for use.

The property is true if the feature is ready to be used, otherwise false. Not being ready usually indicates that no suitable service object could be found, or that automatic discovery has not been triggered.

The backend still might not have sent all properties yet and is not fully initialized. Use isInitialized instead to know when the feature holds all correct values.

See also QIfServiceObject, discoveryMode, and isInitialized.


muted : bool

This property holds whether the audio output is muted.

See also volume.


playMode : enumeration

Holds the current playback mode of the media player. Available values are:

ConstantDescription
NormalEach item in the queue is played in sequential order. Usually the playback stops when the end of the queue is reached.
RepeatTrackAlways 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.
RepeatAllWhen the end of the queue is reached, the first item starts to play.
ShuffleThe item in the queue are played in an random order.

playQueue : PlayQueue [read-only]

Holds the play queue of this media player.

See also PlayQueue.


playState : enumeration [read-only]

Holds the current playback state of the media player. Available values are:

ConstantDescription
PlayingThe media player is currently playing an item.
PausedThe playback is paused and can be continued at the same position.
StoppedThe playback hasn't been started yet. Starting it, will always start from the beginning.

position : int

Holds the position of the current song of the media player in seconds.


preferredBackends : list<string>

Holds a list of wildcards to load the preferred backend during auto discovery.

The auto discovery mechanism will automatically search for backends which provide a matching interface for this feature implementation. See startAutoDiscovery() for more information.

In case multiple backends implement the same interface, the list of wildcards can be used to determine the correct one to load.

The wildcards are applied in order to the found backends. If the wildcard matches some backends those backends will be loaded, otherwise the next wildcard is used.

For example: Given an AbstractFeature with two backends, backend_mqtt.so and backend_qtro.so, the property can be set to "*_mqtt*" to always select the backend_mqtt.so backend when available.


serviceObject : ServiceObject

Sets the service object for the feature.

As Features only expose the front API facing the developer, a service object implementing the actual function is required. This is usually retrieved through the auto discovery mechanism.

The setter for this property returns false if the QIfServiceObject is already set to this particular instance or the QIfServiceObject isn't accepted by the feature.

See also discoveryMode.


volume : int

Holds the sound volume level (0..100)

See also muted.


Method Documentation

next()

Skips to the next track in the playQueue.

See also playMode.


pause()

Pauses the currently ongoing playback.

See also play() and stop().


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().


previous()

Skips to the previous track in the playQueue.

See also playMode.


seek(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.


enumeration startAutoDiscovery()

Performs an automatic discovery attempt.

The feature tries to locate a single ServiceObject that implements the required interface.

If no ServiceObject is found, the feature remains invalid. If more than one ServiceObject is found, the first instance is used.

This function returns either the type of the backend that was loaded; or an error.

If the discoveryMode is set to QIfAbstractFeature::NoAutoDiscovery, this function does nothing and returns QIfAbstractFeature::NoResult.

Return values are:

ConstantDescription
NoResultIndicates that no auto discovery was started because the feature already has a valid ServiceObject assigned.
ErrorWhileLoadingIndicates an error has occurred while searching for a backend with a matching interface.
ProductionBackendLoadedA production backend was loaded, as a result of auto discovery.
SimulationBackendLoadedA simulation backend was loaded, as a result of auto discovery.

See also Dynamic Backend System and QIfServiceManager.


stop()

Stops the currently ongoing playback.

See also play() and pause().


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