【问题标题】:HTML5: capture audio AND video combined from web browserHTML5:从网络浏览器捕获音频和视频组合
【发布时间】:2013-06-06 03:11:12
【问题描述】:
【问题讨论】:
标签:
html
html5-video
html5-audio
asp.net-web-api
【解决方案1】:
你也可以尝试做同样的事情,你应该看看
[http://jsfiddle.net/james2doyle/URyLt/]
如果你愿意,请告诉我,谢谢
$("button").click(do_it);
function do_it() {
var obj = {}, txt="";
if (this.id == "video") {
obj = {
video: true,
audio: true
};
txt = "<video>";
} else {
obj = {
video: false,
audio: true
};
txt = "<audio>";
}
navigator.webkitGetUserMedia(obj, function(stream) {
$("#result").empty();
var output = $(txt).appendTo("#result")[0],
source = window.webkitURL.createObjectURL(stream);
output.autoplay = true;
output.src = source;
console.log(stream);
window.a = stream; //debug
$("span#name").html("Camera name: <b>" + stream.videoTracks[0].label + "</b><br>" + "Mic name: <b>" + stream.audioTracks[0].label + "</b>");
}, function(err) {
console.log(err);
err.code == 1 && (alert("You can click the button again anytime to enable."))
});
}