Skip to content

Getting Started

GitHub

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

Terminal window
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-media-session` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

Terminal window
bun add @capgo/capacitor-media-session
bunx cap sync
import { MediaSession } from '@capgo/capacitor-media-session';

Sets metadata of the currently playing media.

import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setMetadata({} as MetadataOptions);

Updates the playback state of the media session.

import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPlaybackState({} as PlaybackStateOptions);

Registers a handler for a media session action.

import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setActionHandler({} as ActionHandlerOptions, {} as ActionHandler | null);

Updates position state for the active media session.

import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPositionState({} as PositionStateOptions);
export interface MetadataOptions {
album?: string;
artist?: string;
artwork?: MediaImage[];
title?: string;
}
export interface PlaybackStateOptions {
playbackState: MediaSessionPlaybackState;
}
export interface ActionHandlerOptions {
action: MediaSessionAction;
}
export type ActionHandler = (details: ActionDetails) => void;
export interface PositionStateOptions {
duration?: number;
playbackRate?: number;
position?: number;
}
export interface MediaImage {
src: string;
sizes?: string;
type?: string;
}
export type MediaSessionPlaybackState = 'none' | 'paused' | 'playing';
export type MediaSessionAction =
| 'play'
| 'pause'
| 'seekbackward'
| 'seekforward'
| 'previoustrack'
| 'nexttrack'
| 'seekto'
| 'stop';

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

If you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-media-session for the native capability in Using @capgo/capacitor-media-session, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.