diff --git a/src/content/getusermedia/record/js/main.js b/src/content/getusermedia/record/js/main.js index a9e2a664c..9a30cb745 100644 --- a/src/content/getusermedia/record/js/main.js +++ b/src/content/getusermedia/record/js/main.js @@ -108,12 +108,14 @@ async function startRecording() { if (mimeType.split(';', 1)[0] === 'video/mp4') { // Adjust sampling rate to 48khz. const track = window.stream.getAudioTracks()[0]; - const {sampleRate} = track.getSettings(); - if (sampleRate != 48000) { - track.stop(); - window.stream.removeTrack(track); - const newStream = await navigator.mediaDevices.getUserMedia({audio: {sampleRate: 48000}}); - window.stream.addTrack(newStream.getTracks()[0]); + if (track) { + const {sampleRate} = track.getSettings(); + if (sampleRate != 48000) { + track.stop(); + window.stream.removeTrack(track); + const newStream = await navigator.mediaDevices.getUserMedia({audio: {sampleRate: 48000}}); + window.stream.addTrack(newStream.getTracks()[0]); + } } } try {