Skip to content

Instantly share code, notes, and snippets.

@mqp
Created November 15, 2017 22:09
Show Gist options
  • Save mqp/58c00aa9923a101e96febed9aa25927c to your computer and use it in GitHub Desktop.
Save mqp/58c00aa9923a101e96febed9aa25927c to your computer and use it in GitHub Desktop.
Test page for Firefox media stream code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tiny test page</title>
</head>
<body>
<form id="form">
<input id="file" type="file" />
<input type="submit" val="Load"/>
</form>
<video id="video" controls></video>
<script>
var form = document.getElementById("form");
var input = document.getElementById("file");
var video = document.getElementById("video");
form.onsubmit = function(e) {
var f = input.files[0];
var url = URL.createObjectURL(f);
video.src = url;
video.play();
var stream = video.mozCaptureStream();
console.log(stream.getTracks()); // no tracks
setTimeout(() => console.log(stream.getTracks()), 10); // no tracks
setTimeout(() => console.log(stream.getTracks()), 100); // video + audio track
e.preventDefault();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment