---
description: Capacitor plugin to interact with media controls and metadata for a seamless media playback experience across platforms.
title: Capacitor Media Session Plugin for Android, iOS & Web - Capawesome
image: https://capawesome.io/docs/assets/images/social/plugins/media-session.png
---

[ Skip to content](#capawesome-teamcapacitor-media-session) 

[ 🎉 Introducing **Capawesome Platform** — one platform for Live Updates, Native Builds, App Store Publishing, and Insider SDKs.](https://capawesome.io) 

* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* [  Grafana Faro ](/docs/plugins/grafana-faro/)
* [  libSQL ](/docs/plugins/libsql/)
* [  Live Update ](/docs/plugins/live-update/)
* [  Managed Configurations ](/docs/plugins/managed-configurations/)
* Media Session [  Media Session ](/docs/plugins/media-session/)
* [  Configuration ](#configuration)
* [  Usage ](#usage)
* [  API ](#api)
* [  Enums ](#enums)
* [  Changelog ](#changelog)
* [  Breaking Changes ](#breaking-changes)
* [  License ](#license)
* [  ML Kit ](/docs/plugins/mlkit/)
* [  Navigation Bar ](/docs/plugins/navigation-bar/)
* [  NFC ](/docs/plugins/nfc/)
* [  OAuth ](/docs/plugins/oauth/)
* [  Pedometer ](/docs/plugins/pedometer/)
* [  Photo Editor ](/docs/plugins/photo-editor/)
* [  PostHog ](/docs/plugins/posthog/)
* [  Printer ](/docs/plugins/printer/)
* [  Purchases ](/docs/plugins/purchases/)
* [  RealtimeKit ](/docs/plugins/realtimekit/)
* [  Screen Orientation ](/docs/plugins/screen-orientation/)
* [  Screenshot ](/docs/plugins/screenshot/)
* [  Secure Preferences ](/docs/plugins/secure-preferences/)
* [  Speech Recognition ](/docs/plugins/speech-recognition/)
* [  Speech Synthesis ](/docs/plugins/speech-synthesis/)
* [  Share Target ](/docs/plugins/share-target/)
* [  Square Mobile Payments ](/docs/plugins/square-mobile-payments/)
* [  SQLite ](/docs/plugins/sqlite/)
* [  Superwall ](/docs/plugins/superwall/)
* [  Torch ](/docs/plugins/torch/)
* [  Wifi ](/docs/plugins/wifi/)
* [  Zip ](/docs/plugins/zip/)
* [  Cloud ](/docs/cloud/)
* [  Live Updates ](/docs/cloud/live-updates/)
* Advanced
* Integrations
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Configuration ](/docs/cloud/native-builds/configuration/)
* [  Environments ](/docs/cloud/native-builds/environments/)
* Guides
* [  Sample Projects ](/docs/cloud/native-builds/sample-projects/)
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  Automations ](/docs/cloud/automations/)
* [  Assist ](/docs/cloud/assist/)
* Account
* Organizations
* [  Organization and User Management ](/docs/cloud/organizations/memberships/)
* [  Single Sign-On (SSO) ](/docs/cloud/organizations/sso/)
* [  Teams ](/docs/cloud/organizations/teams/)
* [  Two-Factor Authentication ](/docs/cloud/organizations/two-factor-authentication/)
* [  Integrations ](/docs/cloud/integrations/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Pricing ](https://capawesome.io/pricing/)
* [  FAQ ](/docs/cloud/faq/)
* [  Support ](/docs/cloud/support/)
* [  Contributing ](/docs/contributing/)
* [  LLMs ](/docs/llms/)
* [  Insiders ](/docs/insiders/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/insiders/support/)
* [  FAQ ](/docs/insiders/faq/)
* [  Blog ](/blog/)
* Categories

* [  Configuration ](#configuration)
* [  Usage ](#usage)
* [  API ](#api)
* [  Enums ](#enums)
* [  Changelog ](#changelog)
* [  Breaking Changes ](#breaking-changes)
* [  License ](#license)

# @capawesome-team/capacitor-media-session[¶](#capawesome-teamcapacitor-media-session "Permanent link")

Capacitor plugin to interact with media controllers, volume keys and media buttons.

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](../../assets/external/cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.69628c3f.png) ](https://cloud.capawesome.io/) 

## Features[¶](#features "Permanent link")

We are proud to offer one of the most complete and feature-rich Capacitor plugins for media sessions. Here are some of the key features:

* 🖥️ **Cross-platform**: Supports Android, iOS and Web.
* 🎮 **Media Controls**: Handle hardware media keys, lock screen controls, and notification controls.
* 🎵 **Rich Metadata**: Display song title, artist, album, and artwork on lock screen and notifications.
* 🎨 **Customizable Icon**: Configure the notification icon on Android to match your app's branding.
* ▶️ **Action Handlers**: Support for play, pause, seek, next/previous track, and more.
* 📍 **Position State**: Track and display playback position, duration, and playback rate.
* 🔧 **Native APIs**: Uses MediaSession API on Android and MPNowPlayingInfoCenter on iOS for the best possible integration.
* 🤝 **Compatibility**: Compatible with the [Audio Player](https://capawesome.io/docs/plugins/audio-player/) plugin.
* 📦 **CocoaPods & SPM**: Supports CocoaPods and Swift Package Manager for iOS.
* 🔁 **Up-to-date**: Always supports the latest Capacitor version.
* ⭐️ **Support**: Priority support from the Capawesome Team.
* ✨ **Handcrafted**: Built from the ground up with care and expertise, not forked or AI-generated.

Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 8.x.x          | \>=8.x.x          | Active support |
| 0.1.x          | 7.x.x             | Deprecated     |

## Demo[¶](#demo "Permanent link")

| Android                                                                                            | iOS                                                                                        | Web                                                                                        |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| ![Android Demo](https://capawesome.io/docs/assets/images/gifs/capacitor-media-session-android.gif) | ![iOS Demo](https://capawesome.io/docs/assets/images/gifs/capacitor-media-session-ios.gif) | ![Web Demo](https://capawesome.io/docs/assets/images/gifs/capacitor-media-session-web.gif) |

## Installation[¶](#installation "Permanent link")

This plugin is only available to [Capawesome Insiders](https://capawesome.io/insiders/). First, make sure you have the Capawesome npm registry set up. You can do this by running the following commands:

`[](#%5F%5Fcodelineno-0-1)npm config set @capawesome-team:registry https://npm.registry.capawesome.io
[](#%5F%5Fcodelineno-0-2)npm config set //npm.registry.capawesome.io/:_authToken <YOUR_LICENSE_KEY>
`

**Attention**: Replace `<YOUR_LICENSE_KEY>` with the license key you received from Polar. If you don't have a license key yet, you can get one by becoming a [Capawesome Insider](https://capawesome.io/insiders/).

Next, you can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-1-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-2-1)Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome-team/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:

`[](#%5F%5Fcodelineno-3-1)npm install @capawesome-team/capacitor-media-session
[](#%5F%5Fcodelineno-3-2)npx cap sync
`

### Android[¶](#android "Permanent link")

#### Variables[¶](#variables "Permanent link")

If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:

* `$androidMediaVersion` version of `androidx.media:media` (default: `1.7.1`)

## Configuration[¶](#configuration "Permanent link")

These configuration options are available:

| Prop          | Type   | Description                                                                                                                                                                                                                                             | Default           | Since |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- |
| **smallIcon** | string | The name of the drawable resource to use as the small icon in the media notification. Only available on Android. The resource name should not include the R.drawable. prefix or file extension. If the resource is not found, the default icon is used. | "ic\_media\_play" | 8.1.0 |

### Examples[¶](#examples "Permanent link")

In `capacitor.config.ts`:

`[](#%5F%5Fcodelineno-4-1)import type { CapacitorConfig } from '@capacitor/cli';
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)const config: CapacitorConfig = {
[](#%5F%5Fcodelineno-4-4)  plugins: {
[](#%5F%5Fcodelineno-4-5)    MediaSession: {
[](#%5F%5Fcodelineno-4-6)      smallIcon: 'ic_notification',
[](#%5F%5Fcodelineno-4-7)    },
[](#%5F%5Fcodelineno-4-8)  },
[](#%5F%5Fcodelineno-4-9)};
[](#%5F%5Fcodelineno-4-10)
[](#%5F%5Fcodelineno-4-11)export default config;
`

In `capacitor.config.json`:

`[](#%5F%5Fcodelineno-5-1){
[](#%5F%5Fcodelineno-5-2)  "plugins": {
[](#%5F%5Fcodelineno-5-3)    "MediaSession": {
[](#%5F%5Fcodelineno-5-4)      "smallIcon": "ic_notification"
[](#%5F%5Fcodelineno-5-5)    }
[](#%5F%5Fcodelineno-5-6)  }
[](#%5F%5Fcodelineno-5-7)}
`

### Android Custom Icon Setup[¶](#android-custom-icon-setup "Permanent link")

To use a custom notification icon on Android:

1. Add your icon to `android/app/src/main/res/drawable/` (e.g., `ic_notification.png`)
2. Icon should be single-color white with transparent background for best display
3. Can use density-specific folders (`drawable-mdpi`, `drawable-hdpi`, etc.)
4. Configure the plugin in `capacitor.config.ts`:  
`[](#%5F%5Fcodelineno-6-1)const config: CapacitorConfig = {  
[](#%5F%5Fcodelineno-6-2)  plugins: {  
[](#%5F%5Fcodelineno-6-3)    MediaSession: {  
[](#%5F%5Fcodelineno-6-4)      smallIcon: 'ic_notification',  // Matches ic_notification.png  
[](#%5F%5Fcodelineno-6-5)    },  
[](#%5F%5Fcodelineno-6-6)  },  
[](#%5F%5Fcodelineno-6-7)};  
`
5. Run: `npx cap sync`

## Usage[¶](#usage "Permanent link")

`[](#%5F%5Fcodelineno-7-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-7-2)import {
[](#%5F%5Fcodelineno-7-3)  MediaSession,
[](#%5F%5Fcodelineno-7-4)  MediaSessionAction,
[](#%5F%5Fcodelineno-7-5)  MediaSessionPlaybackState
[](#%5F%5Fcodelineno-7-6)} from '@capawesome-team/capacitor-media-session';
[](#%5F%5Fcodelineno-7-7)
[](#%5F%5Fcodelineno-7-8)const setMetadata = async () => {
[](#%5F%5Fcodelineno-7-9)  await MediaSession.setMetadata({
[](#%5F%5Fcodelineno-7-10)    title: 'Test Song',
[](#%5F%5Fcodelineno-7-11)    artist: 'My Awesome Artist',
[](#%5F%5Fcodelineno-7-12)    album: 'My Awesome Album',
[](#%5F%5Fcodelineno-7-13)    artwork: [
[](#%5F%5Fcodelineno-7-14)      {
[](#%5F%5Fcodelineno-7-15)        src: 'https://example.com/cover-96x96.png',
[](#%5F%5Fcodelineno-7-16)        sizes: '96x96',
[](#%5F%5Fcodelineno-7-17)        type: 'image/png',
[](#%5F%5Fcodelineno-7-18)      },
[](#%5F%5Fcodelineno-7-19)      {
[](#%5F%5Fcodelineno-7-20)        src: 'https://example.com/cover-512x512.png',
[](#%5F%5Fcodelineno-7-21)        sizes: '512x512',
[](#%5F%5Fcodelineno-7-22)        type: 'image/png',
[](#%5F%5Fcodelineno-7-23)      },
[](#%5F%5Fcodelineno-7-24)    ],
[](#%5F%5Fcodelineno-7-25)  });
[](#%5F%5Fcodelineno-7-26)};
[](#%5F%5Fcodelineno-7-27)
[](#%5F%5Fcodelineno-7-28)const registerActions = async () => {
[](#%5F%5Fcodelineno-7-29)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-30)    action: MediaSessionAction.Play
[](#%5F%5Fcodelineno-7-31)  });
[](#%5F%5Fcodelineno-7-32)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-33)    action: MediaSessionAction.Pause
[](#%5F%5Fcodelineno-7-34)  });
[](#%5F%5Fcodelineno-7-35)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-36)    action: MediaSessionAction.SeekBackward
[](#%5F%5Fcodelineno-7-37)  });
[](#%5F%5Fcodelineno-7-38)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-39)    action: MediaSessionAction.SeekForward
[](#%5F%5Fcodelineno-7-40)  });
[](#%5F%5Fcodelineno-7-41)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-42)    action: MediaSessionAction.SeekTo
[](#%5F%5Fcodelineno-7-43)  });
[](#%5F%5Fcodelineno-7-44)  await MediaSession.registerActionHandler({
[](#%5F%5Fcodelineno-7-45)    action: MediaSessionAction.Stop
[](#%5F%5Fcodelineno-7-46)  });
[](#%5F%5Fcodelineno-7-47)};
[](#%5F%5Fcodelineno-7-48)
[](#%5F%5Fcodelineno-7-49)const setPlaybackState = async () => {
[](#%5F%5Fcodelineno-7-50)  await MediaSession.setPlaybackState({
[](#%5F%5Fcodelineno-7-51)    playbackState: MediaSessionPlaybackState.Playing,
[](#%5F%5Fcodelineno-7-52)  });
[](#%5F%5Fcodelineno-7-53)};
[](#%5F%5Fcodelineno-7-54)
[](#%5F%5Fcodelineno-7-55)const setPositionState = async () => {
[](#%5F%5Fcodelineno-7-56)  await MediaSession.setPositionState({
[](#%5F%5Fcodelineno-7-57)    duration: 180,
[](#%5F%5Fcodelineno-7-58)    playbackRate: 1.0,
[](#%5F%5Fcodelineno-7-59)    position: 30,
[](#%5F%5Fcodelineno-7-60)  });
[](#%5F%5Fcodelineno-7-61)};
[](#%5F%5Fcodelineno-7-62)
[](#%5F%5Fcodelineno-7-63)const addActionListener = () => {
[](#%5F%5Fcodelineno-7-64)  MediaSession.addListener('action', async (event) => {
[](#%5F%5Fcodelineno-7-65)    switch (event.action) {
[](#%5F%5Fcodelineno-7-66)      case MediaSessionAction.Play:
[](#%5F%5Fcodelineno-7-67)        await AudioPlayer.resume();
[](#%5F%5Fcodelineno-7-68)        await MediaSession.setPlaybackState({
[](#%5F%5Fcodelineno-7-69)          playbackState: MediaSessionPlaybackState.Playing,
[](#%5F%5Fcodelineno-7-70)        });
[](#%5F%5Fcodelineno-7-71)        break;
[](#%5F%5Fcodelineno-7-72)      case MediaSessionAction.Pause:
[](#%5F%5Fcodelineno-7-73)        await AudioPlayer.pause();
[](#%5F%5Fcodelineno-7-74)        await MediaSession.setPlaybackState({
[](#%5F%5Fcodelineno-7-75)          playbackState: MediaSessionPlaybackState.Paused,
[](#%5F%5Fcodelineno-7-76)        });
[](#%5F%5Fcodelineno-7-77)        break;
[](#%5F%5Fcodelineno-7-78)      case MediaSessionAction.SeekBackward:
[](#%5F%5Fcodelineno-7-79)        const { position: currentPos } = await AudioPlayer.getCurrentPosition();
[](#%5F%5Fcodelineno-7-80)        const offsetMs = event.seekOffset ? event.seekOffset * 1000 : 10000;
[](#%5F%5Fcodelineno-7-81)        await AudioPlayer.seekTo({
[](#%5F%5Fcodelineno-7-82)          position: Math.max(0, currentPos - offsetMs)
[](#%5F%5Fcodelineno-7-83)        });
[](#%5F%5Fcodelineno-7-84)        break;
[](#%5F%5Fcodelineno-7-85)      case MediaSessionAction.SeekForward:
[](#%5F%5Fcodelineno-7-86)        const { position: pos } = await AudioPlayer.getCurrentPosition();
[](#%5F%5Fcodelineno-7-87)        const { duration } = await AudioPlayer.getDuration();
[](#%5F%5Fcodelineno-7-88)        const offset = event.seekOffset ? event.seekOffset * 1000 : 10000;
[](#%5F%5Fcodelineno-7-89)        await AudioPlayer.seekTo({
[](#%5F%5Fcodelineno-7-90)          position: Math.min(duration, pos + offset)
[](#%5F%5Fcodelineno-7-91)        });
[](#%5F%5Fcodelineno-7-92)        break;
[](#%5F%5Fcodelineno-7-93)      case MediaSessionAction.SeekTo:
[](#%5F%5Fcodelineno-7-94)        if (event.seekTime !== undefined) {
[](#%5F%5Fcodelineno-7-95)          await AudioPlayer.seekTo({
[](#%5F%5Fcodelineno-7-96)            position: event.seekTime * 1000
[](#%5F%5Fcodelineno-7-97)          });
[](#%5F%5Fcodelineno-7-98)        }
[](#%5F%5Fcodelineno-7-99)        break;
[](#%5F%5Fcodelineno-7-100)      case MediaSessionAction.Stop:
[](#%5F%5Fcodelineno-7-101)        await AudioPlayer.stop();
[](#%5F%5Fcodelineno-7-102)        await MediaSession.setPlaybackState({
[](#%5F%5Fcodelineno-7-103)          playbackState: MediaSessionPlaybackState.None,
[](#%5F%5Fcodelineno-7-104)        });
[](#%5F%5Fcodelineno-7-105)        break;
[](#%5F%5Fcodelineno-7-106)    }
[](#%5F%5Fcodelineno-7-107)  });
[](#%5F%5Fcodelineno-7-108)};
[](#%5F%5Fcodelineno-7-109)
[](#%5F%5Fcodelineno-7-110)const removeActionListener = async () => {
[](#%5F%5Fcodelineno-7-111)  await MediaSession.unregisterActionHandler({
[](#%5F%5Fcodelineno-7-112)    action: MediaSessionAction.Play
[](#%5F%5Fcodelineno-7-113)  });
[](#%5F%5Fcodelineno-7-114)  await MediaSession.unregisterActionHandler({
[](#%5F%5Fcodelineno-7-115)    action: MediaSessionAction.Pause
[](#%5F%5Fcodelineno-7-116)  });
[](#%5F%5Fcodelineno-7-117)  await MediaSession.removeAllListeners();
[](#%5F%5Fcodelineno-7-118)};
`

## API[¶](#api "Permanent link")

* [registerActionHandler(...)](#registeractionhandler)
* [setCameraActive(...)](#setcameraactive)
* [setMetadata(...)](#setmetadata)
* [setMicrophoneActive(...)](#setmicrophoneactive)
* [setPlaybackState(...)](#setplaybackstate)
* [setPositionState(...)](#setpositionstate)
* [setSeekOffset(...)](#setseekoffset)
* [unregisterActionHandler(...)](#unregisteractionhandler)
* [addListener('action', ...)](#addlisteneraction-)
* [removeAllListeners()](#removealllisteners)
* [Interfaces](#interfaces)
* [Enums](#enums)

### registerActionHandler(...)[¶](#registeractionhandler "Permanent link")

`[](#%5F%5Fcodelineno-8-1)registerActionHandler(options: RegisterActionHandlerOptions) => Promise<void>
`

Register a handler for a media session action.

If the action handler is registered, the media session will respond to the action by calling the `action` event listener. If the action handler is not registered, the media session will not respond to the action.

Make sure to unregister the action handler when it is no longer needed.

| Param       | Type                                                          |
| ----------- | ------------------------------------------------------------- |
| **options** | [RegisterActionHandlerOptions](#registeractionhandleroptions) |

**Since:** 0.0.1

---

### setCameraActive(...)[¶](#setcameraactive "Permanent link")

`[](#%5F%5Fcodelineno-9-1)setCameraActive(options: SetCameraActiveOptions) => Promise<void>
`

Set the camera active state.

Only available on Web.

| Param       | Type                                              |
| ----------- | ------------------------------------------------- |
| **options** | [SetCameraActiveOptions](#setcameraactiveoptions) |

**Since:** 0.0.1

---

### setMetadata(...)[¶](#setmetadata "Permanent link")

`[](#%5F%5Fcodelineno-10-1)setMetadata(options: SetMetadataOptions) => Promise<void>
`

Set the metadata for the media session.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [SetMetadataOptions](#setmetadataoptions) |

**Since:** 0.0.1

---

### setMicrophoneActive(...)[¶](#setmicrophoneactive "Permanent link")

`[](#%5F%5Fcodelineno-11-1)setMicrophoneActive(options: SetMicrophoneActive) => Promise<void>
`

Set the microphone active state.

Only available on Web.

| Param       | Type                                        |
| ----------- | ------------------------------------------- |
| **options** | [SetMicrophoneActive](#setmicrophoneactive) |

**Since:** 0.0.1

---

### setPlaybackState(...)[¶](#setplaybackstate "Permanent link")

`[](#%5F%5Fcodelineno-12-1)setPlaybackState(options: SetPlaybackStateOptions) => Promise<void>
`

Set the playback state.

| Param       | Type                                                |
| ----------- | --------------------------------------------------- |
| **options** | [SetPlaybackStateOptions](#setplaybackstateoptions) |

**Since:** 0.0.1

---

### setPositionState(...)[¶](#setpositionstate "Permanent link")

`[](#%5F%5Fcodelineno-13-1)setPositionState(options: SetPositionStateOptions) => Promise<void>
`

Set the position state.

| Param       | Type                                                |
| ----------- | --------------------------------------------------- |
| **options** | [SetPositionStateOptions](#setpositionstateoptions) |

**Since:** 0.0.1

---

### setSeekOffset(...)[¶](#setseekoffset "Permanent link")

`[](#%5F%5Fcodelineno-14-1)setSeekOffset(options: SetSeekOffsetOptions) => Promise<void>
`

Set the seek offset for the `SeekForward` and `SeekBackward` actions.

The offset controls both the value emitted in the `action` event's`seekOffset` property and the offset displayed by the OS (e.g., the number badge on the iOS lock-screen skip button).

Can be called at any time; the new offset is applied immediately.

Only available on Android and iOS.

| Param       | Type                                          |
| ----------- | --------------------------------------------- |
| **options** | [SetSeekOffsetOptions](#setseekoffsetoptions) |

**Since:** 8.3.0

---

### unregisterActionHandler(...)[¶](#unregisteractionhandler "Permanent link")

`[](#%5F%5Fcodelineno-15-1)unregisterActionHandler(options: UnregisterActionHandlerOptions) => Promise<void>
`

Unregister a handler for a media session action.

If the action handler is unregistered, the media session will no longer respond to the action and the `action` event listener will no longer be called for the specific action.

| Param       | Type                                                              |
| ----------- | ----------------------------------------------------------------- |
| **options** | [UnregisterActionHandlerOptions](#unregisteractionhandleroptions) |

**Since:** 0.0.1

---

### addListener('action', ...)[¶](#addlisteneraction "Permanent link")

`[](#%5F%5Fcodelineno-16-1)addListener(eventName: 'action', listenerFunc: (event: ActionEvent) => void) => Promise<PluginListenerHandle>
`

| Param            | Type                                         |
| ---------------- | -------------------------------------------- |
| **eventName**    | 'action'                                     |
| **listenerFunc** | (event: [ActionEvent](#actionevent)) => void |

**Returns:** `Promise<[PluginListenerHandle](#pluginlistenerhandle)>`

**Since:** 0.0.1

---

### removeAllListeners()[¶](#removealllisteners "Permanent link")

`[](#%5F%5Fcodelineno-17-1)removeAllListeners() => Promise<void>
`

Remove all listeners for this plugin.

**Since:** 0.0.1

---

### Interfaces[¶](#interfaces "Permanent link")

#### RegisterActionHandlerOptions[¶](#registeractionhandleroptions "Permanent link")

| Prop       | Type                                      | Description           | Since |
| ---------- | ----------------------------------------- | --------------------- | ----- |
| **action** | [MediaSessionAction](#mediasessionaction) | The action to handle. | 0.0.1 |

#### SetCameraActiveOptions[¶](#setcameraactiveoptions "Permanent link")

| Prop       | Type    | Description                          | Since |
| ---------- | ------- | ------------------------------------ | ----- |
| **active** | boolean | Whether or not the camera is active. | 0.0.1 |

#### SetMetadataOptions[¶](#setmetadataoptions "Permanent link")

| Prop        | Type                     | Description                    | Since |
| ----------- | ------------------------ | ------------------------------ | ----- |
| **album**   | string                   | 0.0.1                          |       |
| **artist**  | string                   | 0.0.1                          |       |
| **artwork** | MediaMetadataArtwork\[\] | Only available on iOS and Web. | 0.0.1 |
| **title**   | string                   | 0.0.1                          |       |

#### MediaMetadataArtwork[¶](#mediametadataartwork "Permanent link")

| Prop      | Type   | Description                                                 | Since |
| --------- | ------ | ----------------------------------------------------------- | ----- |
| **sizes** | string | The size of the artwork.                                    | 0.0.1 |
| **src**   | string | The URL from which the user agent fetches the image's data. | 0.0.1 |
| **type**  | string | The MIME type hint for the user agent.                      | 0.0.1 |

#### SetMicrophoneActive[¶](#setmicrophoneactive%5F1 "Permanent link")

| Prop       | Type    | Description                              | Since |
| ---------- | ------- | ---------------------------------------- | ----- |
| **active** | boolean | Whether or not the microphone is active. | 0.0.1 |

#### SetPlaybackStateOptions[¶](#setplaybackstateoptions "Permanent link")

| Prop              | Type                                                    | Description                | Since |
| ----------------- | ------------------------------------------------------- | -------------------------- | ----- |
| **playbackState** | [MediaSessionPlaybackState](#mediasessionplaybackstate) | The playback state to set. | 0.0.1 |

#### SetPositionStateOptions[¶](#setpositionstateoptions "Permanent link")

| Prop             | Type   | Description                                   | Since |
| ---------------- | ------ | --------------------------------------------- | ----- |
| **duration**     | number | The duration of the media in seconds.         | 0.0.1 |
| **playbackRate** | number | The playback rate of the media.               | 0.0.1 |
| **position**     | number | The current position of the media in seconds. | 0.0.1 |

#### SetSeekOffsetOptions[¶](#setseekoffsetoptions "Permanent link")

| Prop                   | Type   | Description                                                                                                            | Default | Since |
| ---------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------- | ------- | ----- |
| **seekBackwardOffset** | number | The offset in seconds for the SeekBackward action. Must be greater than 0. If not provided, the current value is kept. | 10      | 8.3.0 |
| **seekForwardOffset**  | number | The offset in seconds for the SeekForward action. Must be greater than 0. If not provided, the current value is kept.  | 10      | 8.3.0 |

#### UnregisterActionHandlerOptions[¶](#unregisteractionhandleroptions "Permanent link")

| Prop       | Type                                      | Description               | Since |
| ---------- | ----------------------------------------- | ------------------------- | ----- |
| **action** | [MediaSessionAction](#mediasessionaction) | The action to unregister. | 0.0.1 |

#### PluginListenerHandle[¶](#pluginlistenerhandle "Permanent link")

| Prop       | Type                |
| ---------- | ------------------- |
| **remove** | () => Promise<void> |

#### ActionEvent[¶](#actionevent "Permanent link")

| Prop           | Type                                      | Description                                | Since |
| -------------- | ----------------------------------------- | ------------------------------------------ | ----- |
| **action**     | [MediaSessionAction](#mediasessionaction) | The action that was handled.               | 0.0.1 |
| **fastSeek**   | boolean                                   | Whether or not the action was a fast seek. | 0.0.1 |
| **seekOffset** | number                                    | The offset in seconds to seek to.          | 0.0.1 |
| **seekTime**   | number                                    | The time in seconds to seek to.            | 0.0.1 |

### Enums[¶](#enums "Permanent link")

#### MediaSessionAction[¶](#mediasessionaction "Permanent link")

| Members                   | Value                         | Description            | Since |
| ------------------------- | ----------------------------- | ---------------------- | ----- |
| **Play**                  | 'PLAY'                        | 0.0.1                  |       |
| **Pause**                 | 'PAUSE'                       | 0.0.1                  |       |
| **SeekBackward**          | 'SEEK\_BACKWARD'              | 0.0.1                  |       |
| **SeekForward**           | 'SEEK\_FORWARD'               | 0.0.1                  |       |
| **PreviousTrack**         | 'PREVIOUS\_TRACK'             | 0.0.1                  |       |
| **NextTrack**             | 'NEXT\_TRACK'                 | 0.0.1                  |       |
| **SkipAd**                | 'SKIP\_AD'                    | Only available on Web. | 0.0.1 |
| **Stop**                  | 'STOP'                        | 0.0.1                  |       |
| **SeekTo**                | 'SEEK\_TO'                    | 0.0.1                  |       |
| **ToggleMicrophone**      | 'TOGGLE\_MICROPHONE'          | Only available on Web. | 0.0.1 |
| **ToggleCamera**          | 'TOGGLE\_CAMERA'              | Only available on Web. | 0.0.1 |
| **ToggleScreenShare**     | 'TOGGLE\_SCREEN\_SHARE'       | Only available on Web. | 0.0.1 |
| **HangUp**                | 'HANG\_UP'                    | Only available on Web. | 0.0.1 |
| **PreviousSlide**         | 'PREVIOUS\_SLIDE'             | Only available on Web. | 0.0.1 |
| **NextSlide**             | 'NEXT\_SLIDE'                 | Only available on Web. | 0.0.1 |
| **EnterPictureInPicture** | 'ENTER\_PICTURE\_IN\_PICTURE' | Only available on Web. | 0.0.1 |
| **VoiceActivity**         | 'VOICE\_ACTIVITY'             | Only available on Web. | 0.0.1 |

#### MediaSessionPlaybackState[¶](#mediasessionplaybackstate "Permanent link")

| Members     | Value     | Since |
| ----------- | --------- | ----- |
| **None**    | 'NONE'    | 0.0.1 |
| **Paused**  | 'PAUSED'  | 0.0.1 |
| **Playing** | 'PLAYING' | 0.0.1 |

## Changelog[¶](#changelog "Permanent link")

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/media-session/CHANGELOG.md).

## Breaking Changes[¶](#breaking-changes "Permanent link")

See [BREAKING.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/media-session/BREAKING.md).

## License[¶](#license "Permanent link")

See [LICENSE](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/media-session/LICENSE).

May 17, 2026 

 Back to top 