Capacitor plugin which manages the media session and fire media events for Android TV.
yarn add @videodock/capacitor-media-session
npx cap sync
All API methods are exposed on the CapacitorMediaSession
plugin. Import the plugin like so:
import { CapacitorMediaSession } from '@videodock/capacitor-media-session';
You can now call any API method:
// call when player gets mounted
CapacitorMediaSession.initMediaSession(mediaState);
// call when player gets unmounted/stopped
CapacitorMediaSession.releaseMediaSession();
// call when media state changes (one of the MediaState properties)
CapacitorMediaSession.setMediaState(mediaState);
initMediaSession(...)
releaseMediaSession()
setMediaState(...)
addListener('mediaSessionEvent', ...)
- Interfaces
- Type Aliases
initMediaSession(mediaState: MediaState) => Promise<{ call: string; }>
Param | Type |
---|---|
mediaState |
MediaState |
Returns: Promise<{ call: string; }>
releaseMediaSession() => Promise<{ call: string; }>
Returns: Promise<{ call: string; }>
setMediaState(mediaState: MediaState) => Promise<{ call: string; mediaState: MediaState; }>
Param | Type |
---|---|
mediaState |
MediaState |
Returns: Promise<{ call: string; mediaState: MediaState; }>
addListener(eventName: 'mediaSessionEvent', listenerFunc: MediaSessionListenerFunc) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'mediaSessionEvent' |
listenerFunc |
MediaSessionListenerFunc |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Prop | Type |
---|---|
remove |
() => Promise<void> |
{ isPlaying: boolean; isActive: boolean; title: string; subtitle: string; artworkUri: string; position: number; }
(event: MediaSessionEvent): void
{ eventName: MediaSessionEventType }
'onPlay' | 'onPause' | 'onPlayPause' | 'onStop' | 'onNext' | 'onPrev' | 'onFastForward' | 'onRewind'