Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guest271314/6077e5b177e3332519641d7409732227 to your computer and use it in GitHub Desktop.
Save guest271314/6077e5b177e3332519641d7409732227 to your computer and use it in GitHub Desktop.
MediaStreamTrack does not render silence on Chromium
<!DOCTYPE html>
<html>
<head>
<title>MediaStreamTrack does not render silence on Chromium</title>
<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=1262796 -->
<!-- https://www.w3.org/TR/mediacapture-streams/#life-cycle-and-media-flow -->
</head>
<body>
<script>
var webrtc = new RTCPeerConnection();
var transceiver = webrtc.addTransceiver('audio');
var { track: webrtc_track } = transceiver.receiver;
var webrtc_audio_element = new Audio();
webrtc_audio_element.controls = webrtc_audio_element.autoplay = true;
document.body.appendChild(webrtc_audio_element);
webrtc_audio_element.srcObject = new MediaStream([webrtc_track]);
webrtc_audio_element.ontimeupdate = webrtc_audio_element.onplaying = (
e
) =>
console.assert(e.target.currentTime > 0, [
e.target.currentTime,
e.type,
]);
var ac = new AudioContext();
var msd = new MediaStreamAudioDestinationNode(ac);
var { stream } = msd;
var [webaudio_track] = stream.getAudioTracks();
var webaudio_element = new Audio();
webaudio_element.controls = webaudio_element.autoplay = true;
document.body.appendChild(webaudio_element);
webaudio_element.srcObject = new MediaStream([webaudio_track]);
webaudio_element.ontimeupdate = webaudio_element.onplaying = (e) =>
console.assert(e.target.currentTime > 0, [
e.target.currentTime,
e.type,
]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment