0

在recordRTC库中调用开始录音功能时如何检测耳机和摄像头。

btnStartRecording.onclick = function() {

  btnStartRecording.disabled = true;
  captureUserMedia(function(stream) {

      mediaStream = stream;
      videoElement.src = window.URL.createObjectURL(stream);
      videoElement.play();
      videoElement.muted = true;
      videoElement.controls = false;
      // it is second parameter of the RecordRTC
      var audioConfig = {};
      if (!isRecordOnlyAudio) {
          audioConfig.onAudioProcessStarted = function() {
              // invoke video recorder in this callback
              // to get maximum sync
              videoRecorder.startRecording();
          };
      }

      audioRecorder = RecordRTC(stream, audioConfig);

      if (!isRecordOnlyAudio) {
          // it is second parameter of the RecordRTC
          var videoConfig = {type: 'video'};
          videoRecorder = RecordRTC(stream, videoConfig);
      }

      audioRecorder.startRecording();
      // enable stop-recording button
      btnStopRecording.disabled = false;
  });
};

如果 captureUserMedia 中的任何方法检测设备并返回错误消息。

4

0 回答 0