Skip to content

Instantly share code, notes, and snippets.

@andreupifarre
Last active July 13, 2020 08:51
Show Gist options
  • Save andreupifarre/1d75f9f5b5edeb8e36c995339b4f2854 to your computer and use it in GitHub Desktop.
Save andreupifarre/1d75f9f5b5edeb8e36c995339b4f2854 to your computer and use it in GitHub Desktop.
const preload = Preload();
preload.fetch([
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4',
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4',
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4'
]).then(result => {
// use either a promise or 'oncomplete'
});
preload.oncomplete = items => {
player.src = preload.getItemByUrl('https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4').blobUrl;
player.play();
}
preload.onprogress = event => {
document.getElementById('progress').textContent = document.getElementById('progress-bar').style.width = event.progress + '%';
}
preload.onfetched = item => {
document.getElementById('loaded-items').innerHTML += '<span>' + item.fileName + ' <strong>[' + item.size + ']</strong></span>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment