---
description: Capacitor plugin for audio playback using the device's speakers with background support. Available on Android, iOS, and Web.
title: Capacitor Audio Player Plugin for Android, iOS & Web - Capawesome
image: https://capawesome.io/docs/assets/images/social/sdks/capacitor/audio-player.png
---

<!doctype html> 

[Skip to content ](#capacitor-audio-player-plugin) 

[📲 Introducing **Build Sharing** — get your builds onto testers' devices with a link & QR code. No account required. ](/blog/share-mobile-app-builds-with-testers/) 

* [ SDKs ](/docs/sdks/)
* [ iOS ](#ios)
* [ Usage ](#usage)
* [ API ](#api)
* [ Type Aliases ](#type-aliases)
* [ Enums ](#enums)
* [ Troubleshooting ](#troubleshooting)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ Breaking Changes ](#breaking-changes)
* [ License ](#license)
* [ Audio Recorder ](/docs/sdks/capacitor/audio-recorder/)
* [ Audio Session ](/docs/sdks/capacitor/audio-session/)
* [ Background Geolocation ](/docs/sdks/capacitor/background-geolocation/)
* [ Background Task ](/docs/sdks/capacitor/background-task/)
* [ Badge ](/docs/sdks/capacitor/badge/)
* [ Barcode Scanner ](/docs/sdks/capacitor/barcode-scanner/)
* [ Barometer ](/docs/sdks/capacitor/barometer/)
* [ Battery ](/docs/sdks/capacitor/battery/)
* [ Biometrics ](/docs/sdks/capacitor/biometrics/)
* [ Bluetooth Low Energy ](/docs/sdks/capacitor/bluetooth-low-energy/)
* [ Calendar ](/docs/sdks/capacitor/calendar/)
* [ Clipboard ](/docs/sdks/capacitor/clipboard/)
* [ Cloudinary ](/docs/sdks/capacitor/cloudinary/)
* [ Compass ](/docs/sdks/capacitor/compass/)
* [ Contacts ](/docs/sdks/capacitor/contacts/)
* [ Crisp ](/docs/sdks/capacitor/crisp/)
* [ Datetime Picker ](/docs/sdks/capacitor/datetime-picker/)
* [ Device Info ](/docs/sdks/capacitor/device-info/)
* [ Dialog ](/docs/sdks/capacitor/dialog/)
* [ Document Scanner ](/docs/sdks/capacitor/document-scanner/)
* [ Electron ](/docs/sdks/capacitor/electron/)
* [ Exif ](/docs/sdks/capacitor/exif/)
* [ Facebook Sign-In ](/docs/sdks/capacitor/facebook-sign-in/)
* [ File Compressor ](/docs/sdks/capacitor/file-compressor/)
* [ File Manager ](/docs/sdks/capacitor/file-manager/)
* [ File Opener ](/docs/sdks/capacitor/file-opener/)
* [ File Picker ](/docs/sdks/capacitor/file-picker/)
* [ File Transfer ](/docs/sdks/capacitor/file-transfer/)
* [ Firebase ](/docs/sdks/capacitor/firebase/)
* [ Formbricks ](/docs/sdks/capacitor/formbricks/)
* [ Geocoder ](/docs/sdks/capacitor/geocoder/)
* [ Geofences ](/docs/sdks/capacitor/geofences/)
* [ Google Sign-In ](/docs/sdks/capacitor/google-sign-in/)
* [ Grafana Faro ](/docs/sdks/capacitor/grafana-faro/)
* [ Gyroscope ](/docs/sdks/capacitor/gyroscope/)
* [ Haptics ](/docs/sdks/capacitor/haptics/)
* [ Health ](/docs/sdks/capacitor/health/)
* [ Home Indicator ](/docs/sdks/capacitor/home-indicator/)
* [ In-App Browser ](/docs/sdks/capacitor/in-app-browser/)
* [ Install Referrer ](/docs/sdks/capacitor/install-referrer/)
* [ Intercom ](/docs/sdks/capacitor/intercom/)
* [ Intune ](/docs/sdks/capacitor/intune/)
* [ Keep Awake ](/docs/sdks/capacitor/keep-awake/)
* [ libSQL ](/docs/sdks/capacitor/libsql/)
* [ Light Sensor ](/docs/sdks/capacitor/light-sensor/)
* [ Live Update ](/docs/sdks/capacitor/live-update/)
* [ LLM ](/docs/sdks/capacitor/llm/)
* [ Localization ](/docs/sdks/capacitor/localization/)
* [ Mail Composer ](/docs/sdks/capacitor/mail-composer/)
* [ Managed Configurations ](/docs/sdks/capacitor/managed-configurations/)
* [ MapLibre ](/docs/sdks/capacitor/maplibre/)
* [ Maps Launcher ](/docs/sdks/capacitor/maps-launcher/)
* [ Media Session ](/docs/sdks/capacitor/media-session/)
* [ ML Kit ](/docs/sdks/capacitor/mlkit/)
* [ Navigation Bar ](/docs/sdks/capacitor/navigation-bar/)
* [ Network ](/docs/sdks/capacitor/network/)
* [ NFC ](/docs/sdks/capacitor/nfc/)
* [ Node.js ](/docs/sdks/capacitor/nodejs/)
* [ OAuth ](/docs/sdks/capacitor/oauth/)
* [ Passkeys ](/docs/sdks/capacitor/passkeys/)
* [ Password Autofill ](/docs/sdks/capacitor/password-autofill/)
* [ PDF Generator ](/docs/sdks/capacitor/pdf-generator/)
* [ PDF Viewer ](/docs/sdks/capacitor/pdf-viewer/)
* [ Pedometer ](/docs/sdks/capacitor/pedometer/)
* [ Permissions ](/docs/sdks/capacitor/permissions/)
* [ Phone Dialer ](/docs/sdks/capacitor/phone-dialer/)
* [ Photo Editor ](/docs/sdks/capacitor/photo-editor/)
* [ Photo Manipulator ](/docs/sdks/capacitor/photo-manipulator/)
* [ PixLive ](/docs/sdks/capacitor/pixlive/)
* [ PostHog ](/docs/sdks/capacitor/posthog/)
* [ Printer ](/docs/sdks/capacitor/printer/)
* [ Privacy Screen ](/docs/sdks/capacitor/privacy-screen/)
* [ Proximity Sensor ](/docs/sdks/capacitor/proximity-sensor/)
* [ Purchases ](/docs/sdks/capacitor/purchases/)
* [ RealtimeKit ](/docs/sdks/capacitor/realtimekit/)
* [ Root Detection ](/docs/sdks/capacitor/root-detection/)
* [ Screen Brightness ](/docs/sdks/capacitor/screen-brightness/)
* [ Screen Orientation ](/docs/sdks/capacitor/screen-orientation/)
* [ Screen Reader ](/docs/sdks/capacitor/screen-reader/)
* [ Screenshot ](/docs/sdks/capacitor/screenshot/)
* [ Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [ Settings Launcher ](/docs/sdks/capacitor/settings-launcher/)
* [ Shake ](/docs/sdks/capacitor/shake/)
* [ Silent Mode ](/docs/sdks/capacitor/silent-mode/)
* [ SIM ](/docs/sdks/capacitor/sim/)
* [ SMS Composer ](/docs/sdks/capacitor/sms-composer/)
* [ Speech Recognition ](/docs/sdks/capacitor/speech-recognition/)
* [ Speech Synthesis ](/docs/sdks/capacitor/speech-synthesis/)
* [ Share Target ](/docs/sdks/capacitor/share-target/)
* [ Square Mobile Payments ](/docs/sdks/capacitor/square-mobile-payments/)
* [ SQLite ](/docs/sdks/capacitor/sqlite/)
* [ Superwall ](/docs/sdks/capacitor/superwall/)
* [ System WebView ](/docs/sdks/capacitor/system-webview/)
* [ Tauri ](/docs/sdks/capacitor/tauri/)
* [ Text Interaction ](/docs/sdks/capacitor/text-interaction/)
* [ Text Zoom ](/docs/sdks/capacitor/text-zoom/)
* [ Thermal State ](/docs/sdks/capacitor/thermal-state/)
* [ Toast ](/docs/sdks/capacitor/toast/)
* [ Torch ](/docs/sdks/capacitor/torch/)
* [ Vault ](/docs/sdks/capacitor/vault/)
* [ Volume ](/docs/sdks/capacitor/volume/)
* [ Wallet ](/docs/sdks/capacitor/wallet/)
* [ Watch ](/docs/sdks/capacitor/watch/)
* [ Wifi ](/docs/sdks/capacitor/wifi/)
* [ YouTube Player ](/docs/sdks/capacitor/youtube-player/)
* [ Zip ](/docs/sdks/capacitor/zip/)
* [ Cordova ](/docs/sdks/cordova/)
* [ Cloud ](/docs/cloud/)
* [ Integrations ](/docs/cloud/live-updates/integrations/)
* Concepts
* Reference
* [ Troubleshooting ](/docs/cloud/live-updates/troubleshooting/)
* [ FAQ ](/docs/cloud/live-updates/faq/)
* [ Native Builds ](/docs/cloud/native-builds/)
* [ Set Up Environments ](/docs/cloud/native-builds/environments/)
* [ Set Up Native Configurations ](/docs/cloud/native-builds/native-configurations/)
* [ Auto-Increment Build Numbers ](/docs/cloud/native-builds/auto-incrementing-build-numbers/)
* [ Configure the Web Build Script ](/docs/cloud/native-builds/web-build-script/)
* [ Build from a Monorepo ](/docs/cloud/native-builds/monorepo/)
* [ Use pnpm, Yarn, or bun ](/docs/cloud/native-builds/package-managers/)
* [ Install Private npm Packages ](/docs/cloud/native-builds/npm-private-registry/)
* [ Override the Java Version ](/docs/cloud/native-builds/override-java-version/)
* [ Custom iOS Provisioning Profiles ](/docs/cloud/native-builds/custom-ios-provisioning-profiles/)
* [ Build without Git ](/docs/cloud/native-builds/build-without-git/)
* [ Access Git Behind a Firewall ](/docs/cloud/native-builds/firewall-access/)
* [ Integrations ](/docs/cloud/native-builds/integrations/)
* Reference
* [ Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [ FAQ ](/docs/cloud/native-builds/faq/)
* [ App Store Publishing ](/docs/cloud/app-store-publishing/)
* [ Submit a Build ](/docs/cloud/app-store-publishing/submit-a-build/)
* [ Submit Automatically After a Build ](/docs/cloud/app-store-publishing/submit-automatically/)
* [ Troubleshooting ](/docs/cloud/app-store-publishing/troubleshooting/)
* [ FAQ ](/docs/cloud/app-store-publishing/faq/)
* [ Automations ](/docs/cloud/automations/)
* [ Reference ](/docs/cloud/automations/reference/)
* [ Troubleshooting ](/docs/cloud/automations/troubleshooting/)
* [ FAQ ](/docs/cloud/automations/faq/)
* [ Assist ](/docs/cloud/assist/)
* [ CLI ](/docs/cloud/cli/)
* APIs and SDKs
* [ Webhooks ](/docs/cloud/webhooks/)
* [ Integrations ](/docs/cloud/integrations/)
* Notifications
* Account
* [ Organization ](/docs/cloud/organizations/)
* [ Two-Factor Enforcement ](/docs/cloud/organizations/two-factor-authentication/)
* [ Network Restrictions ](/docs/cloud/organizations/network-restrictions/)
* [ Audit Logs ](/docs/cloud/organizations/audit-logs/)
* [ Billing ](/docs/cloud/organizations/billing/)
* [ License Keys ](/docs/cloud/license-keys/)
* [ AI ](/docs/ai/)
* [ Insiders ](/docs/insiders/)
* [ Billing & Plans ](/docs/insiders/billing-and-plans/)
* [ FAQ ](/docs/insiders/faq/)
* [ License ](https://capawesome.io/legal/eula/)
* [ Support ](/docs/support/)
* [ Contributing ](/docs/contributing/)
* Contributing code
* [ Code of Conduct ](/docs/contributing/code-of-conduct/)
* [ Questions ](https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/participating-in-a-discussion#creating-a-discussion)
* [ Blog ](/blog/)
* Categories

* [ iOS ](#ios)
* [ Usage ](#usage)
* [ API ](#api)
* [ Type Aliases ](#type-aliases)
* [ Enums ](#enums)
* [ Troubleshooting ](#troubleshooting)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ Breaking Changes ](#breaking-changes)
* [ License ](#license)

Build and Ship Mobile Apps Faster

Cloud builds, OTA live updates, and automated store releases — everything your mobile team needs in one platform.

[Start for free ](https://console.cloud.capawesome.io/?utm%5Fsource=docs&utm%5Fmedium=sidebar%5Fcta&utm%5Fcampaign=docs%5Fcta) [See our plans ](https://capawesome.io/pricing/?utm%5Fsource=docs&utm%5Fmedium=sidebar%5Fcta&utm%5Fcampaign=docs%5Fcta) 

# Capacitor Audio Player Plugin[¶](#capacitor-audio-player-plugin "Permanent link")

Capacitor plugin to play audio with background support.

[ ![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")

The Capacitor Audio Player plugin is one of the most complete audio playback solutions for Capacitor apps. Here are some of the key features:

* 🖥️ **Cross-platform**: Supports Android, iOS and Web.
* 🌙 **Background Mode**: Play audio even when the app is in the background.
* 🎵 **Audio Focus Management**: Automatically manages audio focus on Android to pause other audio sources during playback.
* ⏯️ **Full Control**: Play, pause, resume, stop, seek, and adjust volume.
* 🔂 **Loop Support**: Loop audio playback for continuous sound.
* 📋 **Playlist Mode**: Play multiple tracks sequentially with native track advancement, even in the background.
* 🎛️ **Media Session**: Control the playback from the system's media controls (e.g. notification and lock screen), even while the app is in the background.
* 🔊 **Volume Control**: Precise volume control from 0-100.
* ⏩ **Playback Speed**: Adjustable playback rate with pitch preservation.
* 🗂️ **Web Assets**: Support for web asset paths alongside file URIs and remote URLs.
* 🤝 **Compatibility**: Compatible with the [Audio Recorder](https://capawesome.io/docs/sdks/capacitor/audio-recorder/), [Media Session](https://capawesome.io/docs/sdks/capacitor/media-session/), [Speech Recognition](https://capawesome.io/docs/sdks/capacitor/speech-recognition/) and [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/) plugins.
* 📦 **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!

## Use Cases[¶](#use-cases "Permanent link")

The Audio Player plugin is typically used whenever an app needs to play audio, for example:

* **Music and podcast playback**: Play remote audio files and keep them playing while the app is in the background.
* **Voice message playback**: Play voice messages recorded with the [Audio Recorder](https://capawesome.io/docs/sdks/capacitor/audio-recorder/) plugin in chat or support apps.
* **Sound effects**: Play short sounds from your web assets with precise volume control and looping.
* **Audiobooks and learning apps**: Let users adjust the playback speed and seek to specific positions.

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

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

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

| Android | iOS |
| ------- | --- |

## 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-audio-player` 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-audio-player
[](#%5F%5Fcodelineno-3-2)npx cap sync
`

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

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

If needed, you can define the following project variables in your app's `variables.gradle` file to change the default versions of the dependencies:

* `$androidxMedia3ExoPlayerVersion` version of `androidx.media3:media3-exoplayer` (default: `1.6.1`)
* `$androidxMedia3SessionVersion` version of `androidx.media3:media3-session` (default: `1.6.1`)

#### Media Session[¶](#media-session "Permanent link")

If you want to use the media session integration (see the `metadata` option of the `play(...)` method), add the following service to your `AndroidManifest.xml` inside the `application` tag:

`[](#%5F%5Fcodelineno-4-1)<service
[](#%5F%5Fcodelineno-4-2)    android:name="io.capawesome.capacitorjs.plugins.audioplayer.AudioPlayerService"
[](#%5F%5Fcodelineno-4-3)    android:exported="false"
[](#%5F%5Fcodelineno-4-4)    android:foregroundServiceType="mediaPlayback">
[](#%5F%5Fcodelineno-4-5)    <intent-filter>
[](#%5F%5Fcodelineno-4-6)        <action android:name="androidx.media3.session.MediaSessionService" />
[](#%5F%5Fcodelineno-4-7)    </intent-filter>
[](#%5F%5Fcodelineno-4-8)</service>
`

Also, add the following permissions before or after the `application` tag:

`[](#%5F%5Fcodelineno-5-1)<!-- Required to display the media controls in a notification. -->
[](#%5F%5Fcodelineno-5-2)<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
[](#%5F%5Fcodelineno-5-3)<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
`

### iOS[¶](#ios "Permanent link")

#### Capabilities[¶](#capabilities "Permanent link")

If you want to play audio in the background, ensure `Background Modes` capability is enabled with `Audio, AirPlay, and Picture in Picture` in your Xcode project. See [Add a capability to a target](https://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more information.

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

The following examples show how to play audio from web assets, remote URLs, the file system, or a blob, how to play playlists, and how to control, seek, adjust the volume of, and inspect the playback.

### Play an audio file from your web assets or a remote URL[¶](#play-an-audio-file-from-your-web-assets-or-a-remote-url "Permanent link")

Use the `src` option to play a web asset or a remote URL. Both are supported on all platforms:

`[](#%5F%5Fcodelineno-6-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-6-2)
[](#%5F%5Fcodelineno-6-3)const playFromWebAsset = async () => {
[](#%5F%5Fcodelineno-6-4)  await AudioPlayer.play({ 
[](#%5F%5Fcodelineno-6-5)    src: '/assets/audio.mp3', 
[](#%5F%5Fcodelineno-6-6)    loop: false, 
[](#%5F%5Fcodelineno-6-7)    volume: 100, 
[](#%5F%5Fcodelineno-6-8)    position: 0 
[](#%5F%5Fcodelineno-6-9)  });
[](#%5F%5Fcodelineno-6-10)};
`

### Play an audio file from the file system[¶](#play-an-audio-file-from-the-file-system "Permanent link")

Use the `uri` option to play a file from the device's file system, for example one retrieved with the Capacitor Filesystem plugin. This option is only available on Android and iOS:

`[](#%5F%5Fcodelineno-7-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-7-2)import { Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
[](#%5F%5Fcodelineno-7-3)
[](#%5F%5Fcodelineno-7-4)const playFromNativeFile = async () => {
[](#%5F%5Fcodelineno-7-5)  const { uri } = await Filesystem.getUri({
[](#%5F%5Fcodelineno-7-6)    directory: FilesystemDirectory.Documents,
[](#%5F%5Fcodelineno-7-7)    path: 'audio.mp3',
[](#%5F%5Fcodelineno-7-8)  });
[](#%5F%5Fcodelineno-7-9)  await AudioPlayer.play({ uri, loop: false, volume: 100, position: 0 });
[](#%5F%5Fcodelineno-7-10)};
`

### Play an audio file from a blob[¶](#play-an-audio-file-from-a-blob "Permanent link")

Use the `blob` option to play a `Blob` instance, for example one fetched from a server. This option is only available on Web:

`[](#%5F%5Fcodelineno-8-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-8-2)
[](#%5F%5Fcodelineno-8-3)const playFromBlob = async () => {
[](#%5F%5Fcodelineno-8-4)  const assetUrl = 'https://www.example.com/audio.mp3';
[](#%5F%5Fcodelineno-8-5)  const response = await fetch(assetUrl);
[](#%5F%5Fcodelineno-8-6)  const blob = await response.blob();
[](#%5F%5Fcodelineno-8-7)  await AudioPlayer.play({ blob, loop: false, volume: 100, position: 0 });
[](#%5F%5Fcodelineno-8-8)};
`

### Play a playlist[¶](#play-a-playlist "Permanent link")

Use the `tracks` option to play multiple tracks sequentially. The next track starts automatically when the current one ends, even in the background. Use the `startIndex` option to start playback from a specific track:

`[](#%5F%5Fcodelineno-9-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-9-2)
[](#%5F%5Fcodelineno-9-3)const playPlaylist = async () => {
[](#%5F%5Fcodelineno-9-4)  await AudioPlayer.play({
[](#%5F%5Fcodelineno-9-5)    tracks: [
[](#%5F%5Fcodelineno-9-6)      { src: '/assets/track1.mp3' },
[](#%5F%5Fcodelineno-9-7)      { src: '/assets/track2.mp3' },
[](#%5F%5Fcodelineno-9-8)      { src: '/assets/track3.mp3' },
[](#%5F%5Fcodelineno-9-9)    ],
[](#%5F%5Fcodelineno-9-10)    startIndex: 0,
[](#%5F%5Fcodelineno-9-11)  });
[](#%5F%5Fcodelineno-9-12)};
[](#%5F%5Fcodelineno-9-13)
[](#%5F%5Fcodelineno-9-14)const listenForTrackChanges = async () => {
[](#%5F%5Fcodelineno-9-15)  await AudioPlayer.addListener('trackChange', (event) => {
[](#%5F%5Fcodelineno-9-16)    console.log('Track changed to index:', event.index);
[](#%5F%5Fcodelineno-9-17)  });
[](#%5F%5Fcodelineno-9-18)};
`

### Navigate within a playlist[¶](#navigate-within-a-playlist "Permanent link")

Skip to the next or previous track, jump to a specific track, or retrieve the index of the current track:

`[](#%5F%5Fcodelineno-10-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-10-2)
[](#%5F%5Fcodelineno-10-3)const skipToNextTrack = async () => {
[](#%5F%5Fcodelineno-10-4)  await AudioPlayer.skipToNextTrack();
[](#%5F%5Fcodelineno-10-5)};
[](#%5F%5Fcodelineno-10-6)
[](#%5F%5Fcodelineno-10-7)const skipToPreviousTrack = async () => {
[](#%5F%5Fcodelineno-10-8)  await AudioPlayer.skipToPreviousTrack();
[](#%5F%5Fcodelineno-10-9)};
[](#%5F%5Fcodelineno-10-10)
[](#%5F%5Fcodelineno-10-11)const jumpToTrack = async () => {
[](#%5F%5Fcodelineno-10-12)  await AudioPlayer.seekTo({ index: 2, position: 0 });
[](#%5F%5Fcodelineno-10-13)};
[](#%5F%5Fcodelineno-10-14)
[](#%5F%5Fcodelineno-10-15)const getCurrentTrackIndex = async () => {
[](#%5F%5Fcodelineno-10-16)  const { index } = await AudioPlayer.getCurrentTrackIndex();
[](#%5F%5Fcodelineno-10-17)  console.log('Current track index:', index);
[](#%5F%5Fcodelineno-10-18)};
`

### Modify the playlist[¶](#modify-the-playlist "Permanent link")

Add tracks to the playlist or remove tracks from it while it is playing:

`[](#%5F%5Fcodelineno-11-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-11-2)
[](#%5F%5Fcodelineno-11-3)const addTracks = async () => {
[](#%5F%5Fcodelineno-11-4)  await AudioPlayer.addTracks({
[](#%5F%5Fcodelineno-11-5)    tracks: [{ src: '/assets/track4.mp3' }],
[](#%5F%5Fcodelineno-11-6)  });
[](#%5F%5Fcodelineno-11-7)};
[](#%5F%5Fcodelineno-11-8)
[](#%5F%5Fcodelineno-11-9)const removeTrack = async () => {
[](#%5F%5Fcodelineno-11-10)  await AudioPlayer.removeTrack({ index: 0 });
[](#%5F%5Fcodelineno-11-11)};
`

### Set the repeat mode[¶](#set-the-repeat-mode "Permanent link")

Repeat the current track or the entire playlist:

`[](#%5F%5Fcodelineno-12-1)import { AudioPlayer, RepeatMode } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-12-2)
[](#%5F%5Fcodelineno-12-3)const setRepeatMode = async () => {
[](#%5F%5Fcodelineno-12-4)  await AudioPlayer.setRepeatMode({ mode: RepeatMode.All });
[](#%5F%5Fcodelineno-12-5)};
`

### Control the playback from the system's media controls[¶](#control-the-playback-from-the-systems-media-controls "Permanent link")

Provide the `metadata` option to display the playback in the system's media controls (e.g. notification and lock screen). The playback can then be controlled from there, even while the app is in the background. On Android, this requires additional manifest entries (see [Installation](#installation)):

`[](#%5F%5Fcodelineno-13-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-13-2)
[](#%5F%5Fcodelineno-13-3)const playWithMediaSession = async () => {
[](#%5F%5Fcodelineno-13-4)  await AudioPlayer.play({
[](#%5F%5Fcodelineno-13-5)    tracks: [
[](#%5F%5Fcodelineno-13-6)      {
[](#%5F%5Fcodelineno-13-7)        src: 'https://example.com/track1.mp3',
[](#%5F%5Fcodelineno-13-8)        metadata: {
[](#%5F%5Fcodelineno-13-9)          album: 'The Dark Side of the Moon',
[](#%5F%5Fcodelineno-13-10)          artist: 'Pink Floyd',
[](#%5F%5Fcodelineno-13-11)          artworkSource: 'https://example.com/artwork.png',
[](#%5F%5Fcodelineno-13-12)          title: 'Time',
[](#%5F%5Fcodelineno-13-13)        },
[](#%5F%5Fcodelineno-13-14)      },
[](#%5F%5Fcodelineno-13-15)      {
[](#%5F%5Fcodelineno-13-16)        src: 'https://example.com/track2.mp3',
[](#%5F%5Fcodelineno-13-17)        metadata: {
[](#%5F%5Fcodelineno-13-18)          album: 'The Dark Side of the Moon',
[](#%5F%5Fcodelineno-13-19)          artist: 'Pink Floyd',
[](#%5F%5Fcodelineno-13-20)          artworkSource: 'https://example.com/artwork.png',
[](#%5F%5Fcodelineno-13-21)          title: 'Money',
[](#%5F%5Fcodelineno-13-22)        },
[](#%5F%5Fcodelineno-13-23)      },
[](#%5F%5Fcodelineno-13-24)    ],
[](#%5F%5Fcodelineno-13-25)  });
[](#%5F%5Fcodelineno-13-26)};
[](#%5F%5Fcodelineno-13-27)
[](#%5F%5Fcodelineno-13-28)const listenForPlaybackStateChanges = async () => {
[](#%5F%5Fcodelineno-13-29)  await AudioPlayer.addListener('playbackStateChanged', (event) => {
[](#%5F%5Fcodelineno-13-30)    console.log('Playback state changed to:', event.state);
[](#%5F%5Fcodelineno-13-31)  });
[](#%5F%5Fcodelineno-13-32)};
`

### Pause, resume and stop the playback[¶](#pause-resume-and-stop-the-playback "Permanent link")

Pause the playback and resume it later, or stop it entirely:

`[](#%5F%5Fcodelineno-14-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-14-2)
[](#%5F%5Fcodelineno-14-3)const pause = async () => {
[](#%5F%5Fcodelineno-14-4)  await AudioPlayer.pause();
[](#%5F%5Fcodelineno-14-5)};
[](#%5F%5Fcodelineno-14-6)
[](#%5F%5Fcodelineno-14-7)const resume = async () => {
[](#%5F%5Fcodelineno-14-8)  await AudioPlayer.resume();
[](#%5F%5Fcodelineno-14-9)};
[](#%5F%5Fcodelineno-14-10)
[](#%5F%5Fcodelineno-14-11)const stop = async () => {
[](#%5F%5Fcodelineno-14-12)  await AudioPlayer.stop();
[](#%5F%5Fcodelineno-14-13)};
`

### Seek to a specific position[¶](#seek-to-a-specific-position "Permanent link")

Jump to a specific position in the audio playback, given in milliseconds:

`[](#%5F%5Fcodelineno-15-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-15-2)
[](#%5F%5Fcodelineno-15-3)const seekTo = async () => {
[](#%5F%5Fcodelineno-15-4)  await AudioPlayer.seekTo({ position: 30_000 }); // Seek to 30 seconds
[](#%5F%5Fcodelineno-15-5)};
`

### Adjust the volume[¶](#adjust-the-volume "Permanent link")

Set the volume level of the current playback session to a value between 0 and 100:

`[](#%5F%5Fcodelineno-16-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-16-2)
[](#%5F%5Fcodelineno-16-3)const setVolume = async () => {
[](#%5F%5Fcodelineno-16-4)  await AudioPlayer.setVolume({ volume: 50 }); // Set volume to 50%
[](#%5F%5Fcodelineno-16-5)};
`

### Get the current playback state[¶](#get-the-current-playback-state "Permanent link")

Retrieve the current position and duration of the playback in milliseconds, and check whether the audio is currently playing:

`[](#%5F%5Fcodelineno-17-1)import { AudioPlayer } from '@capawesome-team/capacitor-audio-player';
[](#%5F%5Fcodelineno-17-2)
[](#%5F%5Fcodelineno-17-3)const getCurrentPosition = async () => {
[](#%5F%5Fcodelineno-17-4)  const { position } = await AudioPlayer.getCurrentPosition();
[](#%5F%5Fcodelineno-17-5)  console.log('Current position:', position);
[](#%5F%5Fcodelineno-17-6)};
[](#%5F%5Fcodelineno-17-7)
[](#%5F%5Fcodelineno-17-8)const getDuration = async () => {
[](#%5F%5Fcodelineno-17-9)  const { duration } = await AudioPlayer.getDuration();
[](#%5F%5Fcodelineno-17-10)  console.log('Duration:', duration);
[](#%5F%5Fcodelineno-17-11)};
[](#%5F%5Fcodelineno-17-12)
[](#%5F%5Fcodelineno-17-13)const isPlaying = async () => {
[](#%5F%5Fcodelineno-17-14)  const { isPlaying } = await AudioPlayer.isPlaying();
[](#%5F%5Fcodelineno-17-15)  console.log('Is playing:', isPlaying);
[](#%5F%5Fcodelineno-17-16)};
`

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

* [addTracks(...)](#addtracks)
* [getCurrentPosition()](#getcurrentposition)
* [getCurrentTrackIndex()](#getcurrenttrackindex)
* [getDuration()](#getduration)
* [isPlaying()](#isplaying)
* [pause()](#pause)
* [play(...)](#play)
* [removeTrack(...)](#removetrack)
* [resume()](#resume)
* [seekTo(...)](#seekto)
* [setRate(...)](#setrate)
* [setRepeatMode(...)](#setrepeatmode)
* [setVolume(...)](#setvolume)
* [skipToNextTrack()](#skiptonexttrack)
* [skipToPreviousTrack()](#skiptoprevioustrack)
* [stop(...)](#stop)
* [addListener('playbackStateChanged', ...)](#addlistenerplaybackstatechanged-)
* [addListener('stop', ...)](#addlistenerstop-)
* [addListener('trackChange', ...)](#addlistenertrackchange-)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

### addTracks(...)[¶](#addtracks "Permanent link")

`[](#%5F%5Fcodelineno-18-1)addTracks(options: AddTracksOptions) => Promise<void>
`

Add tracks to the currently loaded playlist.

Only available if a playlist has been loaded via `play({ tracks })`.

| Param       | Type                                  |
| ----------- | ------------------------------------- |
| **options** | [AddTracksOptions](#addtracksoptions) |

**Since:** 8.4.0

---

### getCurrentPosition()[¶](#getcurrentposition "Permanent link")

`[](#%5F%5Fcodelineno-19-1)getCurrentPosition() => Promise<GetCurrentPositionResult>
`

Get the current position of the audio playback in milliseconds.

**Returns:** `Promise<[GetCurrentPositionResult](#getcurrentpositionresult)>`

**Since:** 0.0.1

---

### getCurrentTrackIndex()[¶](#getcurrenttrackindex "Permanent link")

`[](#%5F%5Fcodelineno-20-1)getCurrentTrackIndex() => Promise<GetCurrentTrackIndexResult>
`

Get the index of the currently playing track within the loaded playlist.

The `index` is `undefined` if no playlist is loaded (e.g. single-track playback or nothing playing).

**Returns:** `Promise<[GetCurrentTrackIndexResult](#getcurrenttrackindexresult)>`

**Since:** 8.4.0

---

### getDuration()[¶](#getduration "Permanent link")

`[](#%5F%5Fcodelineno-21-1)getDuration() => Promise<GetDurationResult>
`

Get the duration of the audio playback in milliseconds.

**Returns:** `Promise<[GetDurationResult](#getdurationresult)>`

**Since:** 0.0.1

---

### isPlaying()[¶](#isplaying "Permanent link")

`[](#%5F%5Fcodelineno-22-1)isPlaying() => Promise<IsPlayingResult>
`

Check whether the audio is currently playing.

**Returns:** `Promise<[IsPlayingResult](#isplayingresult)>`

**Since:** 0.0.1

---

### pause()[¶](#pause "Permanent link")

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

Pause the audio playback.

**Since:** 0.0.1

---

### play(...)[¶](#play "Permanent link")

`[](#%5F%5Fcodelineno-24-1)play(options: PlayOptions) => Promise<void>
`

Play the audio playback.

| Param       | Type                        |
| ----------- | --------------------------- |
| **options** | [PlayOptions](#playoptions) |

**Since:** 0.0.1

---

### removeTrack(...)[¶](#removetrack "Permanent link")

`[](#%5F%5Fcodelineno-25-1)removeTrack(options: RemoveTrackOptions) => Promise<void>
`

Remove a track from the currently loaded playlist.

If the currently playing track is removed, playback continues with the track that takes its place, or stops if it was the last track.

Only available if a playlist has been loaded via `play({ tracks })`.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [RemoveTrackOptions](#removetrackoptions) |

**Since:** 8.4.0

---

### resume()[¶](#resume "Permanent link")

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

Resume the audio playback.

**Since:** 0.0.1

---

### seekTo(...)[¶](#seekto "Permanent link")

`[](#%5F%5Fcodelineno-27-1)seekTo(options: SeekToOptions) => Promise<void>
`

Seek to a specific position and/or track within the current playback.

Provide `position` to seek within the current track, `index` to jump to a different track in the currently loaded playlist, or both to do both at once. If neither is provided, the call is a no-op.

Play state is preserved: if the player was paused, it stays paused at the new location; call `resume()` afterwards to start playback.

| Param       | Type                            |
| ----------- | ------------------------------- |
| **options** | [SeekToOptions](#seektooptions) |

**Since:** 0.0.1

---

### setRate(...)[¶](#setrate "Permanent link")

`[](#%5F%5Fcodelineno-28-1)setRate(options: SetRateOptions) => Promise<void>
`

Set the playback rate for the audio playback.

This only affects the current playback session and is not persisted.

Only available on Android, iOS and Web.

| Param       | Type                              |
| ----------- | --------------------------------- |
| **options** | [SetRateOptions](#setrateoptions) |

**Since:** 8.2.0

---

### setRepeatMode(...)[¶](#setrepeatmode "Permanent link")

`[](#%5F%5Fcodelineno-29-1)setRepeatMode(options: SetRepeatModeOptions) => Promise<void>
`

Set the repeat mode for the current playback.

This only affects the current playback session and is not persisted.

| Param       | Type                                          |
| ----------- | --------------------------------------------- |
| **options** | [SetRepeatModeOptions](#setrepeatmodeoptions) |

**Since:** 8.4.0

---

### setVolume(...)[¶](#setvolume "Permanent link")

`[](#%5F%5Fcodelineno-30-1)setVolume(options: SetVolumeOptions) => Promise<void>
`

Set the volume level for the audio playback.

This only affects the current playback session and is not persisted.

| Param       | Type                                  |
| ----------- | ------------------------------------- |
| **options** | [SetVolumeOptions](#setvolumeoptions) |

**Since:** 0.0.1

---

### skipToNextTrack()[¶](#skiptonexttrack "Permanent link")

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

Skip to the next track in the currently loaded playlist.

If the repeat mode is `ALL`, skipping past the last track wraps around to the first track.

Only available if a playlist has been loaded via `play({ tracks })`.

**Since:** 8.4.0

---

### skipToPreviousTrack()[¶](#skiptoprevioustrack "Permanent link")

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

Skip to the previous track in the currently loaded playlist.

If the repeat mode is `ALL`, skipping before the first track wraps around to the last track.

Only available if a playlist has been loaded via `play({ tracks })`.

**Since:** 8.4.0

---

### stop(...)[¶](#stop "Permanent link")

`[](#%5F%5Fcodelineno-33-1)stop(options?: StopOptions | undefined) => Promise<void>
`

Stop the audio playback.

| Param       | Type                        |
| ----------- | --------------------------- |
| **options** | [StopOptions](#stopoptions) |

**Since:** 0.0.1

---

### addListener('playbackStateChanged', ...)[¶](#addlistenerplaybackstatechanged "Permanent link")

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

Called when the playback state changes, for example when the user pauses the playback via the media controls on the lock screen.

| Param            | Type                                                                     |
| ---------------- | ------------------------------------------------------------------------ |
| **eventName**    | 'playbackStateChanged'                                                   |
| **listenerFunc** | (event: [PlaybackStateChangedEvent](#playbackstatechangedevent)) => void |

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

**Since:** 8.4.0

---

### addListener('stop', ...)[¶](#addlistenerstop "Permanent link")

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

Called when the audio has stopped playing.

| Param            | Type       |
| ---------------- | ---------- |
| **eventName**    | 'stop'     |
| **listenerFunc** | () => void |

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

**Since:** 0.2.2

---

### addListener('trackChange', ...)[¶](#addlistenertrackchange "Permanent link")

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

Called when the current track changes during playlist playback.

| Param            | Type                                                   |
| ---------------- | ------------------------------------------------------ |
| **eventName**    | 'trackChange'                                          |
| **listenerFunc** | (event: [TrackChangeEvent](#trackchangeevent)) => void |

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

**Since:** 8.4.0

---

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

#### AddTracksOptions[¶](#addtracksoptions "Permanent link")

| Prop       | Type           | Description                                                                                                           | Since |
| ---------- | -------------- | --------------------------------------------------------------------------------------------------------------------- | ----- |
| **index**  | number         | The 0-based index at which to insert the tracks. If not provided, the tracks are appended to the end of the playlist. | 8.4.0 |
| **tracks** | AudioTrack\[\] | The tracks to add to the playlist.                                                                                    | 8.4.0 |

#### AudioTrack[¶](#audiotrack "Permanent link")

| Prop         | Type                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                         | Since |
| ------------ | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **blob**     | [Blob](#blob)                   | The audio file to play. Only available on Web.                                                                                                                                                                                                                                                                                                                                                                                                      | 8.4.0 |
| **metadata** | [TrackMetadata](#trackmetadata) | The metadata of the track, displayed in the system's media controls (e.g. notification and lock screen). Providing metadata activates the media session integration so that the playback can be controlled from the system's media controls, even while the app is in the background. On Android, this requires additional manifest entries. See the [documentation](https://capawesome.io/docs/sdks/capacitor/audio-player/) for more information. | 8.4.0 |
| **src**      | string                          | The path to the web asset file or a remote URL. Both web assets and remote URLs are supported on all platforms.                                                                                                                                                                                                                                                                                                                                     | 8.4.0 |
| **uri**      | string                          | The URI or path of the audio file to play. Only available on Android and iOS.                                                                                                                                                                                                                                                                                                                                                                       | 8.4.0 |

#### Blob[¶](#blob "Permanent link")

A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on [Blob](#blob), inheriting blob functionality and expanding it to support files on the user's system.

| Prop     | Type   |
| -------- | ------ |
| **size** | number |
| **type** | string |

| Method          | Signature                                   |                                 |                             |
| --------------- | ------------------------------------------- | ------------------------------- | --------------------------- |
| **arrayBuffer** | () => Promise<[ArrayBuffer](#arraybuffer)\> |                                 |                             |
| **slice**       | (start?: number \| undefined, end?: number  | undefined, contentType?: string | undefined) => [Blob](#blob) |
| **stream**      | () => [ReadableStream](#readablestream)     |                                 |                             |
| **text**        | () => Promise<string>                       |                                 |                             |

#### ArrayBuffer[¶](#arraybuffer "Permanent link")

Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.

| Prop           | Type   | Description                                                          |
| -------------- | ------ | -------------------------------------------------------------------- |
| **byteLength** | number | Read-only. The length of the [ArrayBuffer](#arraybuffer) (in bytes). |

| Method    | Signature                                                                 | Description                                          |
| --------- | ------------------------------------------------------------------------- | ---------------------------------------------------- |
| **slice** | (begin: number, end?: number \| undefined) => [ArrayBuffer](#arraybuffer) | Returns a section of an [ArrayBuffer](#arraybuffer). |

#### ReadableStream[¶](#readablestream "Permanent link")

This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a [ReadableStream](#readablestream) through the body property of a Response object.

| Prop       | Type    |
| ---------- | ------- |
| **locked** | boolean |

| Method          | Signature                                                                                                                                                                   |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cancel**      | (reason?: any) => Promise<void>                                                                                                                                             |
| **getReader**   | () => [ReadableStreamDefaultReader](#readablestreamdefaultreader)<R>                                                                                                        |
| **pipeThrough** | <T>(transform: [ReadableWritablePair](#readablewritablepair)<T, R>, options?: [StreamPipeOptions](#streampipeoptions) \| undefined) => [ReadableStream](#readablestream)<T> |
| **pipeTo**      | (dest: [WritableStream](#writablestream)<R>, options?: [StreamPipeOptions](#streampipeoptions) \| undefined) => Promise<void>                                               |
| **tee**         | () => \[ReadableStream<R>, [ReadableStream](#readablestream)<R>\]                                                                                                           |

#### ReadableStreamDefaultReader[¶](#readablestreamdefaultreader "Permanent link")

| Method          | Signature                                                                             |
| --------------- | ------------------------------------------------------------------------------------- |
| **read**        | () => Promise<[ReadableStreamDefaultReadResult](#readablestreamdefaultreadresult)<R>> |
| **releaseLock** | () => void                                                                            |

#### ReadableStreamDefaultReadValueResult[¶](#readablestreamdefaultreadvalueresult "Permanent link")

| Prop      | Type  |
| --------- | ----- |
| **done**  | false |
| **value** | T     |

#### ReadableStreamDefaultReadDoneResult[¶](#readablestreamdefaultreaddoneresult "Permanent link")

| Prop      | Type |
| --------- | ---- |
| **done**  | true |
| **value** |      |

#### ReadableWritablePair[¶](#readablewritablepair "Permanent link")

| Prop         | Type                                 | Description                                                                                                                                                                                                                                                                                                                                                                         |
| ------------ | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **readable** | [ReadableStream](#readablestream)<R> |                                                                                                                                                                                                                                                                                                                                                                                     |
| **writable** | [WritableStream](#writablestream)<W> | Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. |

#### WritableStream[¶](#writablestream "Permanent link")

This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.

| Prop       | Type    |
| ---------- | ------- |
| **locked** | boolean |

| Method        | Signature                                                            |
| ------------- | -------------------------------------------------------------------- |
| **abort**     | (reason?: any) => Promise<void>                                      |
| **getWriter** | () => [WritableStreamDefaultWriter](#writablestreamdefaultwriter)<W> |

#### WritableStreamDefaultWriter[¶](#writablestreamdefaultwriter "Permanent link")

This Streams API interface is the object returned by [WritableStream.getWriter](#writablestream)() and once created locks the < writer to the [WritableStream](#writablestream) ensuring that no other streams can write to the underlying sink.

| Prop            | Type               |
| --------------- | ------------------ |
| **closed**      | Promise<undefined> |
| **desiredSize** | number \| null     |
| **ready**       | Promise<undefined> |

| Method          | Signature                       |
| --------------- | ------------------------------- |
| **abort**       | (reason?: any) => Promise<void> |
| **close**       | () => Promise<void>             |
| **releaseLock** | () => void                      |
| **write**       | (chunk: W) => Promise<void>     |

#### StreamPipeOptions[¶](#streampipeoptions "Permanent link")

| Prop              | Type                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **preventAbort**  | boolean                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| **preventCancel** | boolean                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| **preventClose**  | boolean                     | Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. Errors and closures of the source and destination streams propagate as follows: An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. The signal option can be set to an [AbortSignal](#abortsignal) to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. |
| **signal**        | [AbortSignal](#abortsignal) |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

#### AbortSignal[¶](#abortsignal "Permanent link")

A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.

| Prop        | Type                                                                      | Description                                                                                                    |
| ----------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| **aborted** | boolean                                                                   | Returns true if this [AbortSignal](#abortsignal)'s AbortController has signaled to abort, and false otherwise. |
| **onabort** | ((this: [AbortSignal](#abortsignal), ev: [Event](#event)) => any) \| null |                                                                                                                |

| Method                  | Signature                                                                                                                                                                                 | Description        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **addEventListener**    | <K extends "abort">(type: K, listener: (this: [AbortSignal](#abortsignal), ev: AbortSignalEventMap\[K\]) => any, options?: boolean \| [AddEventListenerOptions](#addeventlisteneroptions) | undefined) => void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING\_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING\_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT\_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **addEventListener**    | (type: string, listener: [EventListenerOrEventListenerObject](#eventlisteneroreventlistenerobject), options?: boolean \| [AddEventListenerOptions](#addeventlisteneroptions)              | undefined) => void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING\_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING\_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT\_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **removeEventListener** | <K extends "abort">(type: K, listener: (this: [AbortSignal](#abortsignal), ev: AbortSignalEventMap\[K\]) => any, options?: boolean \| [EventListenerOptions](#eventlisteneroptions)       | undefined) => void | Removes the event listener in target's event listener list with the same type, callback, and options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **removeEventListener** | (type: string, listener: [EventListenerOrEventListenerObject](#eventlisteneroreventlistenerobject), options?: boolean \| [EventListenerOptions](#eventlisteneroptions)                    | undefined) => void | Removes the event listener in target's event listener list with the same type, callback, and options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

#### AbortSignalEventMap[¶](#abortsignaleventmap "Permanent link")

| Prop        | Type            |
| ----------- | --------------- |
| **"abort"** | [Event](#event) |

#### Event[¶](#event "Permanent link")

An event which takes place in the DOM.

| Prop                 | Type                                | Description                                                                                                                                                                                                                                                |
| -------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **bubbles**          | boolean                             | Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.                                                                                                |
| **cancelBubble**     | boolean                             |                                                                                                                                                                                                                                                            |
| **cancelable**       | boolean                             | Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. |
| **composed**         | boolean                             | Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.                                                                                  |
| **currentTarget**    | [EventTarget](#eventtarget) \| null | Returns the object whose event listener's callback is currently being invoked.                                                                                                                                                                             |
| **defaultPrevented** | boolean                             | Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.                                                                                                                                                    |
| **eventPhase**       | number                              | Returns the event's phase, which is one of NONE, CAPTURING\_PHASE, AT\_TARGET, and BUBBLING\_PHASE.                                                                                                                                                        |
| **isTrusted**        | boolean                             | Returns true if event was dispatched by the user agent, and false otherwise.                                                                                                                                                                               |
| **returnValue**      | boolean                             |                                                                                                                                                                                                                                                            |
| **srcElement**       | [EventTarget](#eventtarget) \| null |                                                                                                                                                                                                                                                            |
| **target**           | [EventTarget](#eventtarget) \| null | Returns the object to which event is dispatched (its target).                                                                                                                                                                                              |
| **timeStamp**        | number                              | Returns the event's timestamp as the number of milliseconds measured relative to the time origin.                                                                                                                                                          |
| **type**             | string                              | Returns the type of event, e.g. "click", "hashchange", or "submit".                                                                                                                                                                                        |
| **AT\_TARGET**       | number                              |                                                                                                                                                                                                                                                            |
| **BUBBLING\_PHASE**  | number                              |                                                                                                                                                                                                                                                            |
| **CAPTURING\_PHASE** | number                              |                                                                                                                                                                                                                                                            |
| **NONE**             | number                              |                                                                                                                                                                                                                                                            |

| Method                       | Signature                                                           | Description                                                                                                                                                                                                                             |  |
| ---------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |  |
| **composedPath**             | () => EventTarget\[\]                                               | Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. |  |
| **initEvent**                | (type: string, bubbles?: boolean \| undefined, cancelable?: boolean | undefined) => void                                                                                                                                                                                                                      |  |
| **preventDefault**           | () => void                                                          | If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.               |  |
| **stopImmediatePropagation** | () => void                                                          | Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.                            |  |
| **stopPropagation**          | () => void                                                          | When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.                                                                                                                 |  |

#### EventTarget[¶](#eventtarget "Permanent link")

[EventTarget](#eventtarget) is a DOM interface implemented by objects that can receive events and may have listeners for them.

| Method                  | Signature                                                                                                                     | Description                                                                                                                                                                              |                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **addEventListener**    | (type: string, listener: [EventListenerOrEventListenerObject](#eventlisteneroreventlistenerobject) \| null, options?: boolean | [AddEventListenerOptions](#addeventlisteneroptions)                                                                                                                                      | undefined) => void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING\_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING\_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT\_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **dispatchEvent**       | (event: [Event](#event)) => boolean                                                                                           | Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. |                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **removeEventListener** | (type: string, callback: [EventListenerOrEventListenerObject](#eventlisteneroreventlistenerobject) \| null, options?: boolean | [EventListenerOptions](#eventlisteneroptions)                                                                                                                                            | undefined) => void | Removes the event listener in target's event listener list with the same type, callback, and options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

#### EventListener[¶](#eventlistener "Permanent link")

#### EventListenerObject[¶](#eventlistenerobject "Permanent link")

| Method          | Signature                      |
| --------------- | ------------------------------ |
| **handleEvent** | (evt: [Event](#event)) => void |

#### AddEventListenerOptions[¶](#addeventlisteneroptions "Permanent link")

| Prop        | Type    |
| ----------- | ------- |
| **once**    | boolean |
| **passive** | boolean |

#### EventListenerOptions[¶](#eventlisteneroptions "Permanent link")

| Prop        | Type    |
| ----------- | ------- |
| **capture** | boolean |

#### TrackMetadata[¶](#trackmetadata "Permanent link")

| Prop              | Type   | Description                                                                                                                      | Since |
| ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **album**         | string | The album of the track.                                                                                                          | 8.4.0 |
| **artist**        | string | The artist of the track.                                                                                                         | 8.4.0 |
| **artworkSource** | string | The source of the artwork of the track, displayed in the system's media controls. Both web assets and remote URLs are supported. | 8.4.0 |
| **title**         | string | The title of the track.                                                                                                          | 8.4.0 |

#### GetCurrentPositionResult[¶](#getcurrentpositionresult "Permanent link")

| Prop         | Type   | Description                                                 | Since |
| ------------ | ------ | ----------------------------------------------------------- | ----- |
| **position** | number | The current position of the audio playback in milliseconds. | 0.0.1 |

#### GetCurrentTrackIndexResult[¶](#getcurrenttrackindexresult "Permanent link")

| Prop      | Type   | Description                                                                                                      | Since |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------------- | ----- |
| **index** | number | The 0-based index of the currently playing track within the loaded playlist. undefined if no playlist is loaded. | 8.4.0 |

#### GetDurationResult[¶](#getdurationresult "Permanent link")

| Prop         | Type   | Description                                         | Since |
| ------------ | ------ | --------------------------------------------------- | ----- |
| **duration** | number | The duration of the audio playback in milliseconds. | 0.0.1 |

#### IsPlayingResult[¶](#isplayingresult "Permanent link")

| Prop          | Type    | Description                             | Since |
| ------------- | ------- | --------------------------------------- | ----- |
| **isPlaying** | boolean | Whether the audio is currently playing. | 0.0.1 |

#### PlayOptions[¶](#playoptions "Permanent link")

| Prop           | Type                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Default | Since |
| -------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----- |
| **blob**       | [Blob](#blob)                   | The audio file to play. If both blob and src are provided, blob takes priority. Only available on Web.                                                                                                                                                                                                                                                                                                                                                                                              |         | 0.0.1 |
| **loop**       | boolean                         | Whether to loop the audio playback. This option is ignored when tracks is provided.                                                                                                                                                                                                                                                                                                                                                                                                                 |         | 0.0.1 |
| **metadata**   | [TrackMetadata](#trackmetadata) | The metadata of the track, displayed in the system's media controls (e.g. notification and lock screen). Providing metadata activates the media session integration so that the playback can be controlled from the system's media controls, even while the app is in the background. On Android, this requires additional manifest entries. See the [documentation](https://capawesome.io/docs/sdks/capacitor/audio-player/) for more information. This option is ignored when tracks is provided. |         | 8.4.0 |
| **position**   | number                          | The position to start playback from (in milliseconds).                                                                                                                                                                                                                                                                                                                                                                                                                                              |         | 0.0.1 |
| **rate**       | number                          | The playback rate to use. Values between 0.5 and 2.0 are recommended. Other values may not be supported on all devices. Only available on Android, iOS and Web.                                                                                                                                                                                                                                                                                                                                     | 1.0     | 8.2.0 |
| **startIndex** | number                          | The 0-based index of the track to start playback from. Only meaningful when tracks is provided.                                                                                                                                                                                                                                                                                                                                                                                                     | 0       | 8.4.0 |
| **tracks**     | AudioTrack\[\]                  | A list of audio tracks to play sequentially. When provided, blob, src, and uri are ignored.                                                                                                                                                                                                                                                                                                                                                                                                         |         | 8.4.0 |
| **src**        | string                          | The path to the web asset file to play. If both blob and src are provided, blob takes priority. If both uri and src are provided, uri takes priority. Both web assets and remote URLs are supported on all platforms.                                                                                                                                                                                                                                                                               |         | 0.1.2 |
| **uri**        | string                          | The URI or path of the audio file to play. If both uri and src are provided, uri takes priority. Only available on Android and iOS.                                                                                                                                                                                                                                                                                                                                                                 |         | 0.0.1 |
| **volume**     | number                          | The volume level to set (0-100).                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | 100     | 0.0.1 |

#### RemoveTrackOptions[¶](#removetrackoptions "Permanent link")

| Prop      | Type   | Description                                                 | Since |
| --------- | ------ | ----------------------------------------------------------- | ----- |
| **index** | number | The 0-based index of the track to remove from the playlist. | 8.4.0 |

#### SeekToOptions[¶](#seektooptions "Permanent link")

| Prop         | Type   | Description                                                                                                                                           | Since |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **index**    | number | The 0-based index of the track to jump to within the currently loaded playlist. Only meaningful when a playlist has been loaded via play({ tracks }). | 8.4.0 |
| **position** | number | The position to seek to (in milliseconds). When index is also provided, this is the position within the target track.                                 | 0.0.1 |

#### SetRateOptions[¶](#setrateoptions "Permanent link")

| Prop     | Type   | Description                                                                                                             | Since |
| -------- | ------ | ----------------------------------------------------------------------------------------------------------------------- | ----- |
| **rate** | number | The playback rate to set. Values between 0.5 and 2.0 are recommended. Other values may not be supported on all devices. | 8.2.0 |

#### SetRepeatModeOptions[¶](#setrepeatmodeoptions "Permanent link")

| Prop     | Type                      | Description             | Since |
| -------- | ------------------------- | ----------------------- | ----- |
| **mode** | [RepeatMode](#repeatmode) | The repeat mode to set. | 8.4.0 |

#### SetVolumeOptions[¶](#setvolumeoptions "Permanent link")

| Prop       | Type   | Description                      | Since |
| ---------- | ------ | -------------------------------- | ----- |
| **volume** | number | The volume level to set (0-100). | 0.0.1 |

#### StopOptions[¶](#stopoptions "Permanent link")

| Prop                       | Type    | Description                                                                                                                                                                                                                                                     | Default | Since |
| -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----- |
| **deactivateAudioSession** | boolean | Whether to deactivate the audio session when stopping playback. Set to false if you intend to call play() again shortly after stopping, to avoid CoreMediaErrorDomain -16042 errors on iOS or audio focus issues on Android. Only available on Android and iOS. | true    | 8.3.0 |

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

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

#### PlaybackStateChangedEvent[¶](#playbackstatechangedevent "Permanent link")

| Prop      | Type                            | Description             | Since |
| --------- | ------------------------------- | ----------------------- | ----- |
| **state** | [PlaybackState](#playbackstate) | The new playback state. | 8.4.0 |

#### TrackChangeEvent[¶](#trackchangeevent "Permanent link")

| Prop      | Type   | Description                                 | Since |
| --------- | ------ | ------------------------------------------- | ----- |
| **index** | number | The 0-based index of the new current track. | 8.4.0 |

### Type Aliases[¶](#type-aliases "Permanent link")

#### ReadableStreamDefaultReadResult[¶](#readablestreamdefaultreadresult "Permanent link")

`[ReadableStreamDefaultReadValueResult](#readablestreamdefaultreadvalueresult)<T> | [ReadableStreamDefaultReadDoneResult](#readablestreamdefaultreaddoneresult)`

#### EventListenerOrEventListenerObject[¶](#eventlisteneroreventlistenerobject "Permanent link")

`[EventListener](#eventlistener) | [EventListenerObject](#eventlistenerobject)`

#### AbortSignal[¶](#abortsignal%5F1 "Permanent link")

`unknown`

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

#### RepeatMode[¶](#repeatmode "Permanent link")

| Members  | Value  | Description                 | Since |
| -------- | ------ | --------------------------- | ----- |
| **All**  | 'ALL'  | Repeat the entire playlist. | 8.4.0 |
| **None** | 'NONE' | Do not repeat.              | 8.4.0 |
| **One**  | 'ONE'  | Repeat the current track.   | 8.4.0 |

#### PlaybackState[¶](#playbackstate "Permanent link")

| Members     | Value     | Description              | Since |
| ----------- | --------- | ------------------------ | ----- |
| **Paused**  | 'PAUSED'  | The playback is paused.  | 8.4.0 |
| **Playing** | 'PLAYING' | The playback is playing. | 8.4.0 |
| **Stopped** | 'STOPPED' | The playback is stopped. | 8.4.0 |

## Troubleshooting[¶](#troubleshooting "Permanent link")

##### `CoreMediaErrorDomain -16042` error on iOS when calling `play()` after `stop()`[¶](#coremediaerrordomain-16042-error-on-ios-when-calling-play-after-stop "Permanent link")

When `stop()` is called, the audio session is deactivated by default. If `play()` is called shortly after, `AVAudioSession.setActive(true)` can fail with `CoreMediaErrorDomain -16042`, breaking all subsequent playback. To avoid this, set `deactivateAudioSession` to `false` in the `stop()` options:

`[](#%5F%5Fcodelineno-37-1)await AudioPlayer.stop({ deactivateAudioSession: false });
`

## FAQ[¶](#faq "Permanent link")

### Can I play audio while the app is in the background?[¶](#can-i-play-audio-while-the-app-is-in-the-background "Permanent link")

Yes, the plugin supports background playback. On iOS, you need to enable the `Background Modes` capability with `Audio, AirPlay, and Picture in Picture` in your Xcode project, as described in the [Installation](#installation) section.

### Which audio sources can I play?[¶](#which-audio-sources-can-i-play "Permanent link")

You can play web assets and remote URLs via the `src` option on all platforms. On Android and iOS, you can also play files from the device's file system via the `uri` option. On Web, you can play `Blob` instances via the `blob` option. See the [Usage](#usage) section for examples.

### How can I change the playback speed?[¶](#how-can-i-change-the-playback-speed "Permanent link")

Use the `rate` option of the `play(...)` method or call `setRate(...)` during playback. Values between 0.5 and 2.0 are recommended, as other values may not be supported on all devices. The playback rate is adjusted with pitch preservation and is available on Android (SDK 23+), iOS and Web.

### Why does playback fail with a CoreMediaErrorDomain -16042 error on iOS?[¶](#why-does-playback-fail-with-a-coremediaerrordomain-16042-error-on-ios "Permanent link")

This can happen when `play()` is called shortly after `stop()`, because the audio session is deactivated by default when stopping. Set the `deactivateAudioSession` option of the `stop(...)` method to `false` if you intend to play audio again shortly after stopping. See the [Troubleshooting](#troubleshooting) section for more details.

### Can I use this plugin together with other audio plugins?[¶](#can-i-use-this-plugin-together-with-other-audio-plugins "Permanent link")

Yes, the plugin is compatible with the [Audio Recorder](https://capawesome.io/docs/sdks/capacitor/audio-recorder/), [Media Session](https://capawesome.io/docs/sdks/capacitor/media-session/), [Speech Recognition](https://capawesome.io/docs/sdks/capacitor/speech-recognition/) and [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/) plugins. For example, you can play back a recording created with the Audio Recorder plugin.

### Can I use this plugin with Ionic, React, Vue or Angular?[¶](#can-i-use-this-plugin-with-ionic-react-vue-or-angular "Permanent link")

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

## Related Plugins[¶](#related-plugins "Permanent link")

* [Audio Recorder](https://capawesome.io/docs/sdks/capacitor/audio-recorder/): Record audio using the device's microphone.
* [Audio Session](https://capawesome.io/docs/sdks/capacitor/audio-session/): Configure and observe the iOS audio session.
* [Media Session](https://capawesome.io/docs/sdks/capacitor/media-session/): Interact with media controllers, volume keys and media buttons.
* [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/): Synthesize speech from text with voice selection, pitch, and rate control.

## 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/).

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

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

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

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

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

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

July 8, 2026 

Back to top

```json
{"@context": "https://schema.org", "@graph": [{"@type": "TechArticle", "@id": "https://capawesome.io/docs/sdks/capacitor/audio-player/#article", "headline": "Capacitor Audio Player Plugin for Android, iOS & Web", "name": "Capacitor Audio Player Plugin for Android, iOS & Web", "description": "Capacitor plugin for audio playback using the device's speakers with background support. Available on Android, iOS, and Web.", "inLanguage": "en", "url": "https://capawesome.io/docs/sdks/capacitor/audio-player/", "mainEntityOfPage": "https://capawesome.io/docs/sdks/capacitor/audio-player/", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "about": {"@id": "https://capawesome.io/docs/sdks/capacitor/audio-player/#software"}}, {"@type": "SoftwareSourceCode", "@id": "https://capawesome.io/docs/sdks/capacitor/audio-player/#software", "name": "Capacitor Audio Player Plugin for Android, iOS & Web", "description": "Capacitor plugin for audio playback using the device's speakers with background support. Available on Android, iOS, and Web.", "url": "https://capawesome.io/docs/sdks/capacitor/audio-player/", "programmingLanguage": "TypeScript", "runtimePlatform": "Capacitor", "codeRepository": "https://github.com/capawesome-team", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}}]}
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Can I play audio while the app is in the background?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin supports background playback. On iOS, you need to enable the Background Modes capability with Audio, AirPlay, and Picture in Picture in your Xcode project, as described in the Installation section."}}, {"@type": "Question", "name": "Which audio sources can I play?", "acceptedAnswer": {"@type": "Answer", "text": "You can play web assets and remote URLs via the src option on all platforms. On Android and iOS, you can also play files from the device's file system via the uri option. On Web, you can play Blob instances via the blob option. See the Usage section for examples."}}, {"@type": "Question", "name": "How can I change the playback speed?", "acceptedAnswer": {"@type": "Answer", "text": "Use the rate option of the play(...) method or call setRate(...) during playback. Values between 0.5 and 2.0 are recommended, as other values may not be supported on all devices. The playback rate is adjusted with pitch preservation and is available on Android (SDK 23+), iOS and Web."}}, {"@type": "Question", "name": "Why does playback fail with a CoreMediaErrorDomain -16042 error on iOS?", "acceptedAnswer": {"@type": "Answer", "text": "This can happen when play() is called shortly after stop(), because the audio session is deactivated by default when stopping. Set the deactivateAudioSession option of the stop(...) method to false if you intend to play audio again shortly after stopping. See the Troubleshooting section for more details."}}, {"@type": "Question", "name": "Can I use this plugin together with other audio plugins?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin is compatible with the Audio Recorder, Media Session, Speech Recognition and Speech Synthesis plugins. For example, you can play back a recording created with the Audio Recorder plugin."}}, {"@type": "Question", "name": "Can I use this plugin with Ionic, React, Vue or Angular?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects."}}], "url": "https://capawesome.io/docs/sdks/capacitor/audio-player/"}
```
