C

MediaSessionManager QML Type

MediaSessionManager provides a list of media controllers currently active on the device. More...

Import Statement: import QtAndroidAutomotive.Media
Since: QtAndroidAutomotive 6.5

Properties

Signals

Detailed Description

MediaSessionManager provides a list of active controllers on the device. If it detects that a new controller is added to the system or an active controller has been deleted from the system, it will update the corresponding controller list and emit a signal notifying about the change.

The controllers list can be used as a model for QML ListView as shown below:

ListView {
    model: MediaSessionManager.activeControllers
}

To get access to the controllers in android, you either need to have the MEDIA_CONTENT_CONTROL permission or the user needs to grant notification access for your app. For notification access, you need to add QtMediaNotificationListener class in the AndroidManifest.xml file as shown below:

<service
    android:name="org.qtproject.qt.android.mediasession.QtMediaNotificationListener"
    android:enabled="true"
    android:exported="true"
    android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
    <intent-filter>
        <action android:name="android.service.notification.NotificationListenerService" />
    </intent-filter>
</service>

See Qt Android Manifest File Configuration, Android Manifest <service> element and Android NotificationListenerService documentation for more details.

MediaSessions Known issues, bugs, and defects

All known issues, bugs, and defects that affect this API are listed and described here. The status of these will be updated in every release.

onListenerConnected called before permissions granted

Currently, the Media Sessions API relies on the onListenerConnected method to determine when the notification access has been granted by the user. However, sometimes Android calls the onListenerConnected method even before notification access is granted. This is an open bug on Android and has been reported here.

A workaround is to remove an installed app's permissions before un-installing the app.

See also MediaSessionController.

Property Documentation

activeControllers : list<MediaSessionController>

This property holds a list of active controllers on the device.

When an app plays media, it can create a media session to offer other apps the option to control the media being played. These controllers represent the active sessions on the device.

Note: The controllers returned here are deleted when MediaSessionManager::activeControllersChanged() signal is emitted.


Signal Documentation

activeControllersChanged()

This signal is emitted when the media controller list gets updated. For example, when a new controller is added or an old controller is deleted.

Note: The corresponding handler is onActiveControllersChanged.


Available under certain Qt licenses.
Find out more.