As an exercise I'm learning how to record stream from browser tabs. I've this code that will call the MediaRecorder
API after that the tabCapture
API is called in chrome. How I can use the stream
object that will be provided from the tabCapture
and save it as audio? I've searched around here but I was not able to find any similar question. At the moment this is the code I have, I'm writing a class to record the audio
class TabAudioRecorder {
#recorder;
#stream = null;
#chunks = [];
startRecord(stream) {
this.#recorder = new MediaRecorder(stream, {audioBitsPerSecond: 128000});
this.#recorder.start();
this.#recorder.ondataavailable = (e) => {
console.log('Data available');
this.#chunks.push(e);
}
}
stopRecord() {
this.#recorder.stop();
let blob = new Blob(this.#chunks, {type: 'audio/mpeg'});
let url = URL.createObjectURL(blob);
console.log(blob, url);
chrome.downloads.download({
url: url,
saveAs: true
}, (downloadId) => {
console.log(downloadId);
});
}
}
question from:
https://stackoverflow.com/questions/65869745/how-to-record-browser-tab-audio-using-tabcapture-api 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…