Android-only Capacitor plugin for MediaSession and playback state monitoring
- ✅ Android
- ❌ iOS (Not supported)
- ❌ Web
npm install android-media-watcher
npx cap syncMediaWatcher Capacitor plugin interface.
Android-only plugin used to monitor media playback through system notifications and MediaSession.
hasPermission() => Promise<{ granted: boolean; }>Checks whether notification listener permission is enabled for this application.
Returns: Promise<{ granted: boolean; }>
requestPermission() => Promise<void>Opens system settings so the user can grant notification listener permission manually.
addListener(eventName: 'mediaEvent', listenerFunc: (event: MediaEvent) => void) => Promise<{ remove: () => void; }>Registers a listener for media playback state changes.
| Param | Type | Description |
|---|---|---|
eventName |
'mediaEvent' |
Event name ("mediaEvent") |
listenerFunc |
(event: MediaEvent) => void |
Callback invoked when media state changes |
Returns: Promise<{ remove: () => void; }>
| Prop | Type |
|---|---|
title |
string |
artist |
string |
album |
string |
playbackState |
string |
packageName |
string |