我已经搜索了很多关于getUserMedia的演示和例子,但大多数只是摄像头捕捉,而不是麦克风。
所以我下载了一些例子,并在我自己的电脑上尝试,相机捕捉是工作的,但当我改变
navigator.webkitGetUserMedia({video : true},gotStream);
至
navigator.webkitGetUserMedia({audio : true},gotStream);
浏览器要求我先允许麦克风访问,然后在
document.getElementById("audio").src = window.webkitURL.createObjectURL(stream);
传达的信息是:
GET blob:http%3A//localhost/a5077b7e-097a-4281-b444-8c1d3e327eb4 404 (Not Found)
这是我的代码:getUserMedia_simple_audio_test
我做错什么了吗?或者现在只有getUserMedia可以在摄像头上工作了?
发布于 2012-10-29 21:17:29
它目前在Chrome Canary中被支持。您需要在地址栏中键入about:flag,然后启用Web Audio Input。
下面的代码将音频输入连接到扬声器。注意反馈!
<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()"/>
发布于 2012-10-29 21:25:35
(对不起,我忘记登录了,所以请使用我的正确用户名...)
它目前在Chrome Canary中被支持。您需要在地址栏中键入about:flags
,然后启用网络音频输入。
下面的代码将音频输入连接到扬声器。注意反馈!
<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()"/>
发布于 2012-07-23 03:45:01
工作正常,只需在audio : true
后添加toString
参数即可
查看这篇文章- link
https://stackoverflow.com/questions/10791457
复制相似问题