2013-07-22 75 views
1

我一直在試圖通過使用HTML5的瀏覽器錄製音頻,併成功地在Chrome中做到這一點。我想知道是否有任何這樣的API支持Firefox中的音頻錄製。我試着執行在Firefox中使用的代碼,但由於Firefox不支持AudioContext而無法使用。我正在嘗試使用WebRTC的其他功能進行一些調整,但似乎沒有任何工作。是否Firefox不支持這種錄製或我是否在錯誤的方式?

我的代碼是:在Firefox中的HTML5錄音

<html> 
<head> 
<script type="text/javascript"> 
navigator.getMedia = (navigator.getUserMedia || 
         navigator.webkitGetUserMedia || 
         navigator.mozGetUserMedia || 
         navigator.msGetUserMedia); 

navigator.getMedia (

    // constraints 
    { 
     audio: true 
    }, 

    // successCallback 
    function(localMediaStream) { 
     var video = document.querySelector('audio'); 
     video.src = window.URL.createObjectURL(localMediaStream); 
     video.onloadedmetadata = function(e) { 
     //I do my recording here.. 
     }; 
    }, 

    // errorCallback 
    function(err) { 
    console.log("The following error occured: " + err); 
    } 

); 
</script> 
</head> 
<body> 
</body> 
</html> 

回答

3

MediaRecorder API已經在Firefox Nightlies版(目前只有音頻記錄)已降落。你可以看看this repository;其中「AudioStreamRecorder/MediaRecorder.js」正是你想要的。 Try the demo

另一個例子「AudioVideoRecorder」也可用。 Try the demo

+0

你給出的例子在firefox中似乎不起作用。 –

+0

在Firefox上試試RecordRTC每晚:https://www.webrtc-experiment.com/RecordRTC/ –

+0

我可以在夜間獲得錄製功能。我正在尋找正常的Firefox。無論如何,firefox將在其下一個版本中根據其網站發佈對AudioContext的支持。那麼生活會更簡單!謝謝(你的)信息。 –