Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var successCallback = function(stream) {
var options = {
type: "audio",
mimeType: "audio/webm",
audioBitsPerSecond: 44100,
sampleRate: 44100,
bufferSize: 16384,
numberOfAudioChannels: 1
};
console.log("successCallback");
question.survey.mystream = stream;
question.survey.recordRTC = RecordRTC(
question.survey.mystream,
options
);
if (typeof question.survey.recordRTC != "undefined") {
console.log("startRecording");
question.survey.recordRTC.startRecording();
}
};
const startRecording = ({canvas, video, x, y, width, height, availTop}) => {
const recorder = RecordRTC(canvas, {type: 'canvas'});
const ctx = canvas.getContext('2d');
const stopLoop = getLoop(() => drawFrame({ctx, video, x, y, width, height, availTop}));
recorder.startRecording();
return {
stop() {
return new Promise(resolve => {
stopLoop();
recorder.stopRecording(() => {
recorder.getDataURL(url => resolve({url, width, height}));
});
});
},
pause() {
recorder.pauseRecording();
navigator.getUserMedia({ audio: true, video: false }, (stream) => {
recorder = new RecordRTC(stream, {
recorderType: RecordRTC.StereoAudioRecorder,
type: 'audio',
audioType: 'audio/wav',
mimeType: 'audio/wav',
sampleRate: 44100,
numberOfAudioChannels: 1,
});
recorder.setRecordingDuration(DURATION).onRecordingStopped(() => {
dispatch(stopRecording());
});
recorder.startRecording();
}, () => {
dispatch(openAlert('cannotActivateMicrophone'));
captureUserMedia((stream) => {
this.setState({ mediaStream: stream });
this.state.recordVideo = RecordRTC(stream, {
type: 'video'
});
this.state.recordVideo.startRecording();
});