@capgo/capacitor-media-session
v8.0.2
Published
Capacitor plugin to expose media session controls of the device
Downloads
814
Maintainers
Readme
@capgo/capacitor-media-session
Documentation
The most complete doc is available here: https://capgo.app/docs/plugins/media-session/
Install
npm install @capgo/capacitor-media-session
npx cap syncAPI
setMetadata(...)setPlaybackState(...)setActionHandler(...)setPositionState(...)getPluginVersion()- Interfaces
- Type Aliases
setMetadata(...)
setMetadata(options: MetadataOptions) => Promise<void>Sets metadata of the currently playing media.
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | MetadataOptions |
setPlaybackState(...)
setPlaybackState(options: PlaybackStateOptions) => Promise<void>Updates the playback state of the media session.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | PlaybackStateOptions |
setActionHandler(...)
setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null) => Promise<void>Registers a handler for a media session action.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | ActionHandlerOptions |
| handler | ActionHandler | null |
setPositionState(...)
setPositionState(options: PositionStateOptions) => Promise<void>Updates position state for the active media session.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | PositionStateOptions |
getPluginVersion()
getPluginVersion() => Promise<{ version: string; }>Get the native Capacitor plugin version
Returns: Promise<{ version: string; }>
Interfaces
MetadataOptions
| Prop | Type |
| ------------- | ------------------------- |
| album | string |
| artist | string |
| artwork | MediaImage[] |
| title | string |
MediaImage
| Prop | Type |
| ----------- | ------------------- |
| src | string |
| sizes | string |
| type | string |
PlaybackStateOptions
| Prop | Type |
| ------------------- | ------------------------------------------------------------------------------- |
| playbackState | MediaSessionPlaybackState |
ActionHandlerOptions
| Prop | Type |
| ------------ | ----------------------------------------------------------------- |
| action | MediaSessionAction |
ActionDetails
| Prop | Type |
| -------------- | ----------------------------------------------------------------- |
| action | MediaSessionAction |
| seekTime | number | null |
PositionStateOptions
| Prop | Type |
| ------------------ | ------------------- |
| 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
