An overview of how to get started using Video.js, from basic CDN usage to Browserify, along with examples.
There are a few ways to get started using Video.js (currently v7.2.2), and you should select the one that best fits your particular use case.
Our friends at Fastly are nice enough to provide hosting for all the necessary files for Video.js on their content delivery network. Using these hosted files is probably the easiest way to get started using Video.js, you simply need to include the following links in your page.
For more advanced workflows, installing via npm is recommended
$ npm install video.js
Beginning with v7, we will no longer support Microsoft Internet Explorer versions prior to IE 11, including IE 8, 9, and 10. Microsoft dropped support for these versions over two years ago, they are widely considered out of compliance with modern security standards, and they comprise less than 0.1% of Video.js browser usage.
For versions of Video.js prior to v7, there are a few common things you should keep in mind regardless of how you end up including
to support IE8 you'll need to include an ES5 shim. To make things easier, we created a single file you
can include for IE8 support. No matter where the core Video.js library is placed, this file needs to be located
<head> of the document.
We include a stripped down Google Analytics pixel that tracks a random percentage (currently 1%) of players loaded from the CDN. This allows us to see (roughly) what browsers are in use in the wild, along with other useful metrics such as OS and device. If you'd like to disable analytics, you can simply include the following global before including Video.js via the free CDN:
Note: v7 will not send any data, and v6.8 and up respect the browser's do not track flag.
window.HELP_IMPROVE_VIDEOJS = false;
If you've downloaded one of the releases or installed via a package manager, you've probably noticed that the contents are slightly different from the source code available on Github. The former includes just the compiled files necessary to use Video.js, and the latter includes the source used to create those files.
A Video.js distribution is what you'll find if you've downloaded a release or installed via a package manager.
Video.js/ ├── alt │ ├── video.core.js │ ├── video.core.min.js │ ├── video.core.novtt.js │ ├── video.core.novtt.min.js │ ├── video.novtt.js │ └── video.novtt.min.js ├── examples/ ├── font │ ├── VideoJS.svg │ ├── VideoJS.ttf │ └── VideoJS.woff ├── lang/ ├── video-js-7.2.2.zip ├── video-js.css ├── video-js.min.css ├── video.cjs.js ├── Video.es.js ├── Video.js └── video.min.js
This package includes everything you'll need to use Video.js on a production site. By default, we bundle Video.js with Mozilla's excellent VTT.js.
If you don't need VTT.js functionality for whatever reason, you can use one of the Video.js copies that don't include VTT.js. These have
novtt in the name and can be found in the
font/ includes all the generated icon font files from the Videojs Font project.
lang/ contains all the generated translation files.
The source code is everything you'll find when checking out the Video.js git repository. This includes all the source files and any tooling necessary to build a production ready version of Video.js, as well as useful development tools such as sandboxed examples.
A lot of the root source directory is JSON configs for various package managers because, Internet. Most likely the important things you're looking for will be in
src/ contains all of the source files for both the player JS and the base skin, while the
build/ directory contains various grunt tasks as well as the primary build file,
Using Video.js straight out of the box is fine, but we think it's better if you make it your own. Plugins and skins make it possible to completely customize your player.
The player skin is completely built from HTML and CSS, including when Flash and other players like YouTube are used.
Skin changes can be as simple as centering the play button (you can just add the 'vjs-big-play-centered' class to your video tag), or as complex as creating entirely new layouts. We've built a codepen project where you can explore different changes.
And if you know CSS, you can always just open your Chrome dev tools and hack away!
Video.js by itself is purposefully very simple. It supports the basic video and audio playback features and ensures they work the same across different playback technologies ("techs"). Any more advanced features are built as plugins, including playlists, analytics, advertising, and support for advanced formats like HLS and DASH. Check out the plugins page to see what's available.