{"id":18885658,"url":"https://github.com/nstudio/nativescript-audio-recorder","last_synced_at":"2026-02-23T08:30:25.382Z","repository":{"id":57132291,"uuid":"195692290","full_name":"nstudio/nativescript-audio-recorder","owner":"nstudio","description":"NativeScript plugin for recording audio.","archived":false,"fork":false,"pushed_at":"2019-07-08T02:34:16.000Z","size":2690,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-13T17:13:23.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-07T20:04:26.000Z","updated_at":"2020-03-02T15:08:52.000Z","dependencies_parsed_at":"2022-08-24T23:00:54.995Z","dependency_job_id":null,"html_url":"https://github.com/nstudio/nativescript-audio-recorder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstudio%2Fnativescript-audio-recorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstudio%2Fnativescript-audio-recorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstudio%2Fnativescript-audio-recorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstudio%2Fnativescript-audio-recorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nstudio","download_url":"https://codeload.github.com/nstudio/nativescript-audio-recorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239858982,"owners_count":19708857,"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-11-08T07:20:40.657Z","updated_at":"2026-02-23T08:30:25.150Z","avatar_url":"https://github.com/nstudio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca align=\"center\" href=\"https://www.npmjs.com/package/nativescript-audio-recorder\"\u003e\n    \u003ch3 align=\"center\"\u003eNativeScript Audio Recorder\u003c/h3\u003e\n\u003c/a\u003e\n\u003ch4 align=\"center\"\u003eNativeScript plugin to record audio on Android and iOS.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/nativescript-audio-recorder\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/nativescript-audio-recorder.svg\" alt=\"npm\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/nativescript-audio-recorder\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/dt/nativescript-audio-recorder.svg?label=npm%20downloads\" alt=\"npm\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/nstudio/nativescript-audio-recorder/stargazers\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/nstudio/nativescript-audio-recorder.svg\" alt=\"stars\"\u003e\n    \u003c/a\u003e\n     \u003ca href=\"https://github.com/nstudio/nativescript-audio-recorder/network\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/forks/nstudio/nativescript-audio-recorder.svg\" alt=\"forks\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/nstudio/nativescript-audio-recorder/blob/master/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/nstudio/nativescript-audio-recorder.svg\" alt=\"license\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://nstudio.io\"\u003e\n      \u003cimg src=\"https://github.com/nstudio/media/blob/master/images/nstudio-banner.png?raw=true\" alt=\"nStudio banner\"\u003e\n    \u003c/a\u003e\n    \u003ch5 align=\"center\"\u003eDo you need assistance on your project or plugin? Contact the nStudio team anytime at \u003ca href=\"mailto:team@nstudio.io\"\u003eteam@nstudio.io\u003c/a\u003e to get up to speed with the best practices in mobile and web app development.\n    \u003c/h5\u003e\n\u003c/p\u003e\n\n---\n\n## Installation\n\n`tns plugin add @nstudio/nativescript-audio-recorder`\n\n## Usage\n\n```typescript\nimport {\n  AudioRecorder,\n  AudioRecorderOptions\n} from '@nstudio/nativescript-audio-recorder';\nimport { File, knownFolders } from 'tns-core-modules/file-system';\nimport { isAndroid } from 'tns-core-modules/platform';\n\nexport class SomeClassInYourProject {\n  private _recorder: AudioRecorder;\n\n  constructor() {\n    this._recorder = new AudioRecorder();\n  }\n\n  public startRecordingAudio() {\n    if (!AudioRecorder.DEVICE_CAN_RECORD()) {\n      console.log('crud, this device cannot record audio');\n      return;\n    }\n\n    const audioFolder = knownFolders.currentApp().getFolder('audio');\n\n    let androidFormat;\n    let androidEncoder;\n    if (isAndroid) {\n      androidFormat = android.media.MediaRecorder.OutputFormat.MPEG_4;\n      androidEncoder = android.media.MediaRecorder.AudioEncoder.AAC;\n    }\n\n    const recorderOptions: AudioRecorderOptions = {\n      filename: `${audioFolder.path}/recording.${isAndroid ? 'm4a' : 'caf'}`,\n\n      format: androidFormat,\n\n      encoder: androidEncoder,\n\n      metering: true,\n\n      infoCallback: infoObject =\u003e {\n        console.log(JSON.stringify(infoObject));\n      },\n\n      errorCallback: errorObject =\u003e {\n        console.log(JSON.stringify(errorObject));\n      }\n    };\n\n    this._recorder\n      .start(recorderOptions)\n      .then(result =\u003e {\n        console.log('recording has started', result);\n      })\n      .catch(err =\u003e {\n        console.log('oh no, something is wrong and recording did not start');\n      });\n  }\n\n  public pauseRecording() {\n    this._recorder\n      .pause()\n      .then(result =\u003e {\n        console.log('recording has been paused');\n      })\n      .catch(err =\u003e {\n        console.log('recording could not be paused');\n      });\n  }\n\n  public async stopRecording() {\n    const stopResult = await this._recorder.stop().catch(err =\u003e {\n      console.log('oh no recording did not stop correctly');\n    });\n    if (stopResult) {\n      console.log('recording stopped successfully.');\n    }\n  }\n\n  public getFile() {\n    try {\n      const audioFolder = knownFolders.currentApp().getFolder('audio');\n      const recordedFile = audioFolder.getFile(\n        `recording.${isAndroid ? 'm4a' : 'caf'}`\n      );\n      console.log(JSON.stringify(recordedFile));\n      console.log('recording exists: ' + File.exists(recordedFile.path));\n      this.recordedAudioFile = recordedFile.path;\n    } catch (ex) {\n      console.log(ex);\n    }\n  }\n\n  public async disposeRecorder() {\n    const disposeResult = await this._recorder.dispose().catch(err =\u003e {\n      dialogs.alert({\n        message: `Dispose Error: ${err}`,\n        okButtonText: 'Okay'\n      });\n    });\n    console.log('disposeResult', disposeResult);\n    this._recorder = new AudioRecorder();\n  }\n}\n```\n\n## API\n\n| Method                                                  | Description                                                                                                                                                                                     |\n| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `start(options: AudioRecorderOptions):Promise\u003cboolean\u003e` | Starts recording audio from the device. Permissions are required to record. The plugin attempts to request needed permissions.                                                                  |\n| `stop():Promise\u003cboolean\u003e`                               | Stops the recording.                                                                                                                                                                            |\n| `pause():Promise\u003cboolean\u003e`                              | Pauses the recording.                                                                                                                                                                           |\n| `resume():Promise\u003cboolean\u003e`                             | Resumes the recording.                                                                                                                                                                          |\n| `dispose():Promise\u003cboolean\u003e`                            | Disposes of the audio recorder. This will release resources and null out the internal recorder. So it's best to create a new instance of the `AudioRecorder` after if you want to record again. |\n\n## Interfaces\n\n#### AudioRecorderOptions\n\n```typescript\ninterface AudioRecorderOptions {\n  /**\n   * Gets or sets the recorded file name.\n   */\n  filename: string;\n\n  /**\n   * Sets the source for recording ***ANDROID ONLY for now ***\n   */\n  source?: any;\n\n  /**\n   * Gets or set the max duration of the recording session.\n   */\n  maxDuration?: number;\n\n  /**\n   * Enable metering. Off by default.\n   */\n  metering?: boolean;\n\n  /**\n   * Format\n   */\n  format?: any;\n\n  /**\n   * Channels\n   */\n  channels?: any;\n\n  /**\n   * Sampling rate\n   */\n  sampleRate?: any;\n\n  /**\n   * Bit rate\n   */\n  bitRate?: any;\n\n  /**\n   * Encoding\n   */\n  encoder?: any;\n\n  /**\n   * Gets or sets the callback when an error occurs with the media recorder.\n   * @returns {Object} An object containing the native values for the error callback.\n   */\n  errorCallback?: Function;\n\n  /**\n   * Gets or sets the callback to be invoked to communicate some info and/or warning about the media or its playback.\n   * @returns {Object} An object containing the native values for the info callback.\n   */\n  infoCallback?: Function;\n}\n```\n\n## License\n\nApache License Version 2.0, January 2004\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstudio%2Fnativescript-audio-recorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnstudio%2Fnativescript-audio-recorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstudio%2Fnativescript-audio-recorder/lists"}