【问题标题】:getUserMedia questions - Stopping stream and local storage APIgetUserMedia 问题 - 停止流和本地存储 API
【发布时间】:2013-06-27 21:27:00
【问题描述】:

我正在为音频/视频实现 getUserMedia,然后通过 HTML5 api 通过本地存储将其保存。我有两个问题。

第一个问题是,当音频连接时,它会非常微弱地回响我的声音并且具有恒定的静态声音(在 Firefox 中测试)。是否有任何已知问题,我无法找到任何类型的答案。

还有,是否有文档停止并将 mediaStream 文件放入要通过本地存储或 ajax/php 或类似的东西保存的东西?我对如何停止然后保留文件有点迷茫。

下面是我的 JavaScript 代码和 HTML 代码...谢谢!

<section>
        <!-- <audio controls autoplay></audio> -->
        <video controls autoplay></video>
        <input id="startRecording" type="button" value="Start Recording"/>
        <input id="stopRecording" type="button" value="Stop Recording"/>
</section>




window.onload = function() {

function hasGetUserMedia() {
    //Note: opera is unprefixed
    return !!(navigator.hasGetUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
} //Check for Get User Media in browsers

function startRecording() {

        navigator.getUserMedia({audio: true, video: true},function(stream) {audio.src = window.URL.createObjectURL(stream); },onFail);
}

function stopRecording() {
    var audio  = document.querySelector('video');
    audio.src = "";Q
}

var onFail = function(e) {
    console.log("ERROR");
}
var audio  = document.querySelector('video');

if (hasGetUserMedia()) {
    //AWESOME!  Do whatever needs to be done
    window.URL = (window.URL || window.webkitURL || window.webkitURL || window.mozURL || window.msURL);
    navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia );

    var startRecord =  document.getElementById('startRecording');
    var endRecord =  document.getElementById('stopRecording');
    startRecord.onclick = startRecording;
    endRecord.onclick = stopRecording;

} else {
    alert("FAIL");
    //Put in fallback for flash/silverlight?
} //Check for getUserMedia()

} //load this stuff onload

【问题讨论】:

    标签: javascript local-storage getusermedia


    【解决方案1】:

    目前可以通过画布间接捕获视频,但尚未实现 Mediastream Recorder API。所以无论如何声音都会很难。

    至于回声,那是很有可能的。看: https://hacks.mozilla.org/2013/06/webrtc-comes-to-firefox/

    所以恐怕你还要再等一会儿。

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 2020-07-16
      • 2019-06-15
      • 2010-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多