video-prefetcher
v1.0.5
Published
HTML5 video prefetch library.
Downloads
11
Readme
video-prefetcher
HTML5 video prefetch library.
Installation
npm install video-prefetcher
Dependency
Usage
<video width="400" src="Google_Developer_Stories.webm" id="video">
</video>
var VideoPrefetcher = require("video-prefetcher");
// <video> has `src` attribute
var video = document.getElementById("video");
var prefetcher = new VideoPrefetcher(video);
prefetcher.onProgress(function (event) {
var percentComplete = event.loaded / event.total;
console.log((percentComplete * 100) + "%");
});
prefetcher.onLoad(function (event) {
// automatically, replace <video> src to fetched blob url.
console.log("loaded", event);
});
prefetcher.onError(function (error) {
console.error(error, error.stack);
});
prefetcher.start();
Tests
npm test
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT