body {
margin: 0;
padding: 0;
background-color: black;
}
video {
width: 100vw;
height: 100vh;
}
JavaScript
// MAKE SURE TO CLICK INTO THE RESULT IFRAME OR ELSE SAFARI WILL ONLY RENDER RAF / SETINTERVAL AT MAX 30FPS DUE TO POWER SAVING CODE
var index = 0;
var url = "https://s3.amazonaws.com/files.panomoments.com/hd_dashinit.mp4"; // 100% I-Frames for fast seeking
var video = document.createElement('video');
video.preload = "auto";
video.muted = true;
video.autoplay = true; // Needed for iOS to trigger readyState = 4
video.loop = true;
document.body.appendChild(video);
var animationStrategy = 1;
if (animationStrategy == 1) {
window.requestAnimationFrame(render); // Slower performance than setInterval
} else if (animationStrategy == 2) {
setInterval(render, 1000/60);
}
function render() {
if (animationStrategy == 1) {
window.requestAnimationFrame(render);
}
if (video.readyState >= 3) {
index = (index + 1) % 242;
video.currentTime = index;
}
}
fetch(url).then(function(response) {
response.blob().then(function(myBlob) {
video.src = window.URL.createObjectURL(myBlob); // Seeking with blob occasionally shows XPC memory issue on Safari but even with this issue you should be able ot see that rAF performs worse than setInterval
});
});
(function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();document.body.appendChild(stats.dom);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='//mrdoob.github.io/stats.js/build/stats.min.js';document.head.appendChild(script);})()
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.