@capgo/capacitor-media-session

Expose media session controls for Capacitor apps
Documentation
The most complete doc is available here: https://capgo.app/docs/plugins/media-session/
Compatibility
| v8.*.* | v8.*.* | ✅ |
| v7.*.* | v7.*.* | On demand |
| v6.*.* | v6.*.* | ❌ |
| v5.*.* | v5.*.* | ❌ |
Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.
Install
npm install @capgo/capacitor-media-session
npx cap sync
API
setMetadata(...)
setMetadata(options: MetadataOptions) => Promise<void>
Sets metadata of the currently playing media.
setPlaybackState(...)
setPlaybackState(options: PlaybackStateOptions) => Promise<void>
Updates the playback state of the media session.
setActionHandler(...)
setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null) => Promise<void>
Registers a handler for a media session action.
setPositionState(...)
setPositionState(options: PositionStateOptions) => Promise<void>
Updates position state for the active media session.
getPluginVersion()
getPluginVersion() => Promise<{ version: string; }>
Get the native Capacitor plugin version
Returns: Promise<{ version: string; }>
Interfaces
MetadataOptions
album | string |
artist | string |
artwork | MediaImage[] |
title | string |
MediaImage
src | string |
sizes | string |
type | string |
PlaybackStateOptions
ActionHandlerOptions
ActionDetails
PositionStateOptions
duration | number |
playbackRate | number |
position | number |
Type Aliases
MediaSessionPlaybackState
'none' | 'paused' | 'playing'
MediaSessionAction
'play' | 'pause' | 'seekbackward' | 'seekforward' | 'previoustrack' | 'nexttrack' | 'seekto' | 'stop'
ActionHandler
(details: ActionDetails): void