Skip to content

Latest commit

 

History

History
142 lines (85 loc) · 3.73 KB

README.md

File metadata and controls

142 lines (85 loc) · 3.73 KB

capacitor-media-session

Capacitor plugin which manages the media session and fire media events for Android TV.

Install

yarn add @videodock/capacitor-media-session
npx cap sync

Usage

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);

API

initMediaSession(...)

initMediaSession(mediaState: MediaState) => Promise<{ call: string; }>
Param Type
mediaState MediaState

Returns: Promise<{ call: string; }>


releaseMediaSession()

releaseMediaSession() => Promise<{ call: string; }>

Returns: Promise<{ call: string; }>


setMediaState(...)

setMediaState(mediaState: MediaState) => Promise<{ call: string; mediaState: MediaState; }>
Param Type
mediaState MediaState

Returns: Promise<{ call: string; mediaState: MediaState; }>


addListener('mediaSessionEvent', ...)

addListener(eventName: 'mediaSessionEvent', listenerFunc: MediaSessionListenerFunc) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'mediaSessionEvent'
listenerFunc MediaSessionListenerFunc

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

Type Aliases

MediaState

{ isPlaying: boolean; isActive: boolean; title: string; subtitle: string; artworkUri: string; position: number; }

MediaSessionListenerFunc

(event: MediaSessionEvent): void

MediaSessionEvent

{ eventName: MediaSessionEventType }

MediaSessionEventType

'onPlay' | 'onPause' | 'onPlayPause' | 'onStop' | 'onNext' | 'onPrev' | 'onFastForward' | 'onRewind'