GithubHelp home page GithubHelp logo

alssl-ross / cordova-plugin-audio-recorder-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevinwang15/cordova-plugin-audio-recorder-api

3.0 4.0 4.0 31 KB

This plugin is a Cordova audio recorder plugin which works as API.

Java 45.85% Objective-C 44.40% JavaScript 9.75%

cordova-plugin-audio-recorder-api's Introduction

Cordova Audio Recorder API Plugin

Join the chat at https://gitter.im/emj365/cordova-plugin-audio-recorder-api

Introduction:

This plugin is a Cordova audio recorder plugin that works as API.

Different than http://plugins.cordova.io/#/package/org.apache.cordova.media-capture this plugin does not request the native recorder app (system default recorder) and active recording manually.

**This is a fork of https://github.com/emj365/cordova-plugin-audio-recorder-api. This fork adds support for Android 6.0+ permissions and increases the quality of the iOS recording.

Without the Android 6.0+ permission fix, an error of "setAudioSource failed" occurs when recording is attempted.**

Supports platforms:

  • iOS
  • Android

How to use:

var recorder = new Object;
recorder.stop = function() {
  window.plugins.audioRecorderAPI.stop(function(msg) {
    // success
    alert('ok: ' + msg);
  }, function(msg) {
    // failed
    alert('ko: ' + msg);
  });
}
recorder.record = function() {
  window.plugins.audioRecorderAPI.record(function(msg) {
    // complete
    alert('ok: ' + msg);
  }, function(msg) {
    // failed
    alert('ko: ' + msg);
  }, 30); // record 30 seconds
}
recorder.playback = function() {
  window.plugins.audioRecorderAPI.playback(function(msg) {
    // complete
    alert('ok: ' + msg);
  }, function(msg) {
    // failed
    alert('ko: ' + msg);
  });
}
window.plugins.audioRecorderAPI.dopermissions(function (msg) {
		    // success
		    console.log('Audio permissions ok: ' + msg);
		}, function (msg) {
		    // failed
		    console.error("audioRecorderAPI: permission not granted");
		    alert("The app needs access to your microphone to function.");
		});

Where are files saved?

iOS: /var/mobile/Applications/<UUID>/Library/NoCloud/<file-id>.m4a Android: /data/data/<app-id>/files/<file-id>.m4a

Copy File to Another Place

Example with file plugin: http://ngcordova.com/docs/plugins/file/

iOS: /var/mobile/Applications/<UUID>/Documents/new_file.m4a Android: <sdcard>/new_file.m4a

window.plugins.audioRecorderAPI.record(function(savedFilePath) {
  var fileName = savedFilePath.split('/')[savedFilePath.split('/').length - 1];
  var directory;
  if (cordova.file.documentsDirectory) {
    directory = cordova.file.documentsDirectory; // for iOS
  } else {
    directory = cordova.file.externalRootDirectory; // for Android
  }
  $cordovaFile.copyFile(
    cordova.file.dataDirectory, fileName,
    directory, "new_file.m4a"
  )
    .then(function (success) {
      alert(JSON.stringify(success));
    }, function (error) {
      alert(JSON.stringify(error));
    });
}, function(msg) {
  alert('ko: ' + msg);
}, 3);

cordova-plugin-audio-recorder-api's People

Contributors

alssl-ross avatar danwithams7d avatar emj365 avatar gitter-badger avatar kevinwang15 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.