HTML5 中的媒体流
媒体流表示同步的媒体流。如果没有音频轨道,它将返回一个空数组,并且它将检查视频流,如果网络摄像头连接,stream.getVideoTracks() 将返回一个 MediaStreamTrack 数组,表示来自网络摄像头的流。
function gotStream(stream) { window.AudioContext = window.AudioContext || window.webkitAudioContext; var audioContext = new AudioContext(); // Create an AudioNode from the stream var mediaStreamSource = audioContext.createMediaStreamSource(stream); // Connect it to destination to hear yourself // or any other node for processing! mediaStreamSource.connect(audioContext.destination); } navigator.getUserMedia({audio:true}, gotStream);
广告