Simple Wrapper around Opus Recorder.
This provides a service that can be used to record, play, and export audio as a wav file, blob, or bas64 string.
ember install ember-cli-opus-recorder
- After running
recorder.start()<Promise>
you can then runrecorder.getAudio()
to get the wav file created
- recordingTime: (Default: 5000)
- Set how long recording should be before automatically stopping
- Note: If set to a falsey value you will need to call
recorder.stop()
manually recorder.set('recordingTime', <time in milliseconds>)
import Route from '@ember/routing/route';
import { inject } from '@ember/service';
export default Route.extend({
recorder: inject(),
init() {
this._super(...arguments);
let recorder = this.get('recorder');
recorder.set('recordingTime', 5000);
},
setupController(controller) {
this._super(...arguments);
let recorder = this.get('recorder');
controller.set('recorder', recorder);
},
actions: {
async record() {
let recorder = this.get('recorder');
await recorder.start();
let { base64, audioURL, blob } = await recorder.getAudio();
console.log(base64, audioURL, blob);
},
async play() {
let recorder = this.get('recorder');
recorder.play();
},
async stop() {
let recorder = this.get('recorder');
recorder.stop();
}
}
});
See the Contributing guide for details.
This project is licensed under the MIT License.