|CMake:|| find_package(Qt6 REQUIRED COMPONENTS AndroidAutomotiveMedia) |
target_link_libraries(mytarget PRIVATE Qt6::AndroidAutomotiveMedia)
|qmake:||QT += media|
|QList<QMediaSessionController *>||activeControllers() const|
QMediaSessionManager manages a list of active media 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 active controller list and emit a signal notifying about the change.
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 the
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>
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.
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 QMediaSessionController.
Member Function Documentation
QList<QMediaSessionController *> QMediaSessionManager::activeControllers() const
Returns 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.
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.
Returns a pointer to the singleton instance.
Available under certain Qt licenses.
Find out more.