1.6.0 • Published 7 years ago

au-audio-recorder v1.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

AudioRecorder

An audio recorder written in Javascript and HTML. The main audio recorder is in the file 'AUAudioRecorder.js' which contains the AUAudioRecorder object. To see a very simple example of the audio recorder at work, navigate to the 'RecorderTester.html' file in the Example folder.

Methods

  • startRecording(): Starts the recording process. The method "requestPermission()" must be called first so that the program has permission to access the computer's microphone.
audioRec.startRecording(callback);
  • stopRecording(): Stops recording and saves the recorded audio into a variable with a file type that can be specified by another method.
audioRec.stopRecording(callback);
  • play(): Plays the recorded audio in the browser.
audioRec.play(callback);
  • pause(): Pauses the audio that is playing. when the play button is clicked again the audio will resume from where it was.
audioRec.pause(callback);
  • stop(): Stops the audio from playing and sends it back to the beginning.
audioRec.stop(callback);
  • loop(bool): Sets whether or not the audio should loop once it is played. Set the parameter "bool" to true or false for your desired option.
audioRec.loop(true,callback);
  • stepBackward(): Starts the audio from the beginning but does not pause it.
audioRec.stepBackward(callback);
  • stepForward(): Sends the audio to the end. Basically just stops it from playing by doing this.
audioRec.stepForward(callback);
  • clear(): Deletes the currently recorded audio. This is the only callback that does not return an error message.
audioRec.clear(callback);
  • isFinished(): Returns whether or not the audio is finished playing.
audioRec.isFinished();
  • requestPermission(): Asks the user for permission to access the computer’s microphone.
audioRec.requestPermission();
  • hasPermission(): Returns true/false if the user has given permission to use the computer's microphone.
audioRec.hasPermission();
  • getRecording(): Returns an audio object that contains the recorded audio.
audioRec.getRecording();
  • getRecordingFile(): Returns a Blob object that contains the recorded audio. This can be used for operations where a file is needed.
audioRec.getRecordingFile();
  • setOutputFileType(fileType): Sets the type of file that the audio will be formatted to. The "fileType" parameter is the file extension that you would like to use (i.e. mp3, wav, ogg). The default file type is mp3.
audioRec.setOutputFileType("mp3");
  • getStream(): Returns the stream used by the Web Audio API that handles the recording. This method would be useful if one would like to do other things with the Web Audio API such as drawing it on a canvas or adding sound effects.
audioRec.getStream();

How To

  • Step 1: Add the AUAudioRecorder to your web application. This can be done by using the script tag like so:
<script type="text/javascript" src="https://adeolauthman.squarespace.com/s/AUAudioRecorder.js"></script>

or by installing it with npm, as shown here:

$npm install au-audio-recorder

then, in your JavaScript file typing:

var audioRec = require('au-audio-recorder');
// Or
import audioRec from 'au-audio-recorder';
  • Step 2: Assuming you have already created buttons in your HTML file and already have your own Javascript file for your webpage, you can create a new AUAudioRecorder object and call methods from it when buttons are clicked.
var audioRec = new AUAudioRecorder();

audioRec.hasPermission( (err) => { console.log(err); } );
audioRec.requestPermission();
audioRec.startRecording( (err) => { console.log(err); } );
audioRec.stopRecording( (err) => { console.log(err); } );
audioRec.loop(true, (err) => { console.log(err); } );
audioRec.play( (err) => { console.log(err); } );
audioRec.pause( (err) => { console.log(err); } );
audioRec.stop( (err) => { console.log(err); } );
audioRec.stepBackward( (err) => { console.log(err); } );
audioRec.stepForward( (err) => { console.log(err); } );
audioRec.clear( () => { /* callback */ } );
audioRec.isFinished();
audioRec.getRecording();
audioRec.getRecordingFile();
audioRec.setOutputFileType("mp3");
audioRec.getStream();

Author

  • Year: 2016
  • Languages: HTML, Javascript
  • Programmer: Adeola Uthman
1.6.0

7 years ago

1.5.9995

7 years ago

1.5.9992

7 years ago

1.5.9991

7 years ago

1.5.999

7 years ago

1.5.998

7 years ago

1.5.997

7 years ago

1.5.996

7 years ago

1.5.995

7 years ago

1.5.99

7 years ago

1.5.98

7 years ago

1.5.975

7 years ago

1.5.97

7 years ago

1.5.96

7 years ago

1.5.95

7 years ago

1.5.94

7 years ago

1.5.93

7 years ago

1.5.92

7 years ago

1.5.91

7 years ago

1.5.9

7 years ago

1.5.89

7 years ago

1.5.88

7 years ago

1.5.87

7 years ago

1.5.86

7 years ago

1.5.85

7 years ago

1.5.8

7 years ago

1.5.75

7 years ago

1.5.7

7 years ago

1.5.696

7 years ago

1.5.695

7 years ago

1.5.69

7 years ago

1.5.65

7 years ago

1.5.6

7 years ago

1.5.55

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago