{"id":13514818,"url":"https://github.com/capacitor-community/native-audio","last_synced_at":"2025-12-30T13:15:24.665Z","repository":{"id":41971932,"uuid":"267677900","full_name":"capacitor-community/native-audio","owner":"capacitor-community","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-17T22:07:53.000Z","size":6074,"stargazers_count":108,"open_issues_count":29,"forks_count":66,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-09-29T05:29:50.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/capacitor-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS.txt","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-28T19:26:54.000Z","updated_at":"2024-09-15T20:55:07.000Z","dependencies_parsed_at":"2024-01-02T23:09:28.049Z","dependency_job_id":"31575d98-2a37-429f-9d36-c67fbad910ae","html_url":"https://github.com/capacitor-community/native-audio","commit_stats":{"total_commits":82,"total_committers":10,"mean_commits":8.2,"dds":0.5609756097560976,"last_synced_commit":"b13bd911df773802c340a7d69b7179dcf5ed7651"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":"capacitor-community/.github","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capacitor-community%2Fnative-audio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capacitor-community%2Fnative-audio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capacitor-community%2Fnative-audio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capacitor-community%2Fnative-audio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capacitor-community","download_url":"https://codeload.github.com/capacitor-community/native-audio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266565,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:01:02.218Z","updated_at":"2025-12-30T13:15:24.659Z","avatar_url":"https://github.com/capacitor-community.png","language":"Java","funding_links":[],"categories":["Java","Community plugins","Plugins"],"sub_categories":["Capacitor Community"],"readme":"\u003cp align=\"center\"\u003e\u003cbr\u003e\u003cimg src=\"https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png\" width=\"128\" height=\"128\" /\u003e\u003c/p\u003e\n\u003ch3 align=\"center\"\u003eNative Audio\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\u003cstrong\u003e\u003ccode\u003e@capacitor-community/native-audio\u003c/code\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  ⚡ Capacitor plugin for playing sounds natively.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/maintenance/yes/2025?style=flat-square\" /\u003e\n  \u003ca href=\"https://github.com/capacitor-community/native-audio/actions?query=workflow%3A%22CI%22\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/capacitor-community/native-audio/ci.yml?branch=master\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@capacitor-community/native-audio\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@capacitor-community/native-audio?style=flat-square\" /\u003e\u003c/a\u003e\n\u003cbr\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@capacitor-community/native-audio\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/@capacitor-community/native-audio?style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@capacitor-community/native-audio\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@capacitor-community/native-audio?style=flat-square\" /\u003e\u003c/a\u003e\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n\u003ca href=\"#contributors-\"\u003e\u003cimg src=\"https://img.shields.io/badge/all%20contributors-2-orange?style=flat-square\" /\u003e\u003c/a\u003e\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\u003c/p\u003e\n\n## Maintainers\n\n| Maintainer    | GitHub                                      | Social                              |\n| ------------- | ------------------------------------------- | ----------------------------------- |\n| Maxim Bazuev  | [bazuka5801](https://github.com/bazuka5801) | [Telegram](https://t.me/bazuka5801) |\n\n## Demo\n\n[![YouTube Example](https://img.youtube.com/vi/XpUGlWWtwHs/0.jpg)](https://www.youtube.com/watch?v=XpUGlWWtwHs)\n\n## Preparation\n\nAll audio place in specific platform folder\n\nAndoid: `android/app/src/assets`\n\niOS: `ios/App/App/sounds`\n\nWeb: `assets/sounds`\n\n## Installation\n\nTo use npm\n\n```bash\nnpm install @capacitor-community/native-audio\n```\n\nTo use yarn\n\n```bash\nyarn add @capacitor-community/native-audio\n```\n\nSync native files\n\n```bash\nnpx cap sync\n```\n\nOn iOS, Android and Web, no further steps are needed.\n\n## Configuration\n\nNo configuration required for this plugin.\n\u003cdocgen-config\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n\n\n\u003c/docgen-config\u003e\n\n## Supported methods\n\n| Name           | Android | iOS | Web |\n| :------------- | :------ | :-- | :-- |\n| configure      | ✅      | ✅  | ❌  |\n| preload        | ✅      | ✅  | ✅  |\n| play           | ✅      | ✅  | ✅  |\n| pause          | ✅      | ✅  | ✅  |\n| resume         | ✅      | ✅  | ✅  |\n| loop           | ✅      | ✅  | ✅  |\n| stop           | ✅      | ✅  | ✅  |\n| unload         | ✅      | ✅  | ✅  |\n| setVolume      | ✅      | ✅  | ✅  |\n| getDuration    | ✅      | ✅  | ✅  |\n| getCurrentTime | ✅      | ✅  | ✅  |\n| isPlaying      | ✅      | ✅  | ✅  |\n\n## Usage\n\n[Example repository](https://github.com/bazuka5801/native-audio-example)\nOR\nanother complete Ionic/Angular application demonstrating every plugin method is available in the **example-app** directory\n\n```typescript\nimport {NativeAudio} from '@capacitor-community/native-audio'\n\n\n/**\n * This method will load more optimized audio files for background into memory.\n * @param assetPath - relative path of the file or absolute url (file://)\n *        assetId - unique identifier of the file\n *        audioChannelNum - number of audio channels\n *        isUrl - pass true if assetPath is a `file://` url\n * @returns void\n */\nNativeAudio.preload({\n    assetId: \"fire\",\n    assetPath: \"fire.mp3\",\n    audioChannelNum: 1,\n    isUrl: false\n});\n\n/**\n * This method will play the loaded audio file if present in the memory.\n * @param assetId - identifier of the asset\n * @param time - (optional) play with seek. example: 6.0 - start playing track from 6 sec\n * @returns void\n */\nNativeAudio.play({\n    assetId: 'fire',\n    // time: 6.0 - seek time\n});\n\n/**\n * This method will loop the audio file for playback.\n * @param assetId - identifier of the asset\n * @returns void\n */\nNativeAudio.loop({\n  assetId: 'fire',\n});\n\n\n/**\n * This method will stop the audio file if it's currently playing.\n * @param assetId - identifier of the asset\n * @returns void\n */\nNativeAudio.stop({\n  assetId: 'fire',\n});\n\n/**\n * This method will unload the audio file from the memory.\n * @param assetId - identifier of the asset\n * @returns void\n */\nNativeAudio.unload({\n  assetId: 'fire',\n});\n\n/**\n * This method will set the new volume for a audio file.\n * @param assetId - identifier of the asset\n *        volume - numerical value of the volume between 0.1 - 1.0\n * @returns void\n */\nNativeAudio.setVolume({\n  assetId: 'fire',\n  volume: 0.4,\n});\n\n/**\n * this method will get the duration of an audio file.\n * only works if channels == 1\n */\nNativeAudio.getDuration({\n  assetId: 'fire'\n})\n.then(result =\u003e {\n  console.log(result.duration);\n})\n\n/**\n * this method will get the current time of a playing audio file.\n * only works if channels == 1\n */\nNativeAudio.getCurrentTime({\n  assetId: 'fire'\n});\n.then(result =\u003e {\n  console.log(result.currentTime);\n})\n\n/**\n * This method will return false if audio is paused or not loaded.\n * @param assetId - identifier of the asset\n * @returns {isPlaying: boolean}\n */\nNativeAudio.isPlaying({\n  assetId: 'fire'\n})\n.then(result =\u003e {\n  console.log(result.isPlaying);\n})\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### configure(...)\n\n```typescript\nconfigure(options: ConfigureOptions) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                                                          |\n| ------------- | ------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#configureoptions\"\u003eConfigureOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### preload(...)\n\n```typescript\npreload(options: PreloadOptions) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                                                      |\n| ------------- | --------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#preloadoptions\"\u003ePreloadOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### play(...)\n\n```typescript\nplay(options: { assetId: string; time?: number; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                                             |\n| ------------- | ------------------------------------------------ |\n| **`options`** | \u003ccode\u003e{ assetId: string; time?: number; }\u003c/code\u003e |\n\n--------------------\n\n\n### pause(...)\n\n```typescript\npause(options: { assetId: string; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n--------------------\n\n\n### resume(...)\n\n```typescript\nresume(options: { assetId: string; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n--------------------\n\n\n### loop(...)\n\n```typescript\nloop(options: { assetId: string; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n--------------------\n\n\n### stop(...)\n\n```typescript\nstop(options: { assetId: string; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n--------------------\n\n\n### unload(...)\n\n```typescript\nunload(options: { assetId: string; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n--------------------\n\n\n### setVolume(...)\n\n```typescript\nsetVolume(options: { assetId: string; volume: number; }) =\u003e Promise\u003cvoid\u003e\n```\n\n| Param         | Type                                              |\n| ------------- | ------------------------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; volume: number; }\u003c/code\u003e |\n\n--------------------\n\n\n### getCurrentTime(...)\n\n```typescript\ngetCurrentTime(options: { assetId: string; }) =\u003e Promise\u003c{ currentTime: number; }\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ currentTime: number; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### getDuration(...)\n\n```typescript\ngetDuration(options: { assetId: string; }) =\u003e Promise\u003c{ duration: number; }\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ duration: number; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### isPlaying(...)\n\n```typescript\nisPlaying(options: { assetId: string; }) =\u003e Promise\u003c{ isPlaying: boolean; }\u003e\n```\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | \u003ccode\u003e{ assetId: string; }\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ isPlaying: boolean; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### addListener('complete', ...)\n\n```typescript\naddListener(eventName: 'complete', listenerFunc: (event: { assetId: string; }) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\nListen for asset completed playing event\n\n| Param              | Type                                                  |\n| ------------------ | ----------------------------------------------------- |\n| **`eventName`**    | \u003ccode\u003e'complete'\u003c/code\u003e                               |\n| **`listenerFunc`** | \u003ccode\u003e(event: { assetId: string; }) =\u0026gt; void\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n**Since:** 5.0.1\n\n--------------------\n\n\n### Interfaces\n\n\n#### ConfigureOptions\n\n| Prop        | Type                 | Description                                       | Default            |\n| ----------- | -------------------- | ------------------------------------------------- | ------------------ |\n| **`fade`**  | \u003ccode\u003eboolean\u003c/code\u003e | Indicating whether or not to fade audio.          | \u003ccode\u003efalse\u003c/code\u003e |\n| **`focus`** | \u003ccode\u003eboolean\u003c/code\u003e | Indicating whether or not to disable mixed audio. | \u003ccode\u003efalse\u003c/code\u003e |\n\n\n#### PreloadOptions\n\n| Prop                  | Type                 |\n| --------------------- | -------------------- |\n| **`assetPath`**       | \u003ccode\u003estring\u003c/code\u003e  |\n| **`assetId`**         | \u003ccode\u003estring\u003c/code\u003e  |\n| **`volume`**          | \u003ccode\u003enumber\u003c/code\u003e  |\n| **`audioChannelNum`** | \u003ccode\u003enumber\u003c/code\u003e  |\n| **`isUrl`**           | \u003ccode\u003eboolean\u003c/code\u003e |\n\n\n#### PluginListenerHandle\n\n| Prop         | Type                                      |\n| ------------ | ----------------------------------------- |\n| **`remove`** | \u003ccode\u003e() =\u0026gt; Promise\u0026lt;void\u0026gt;\u003c/code\u003e |\n\n\u003c/docgen-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapacitor-community%2Fnative-audio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapacitor-community%2Fnative-audio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapacitor-community%2Fnative-audio/lists"}