Guide
Tutorial on Media Session
Using @capgo/capacitor-media-session
Capacitor plugin to expose media session controls of the device.
Install
bun add @capgo/capacitor-media-session
bunx cap sync
What This Plugin Exposes
setMetadata- Sets metadata of the currently playing media.setPlaybackState- Updates the playback state of the media session.setActionHandler- Registers a handler for a media session action.setPositionState- Updates position state for the active media session.
Example Usage
setMetadata
Sets metadata of the currently playing media.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setMetadata({} as MetadataOptions);
setPlaybackState
Updates the playback state of the media session.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPlaybackState({} as PlaybackStateOptions);
setActionHandler
Registers a handler for a media session action.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setActionHandler({} as ActionHandlerOptions, {} as ActionHandler | null);
setPositionState
Updates position state for the active media session.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPositionState({} as PositionStateOptions);
Full Reference
- GitHub: https://github.com/Cap-go/capacitor-media-session/
- Docs: /docs/plugins/media-session/
Keep going from Using @capgo/capacitor-media-session
If you are using Using @capgo/capacitor-media-session to plan dashboard and API operations, connect it with @capgo/capacitor-media-session for the implementation detail in @capgo/capacitor-media-session, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.