我正在玩getUserMedia以訪問Chrome中的用戶麥克風(版本28.0.1500.72米)。當他們使用帶內置揚聲器的內置麥克風時,我可以錄製和播放用戶輸入的內容。HTML5音頻錄製不工作外部麥克風
只要我插入USB麥克風耳機,我不再能夠記錄用戶輸入。我已在私密性和內容設置下在Chrome設置中切換設備。所以鉻不會看到新插入的麥克風。我重新啓動了Chrome並在插入麥克風後再次嘗試。仍然沒有用戶輸入。
在此先感謝。
下面是我正在使用的當前代碼。
window.AudioContext = window.AudioContext||window.webkitAudioContext;
var html5Recorder;
var audioContext = new AudioContext();
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
if(navigator.getUserMedia){
navigator.getUserMedia({audio:true},handleAudioStream, audioError)
}else{
console.log('Use Flash')
}
function handleAudioStream(stream){
var mediaStream = audioContext.createMediaStreamSource(stream);
mediaStream.connect(audioContext.destination);
html5Recorder = new HTML5Recorder(mediaStream);
html5Recorder.stop();
html5Recorder.clear();
}
function audioError(error){
console.log(error);
}
function record(){
html5Recorder.record();
}
function stopRecording(){
html5Recorder.stop();
html5Recorder.exportWAV(function(e){
console.log(e);
console.log(window.URL.createObjectURL(e));
document.getElementById('audio1').src = window.URL.createObjectURL(e);
HTML5Recorder.forceDownload(e);
});
}