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);

更新於:2020-01-28

296 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.