首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HTML5的音频录制getUserMedia现在可以工作了吗?

HTML5的音频录制getUserMedia现在可以工作了吗?
EN

Stack Overflow用户
提问于 2012-05-29 07:27:48
回答 3查看 10.3K关注 0票数 16

我已经搜索了很多关于getUserMedia的演示和例子,但大多数只是摄像头捕捉,而不是麦克风。

所以我下载了一些例子,并在我自己的电脑上尝试,相机捕捉是工作的,但当我改变

代码语言:javascript
复制
navigator.webkitGetUserMedia({video : true},gotStream);

代码语言:javascript
复制
navigator.webkitGetUserMedia({audio : true},gotStream);

浏览器要求我先允许麦克风访问,然后在

代码语言:javascript
复制
document.getElementById("audio").src = window.webkitURL.createObjectURL(stream); 

传达的信息是:

代码语言:javascript
复制
GET blob:http%3A//localhost/a5077b7e-097a-4281-b444-8c1d3e327eb4 404 (Not Found)

这是我的代码:getUserMedia_simple_audio_test

我做错什么了吗?或者现在只有getUserMedia可以在摄像头上工作了?

EN

回答 3

Stack Overflow用户

发布于 2012-10-29 21:17:29

它目前在Chrome Canary中被支持。您需要在地址栏中键入about:flag,然后启用Web Audio Input。

下面的代码将音频输入连接到扬声器。注意反馈!

代码语言:javascript
复制
<script>
// this is to store a reference to the input so we can kill it later 
var liveSource;
// creates an audiocontext and hooks up the audio input
function connectAudioInToSpeakers(){
  var context = new webkitAudioContext();  
  navigator.webkitGetUserMedia({audio: true}, function(stream) {
    console.log("Connected live audio input");
    liveSource = context.createMediaStreamSource(stream);
    liveSource.connect(context.destination);
  });
 }
// disconnects the audio input
function makeItStop(){
   console.log("killing audio!");
   liveSource.disconnect();
 }
// run this when the page loads
connectAudioInToSpeakers();
</script>
<input type="button" value="please make it stop!" onclick="makeItStop()"/>
票数 5
EN

Stack Overflow用户

发布于 2012-10-29 21:25:35

(对不起,我忘记登录了,所以请使用我的正确用户名...)

它目前在Chrome Canary中被支持。您需要在地址栏中键入about:flags,然后启用网络音频输入。

下面的代码将音频输入连接到扬声器。注意反馈!

http://jsfiddle.net/2mLtM/

代码语言:javascript
复制
<script>
// this is to store a reference to the input so we can kill it later 
var liveSource;
// creates an audiocontext and hooks up the audio input
function connectAudioInToSpeakers(){
  var context = new webkitAudioContext();  
  navigator.webkitGetUserMedia({audio: true}, function(stream) {
    console.log("Connected live audio input");
    liveSource = context.createMediaStreamSource(stream);
    liveSource.connect(context.destination);
  });
 }
// disconnects the audio input
function makeItStop(){
   console.log("killing audio!");
   liveSource.disconnect();
 }
// run this when the page loads
connectAudioInToSpeakers();
</script>
<input type="button" value="please make it stop!" onclick="makeItStop()"/>
票数 1
EN

Stack Overflow用户

发布于 2012-07-23 03:45:01

工作正常,只需在audio : true后添加toString参数即可

查看这篇文章- link

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10791457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档