pc瀏覽器獲取音頻流,怎樣實(shí)時(shí)傳給后臺(tái)
飲歌長(zhǎng)嘯
2018-08-10 09:17:20
TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
視頻和音頻原理一樣,這里以音頻為例。
其實(shí)這個(gè)問題你需要和后臺(tái)協(xié)商的, 假設(shè)后臺(tái)有一個(gè)接受文件流的接口,那么代碼類似這樣:
navigator.getUserMedia( // constraints { //video: true, audio: true }, // successCallback function (localMediaStream) { fetch(url, { method: 'POST', body: localMediaStream }) }, // errorCallback function (err) { console.log("The following error occured: " + err); }); } else { alert("getUserMedia not supported by your web browser or Operating system version"); }
舉報(bào)