Skip to content

Instantly share code, notes, and snippets.

@phoboslab
Last active December 15, 2015 10:59
Show Gist options
  • Save phoboslab/5249534 to your computer and use it in GitHub Desktop.
Save phoboslab/5249534 to your computer and use it in GitHub Desktop.
Ejecta Video
var video = document.createElement('video');
console.log( 'can play mp4', video.canPlayType('video/mp4') );
video.src = 'test.mov';
// Also loads from the internet:
//video.src = 'http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov';
// Show playback controls:
//video.controls = true;
// For local video files, you don't really have to wait for the 'canplaythrough' event;
// you can just call .play() after setting the .src
video.addEventListener('canplaythrough', function(){
console.log('duration', video.duration);
video.scalingMode = 'aspect-fill'; // default scalingMode
//video.scalingMode = 'aspect-fit';
//video.scalingMode = 'fill';
//video.scalingMode = 'none';
video.play();
// Jump to 100 seconds:
//video.currentTime = 100;
video.addEventListener('click', function(){
video.pause();
}, false);
video.addEventListener('ended', function(){
console.log('ended!');
}, false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment