https://github.com/cap-go/capacitor-media-session
Capacitor plugin to expose media session controls of the device
https://github.com/cap-go/capacitor-media-session
capacitor capacitor-plugin
Last synced: 2 months ago
JSON representation
Capacitor plugin to expose media session controls of the device
- Host: GitHub
- URL: https://github.com/cap-go/capacitor-media-session
- Owner: Cap-go
- License: mpl-2.0
- Created: 2025-10-09T16:37:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-04-06T11:35:19.000Z (2 months ago)
- Last Synced: 2026-04-06T13:24:34.055Z (2 months ago)
- Topics: capacitor, capacitor-plugin
- Language: Java
- Homepage: https://capgo.app
- Size: 717 KB
- Stars: 5
- Watchers: 0
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
# @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
| Plugin version | Capacitor compatibility | Maintained |
| -------------- | ----------------------- | ---------- |
| 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
```bash
npm install @capgo/capacitor-media-session
npx cap sync
```
## API
* [`setMetadata(...)`](#setmetadata)
* [`setPlaybackState(...)`](#setplaybackstate)
* [`setActionHandler(...)`](#setactionhandler)
* [`setPositionState(...)`](#setpositionstate)
* [`getPluginVersion()`](#getpluginversion)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
### setMetadata(...)
```typescript
setMetadata(options: MetadataOptions) => Promise
```
Sets metadata of the currently playing media.
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| **`options`** | MetadataOptions |
--------------------
### setPlaybackState(...)
```typescript
setPlaybackState(options: PlaybackStateOptions) => Promise
```
Updates the playback state of the media session.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | PlaybackStateOptions |
--------------------
### setActionHandler(...)
```typescript
setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null) => Promise
```
Registers a handler for a media session action.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | ActionHandlerOptions |
| **`handler`** | ActionHandler \| null |
--------------------
### setPositionState(...)
```typescript
setPositionState(options: PositionStateOptions) => Promise
```
Updates position state for the active media session.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | PositionStateOptions |
--------------------
### getPluginVersion()
```typescript
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