<html>
<head><title>document loading</title></head>
<body>
<script>
function getVideoFileNameForCodecs(codecs) {
if (!codecs) {
document.title = 'The "codecs" parameter is required.';
return null;
}
if (codecs == "vp8") {
return 'bear-vp8a.webm';
} else if (codecs == "vp9,opus") {
return 'bear-vp9-opus.webm';
} else if (codecs == "vp9") {
return 'bear-vp9.webm';
} else {
document.title = 'Unrecognized value in "codecs" parameter';
return null;
}
}
var bear = document.createElement('video');
var isMetadataLoaded = false;
var isPlaying = false;
var params = new URLSearchParams(window.location.search);
var videoFile = getVideoFileNameForCodecs(params.get("codecs"));
if (params.get("autoplay") == "1") {
bear.autoplay = true;
}
var reportEnded = params.get("reportended") == "1";
bear.onerror = function() { document.title = 'media element error'; }
bear.onloadeddata = function() {
document.title = 'loaded';
if (bear.autoplay) {
window.setTimeout(function() {
if (!isPlaying)
document.title = 'blocked';
}, 200);
}
}
bear.onloadedmetadata = function() { isMetadataLoaded = true; }
bear.onpause = function () { isPlaying = false; }
bear.onplay = function() {
isPlaying = true;
document.title = 'playing';
}
bear.onstalled = function() { document.title = 'stalled'; }
bear.onended = function() {
if (reportEnded) {
document.title = 'ended';
}
}
if (videoFile) {
document.title = 'initial title';
bear.src = videoFile;
}
</script>
</body>
</html>