C
QMediaSessionManager Class
The QMediaSessionManager class provides a list of media controllers currently active on the device. More...
Header: | #include <QMediaSessionManager> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS AndroidAutomotiveMedia) target_link_libraries(mytarget PRIVATE Qt6::AndroidAutomotiveMedia) |
Since: | QtAndroidAutomotive 6.5 |
Inherits: | QObject |
Public Functions
QList<QMediaSessionController *> | activeControllers() const |
Signals
void | activeControllersChanged() |
Static Public Members
QMediaSessionManager * | instance() |
Detailed Description
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>
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 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.
Note: The controllers are owned by QMediaSessionManager. The controllers are deleted when the QMediaSessionManager::activeControllersChanged() signal is emitted, and any held references are invalid.
[signal]
void QMediaSessionManager::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.
[static]
QMediaSessionManager *QMediaSessionManager::instance()
Returns a pointer to the singleton instance.
Available under certain Qt licenses.
Find out more.