Top Related Projects
The HTML5 video player for the web
:clapper: An extensible media player for the web.
JW Player is the world's most popular embeddable media player.
HTML5 <audio> or <video> player with support for MP4, WebM, and MP3 as well as HLS, Dash, YouTube, Facebook, SoundCloud and others with a common HTML5 MediaElement API, enabling a consistent UI in all browsers.
HTML5 FLV Player
A simple HTML5, YouTube and Vimeo player
Quick Overview
Video.js is an open-source, web video player built with JavaScript. It supports HTML5 video and modern streaming formats, as well as YouTube and Vimeo. Video.js is designed to be easy to use and customize, making it a popular choice for developers looking to implement video playback on their websites.
Pros
- Cross-browser compatibility and support for various video formats
- Extensive plugin ecosystem for added functionality
- Customizable appearance with CSS
- Active community and regular updates
Cons
- Can be overkill for simple video playback needs
- Some advanced features require additional plugins
- Learning curve for deep customization
- Performance may be impacted with multiple instances on a single page
Code Examples
- Basic video player setup:
<video
id="my-video"
class="video-js"
controls
preload="auto"
width="640"
height="360"
data-setup="{}"
>
<source src="my-video.mp4" type="video/mp4" />
</video>
<script src="https://vjs.zencdn.net/7.20.3/video.min.js"></script>
<script>
var player = videojs('my-video');
</script>
- Adding a plugin (for example, the hotkeys plugin):
import videojs from 'video.js';
import 'videojs-hotkeys';
const player = videojs('my-video');
player.hotkeys({
volumeStep: 0.1,
seekStep: 5,
enableModifiersForNumbers: false
});
- Customizing the player with options:
const player = videojs('my-video', {
autoplay: true,
controls: true,
loop: false,
fluid: true,
playbackRates: [0.5, 1, 1.5, 2]
});
Getting Started
- Include Video.js in your project:
<link href="https://vjs.zencdn.net/7.20.3/video-js.min.css" rel="stylesheet" />
<script src="https://vjs.zencdn.net/7.20.3/video.min.js"></script>
- Add a video element to your HTML:
<video
id="my-video"
class="video-js"
controls
preload="auto"
width="640"
height="360"
data-setup="{}"
>
<source src="my-video.mp4" type="video/mp4" />
</video>
- Initialize the player in your JavaScript:
var player = videojs('my-video');
Competitor Comparisons
The HTML5 video player for the web
Pros of Flowplayer
- Smaller file size, leading to faster load times
- Built-in support for HLS and DASH streaming
- More customizable UI with easier theming options
Cons of Flowplayer
- Smaller community and fewer third-party plugins compared to Video.js
- Less extensive documentation and tutorials
- Limited free features; some advanced functionality requires a paid license
Code Comparison
Video.js basic setup:
videojs('my-video', {
controls: true,
sources: [{ src: 'video.mp4', type: 'video/mp4' }]
});
Flowplayer basic setup:
flowplayer('#player', {
clip: {
sources: [
{ type: 'video/mp4', src: 'video.mp4' }
]
}
});
Both libraries offer similar basic setup, but Flowplayer's API is slightly more concise. Video.js provides more options for customization in the initial configuration, while Flowplayer often relies on additional method calls or plugins for advanced features.
Overall, Video.js offers a more robust, open-source solution with a larger ecosystem, while Flowplayer provides a streamlined experience with some advanced features out-of-the-box, particularly for streaming. The choice between the two depends on specific project requirements, budget constraints, and desired level of community support.
:clapper: An extensible media player for the web.
Pros of Clappr
- Lightweight and modular architecture
- Built-in support for adaptive streaming (HLS, DASH)
- Easy to extend with plugins
Cons of Clappr
- Smaller community and ecosystem compared to Video.js
- Less extensive documentation and examples
- Fewer built-in UI customization options
Code Comparison
Video.js:
videojs('my-video', {
controls: true,
sources: [{ src: 'video.mp4', type: 'video/mp4' }]
});
Clappr:
new Clappr.Player({
source: 'video.mp4',
parentId: '#player'
});
Both Video.js and Clappr are popular open-source HTML5 video players. Video.js has a larger community, more extensive documentation, and a wider range of plugins and skins. It's known for its flexibility and cross-browser compatibility.
Clappr, on the other hand, offers a more modern and lightweight approach. It has built-in support for adaptive streaming protocols like HLS and DASH, which can be advantageous for streaming applications. Clappr's modular architecture makes it easier to extend and customize, but it may require more effort to achieve the same level of UI customization as Video.js.
In terms of code, both libraries offer straightforward initialization. Video.js uses a more traditional approach with an existing video element, while Clappr creates the player instance directly in JavaScript.
Ultimately, the choice between Video.js and Clappr depends on specific project requirements, desired features, and the level of community support needed.
JW Player is the world's most popular embeddable media player.
Pros of JW Player
- More extensive feature set, including advanced analytics and advertising support
- Better documentation and enterprise-level support
- Wider range of customization options and plugins
Cons of JW Player
- Proprietary software with licensing costs, unlike the open-source Video.js
- Steeper learning curve due to more complex API and configuration options
- Less flexibility for developers who want to modify the core player functionality
Code Comparison
JW Player setup:
jwplayer("myElement").setup({
file: "video.mp4",
width: "100%",
aspectratio: "16:9"
});
Video.js setup:
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264">
<source src="video.mp4" type="video/mp4">
</video>
<script>
var player = videojs('my-video');
</script>
Both players offer easy setup, but JW Player uses a JavaScript-based configuration, while Video.js relies more on HTML attributes with JavaScript enhancement. JW Player's setup is more concise, but Video.js offers a more familiar HTML-first approach that some developers may prefer.
HTML5 <audio> or <video> player with support for MP4, WebM, and MP3 as well as HLS, Dash, YouTube, Facebook, SoundCloud and others with a common HTML5 MediaElement API, enabling a consistent UI in all browsers.
Pros of MediaElement
- Simpler API and easier to implement for basic use cases
- Better support for older browsers and legacy media formats
- Smaller file size, potentially faster load times
Cons of MediaElement
- Less active development and community support
- Fewer advanced features and customization options
- Limited plugin ecosystem compared to Video.js
Code Comparison
MediaElement:
var player = new MediaElementPlayer('player1', {
features: ['playpause', 'current', 'progress', 'duration', 'volume'],
success: function(mediaElement, domObject) {
// Player is ready
}
});
Video.js:
var player = videojs('my-video', {
controls: true,
autoplay: false,
preload: 'auto',
fluid: true,
plugins: {
// Plugin configurations
}
});
Both libraries offer straightforward initialization, but Video.js provides more options for customization and plugin integration out of the box. MediaElement's setup is simpler, which can be advantageous for basic implementations.
Video.js has a more extensive API and plugin ecosystem, making it better suited for complex projects with advanced requirements. However, this comes at the cost of a steeper learning curve and potentially more complex codebase.
MediaElement shines in its simplicity and compatibility with older systems, making it a good choice for projects that need to support legacy browsers or have simpler video playback needs.
HTML5 FLV Player
Pros of flv.js
- Specialized for FLV playback, offering better performance for this format
- Lightweight and focused, with a smaller file size
- Direct support for streaming FLV over HTTP
Cons of flv.js
- Limited to FLV format, less versatile than video.js
- Smaller community and fewer plugins compared to video.js
- Less extensive documentation and examples
Code Comparison
flv.js:
if (flvPlayer != null) {
flvPlayer.unload();
flvPlayer.detachMediaElement();
flvPlayer.destroy();
flvPlayer = null;
}
video.js:
var player = videojs('my-video', {
controls: true,
autoplay: false,
preload: 'auto'
});
player.src({ type: 'video/mp4', src: 'path/to/video.mp4' });
Summary
flv.js is a specialized player for FLV format, offering better performance and a smaller footprint for this specific use case. However, it lacks the versatility and extensive ecosystem of video.js. video.js provides a more comprehensive solution for various video formats and has a larger community, but may be overkill for projects focused solely on FLV playback. The choice between the two depends on the specific requirements of the project and the primary video format being used.
A simple HTML5, YouTube and Vimeo player
Pros of Plyr
- Lightweight and more focused on modern browsers, resulting in a smaller file size
- Simpler API and easier customization options
- Better out-of-the-box styling and responsive design
Cons of Plyr
- Less extensive plugin ecosystem compared to Video.js
- Fewer advanced features and customization options for complex use cases
- Smaller community and potentially slower development pace
Code Comparison
Plyr initialization:
const player = new Plyr('#player', {
controls: ['play', 'progress', 'current-time', 'mute', 'volume', 'fullscreen']
});
Video.js initialization:
const player = videojs('my-video', {
controls: true,
autoplay: false,
preload: 'auto'
});
Both libraries offer simple initialization, but Plyr's approach is more concise and focused on modern features. Video.js provides more extensive options for customization and compatibility with older browsers.
Plyr is ideal for projects requiring a lightweight, modern video player with a clean interface. Video.js is better suited for complex applications needing extensive customization and broad browser support.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Video.js® - Web Video Player
Video.js is a full featured, open source video player for all web-based platforms.
Right out of the box, Video.js supports all common media formats used on the web including streaming formats like HLS and DASH. It works on desktops, mobile devices, tablets, and web-based Smart TVs. It can be further extended and customized by a robust ecosystem of plugins.
Video.js was started in the middle of 2010 and is now used on over 50,000 100,000 200,000 400,000 700,000 800,000 websites.
Table of Contents
Quick Start
Thanks to the awesome folks over at Fastly, there's a free, CDN hosted version of Video.js that anyone can use. Add these tags to your document's <head>
:
<link href="//vjs.zencdn.net/8.18.0/video-js.min.css" rel="stylesheet">
<script src="//vjs.zencdn.net/8.18.0/video.min.js"></script>
Alternatively, you can include Video.js by getting it from npm, downloading it from GitHub releases or by including it via unpkg or another JavaScript CDN, like CDNjs.
<!-- unpkg : use the latest version of Video.js -->
<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet">
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
<!-- unpkg : use a specific version of Video.js (change the version numbers as necessary) -->
<link href="https://unpkg.com/video.js@8.18.0/dist/video-js.min.css" rel="stylesheet">
<script src="https://unpkg.com/video.js@8.18.0/dist/video.min.js"></script>
<!-- cdnjs : use a specific version of Video.js (change the version numbers as necessary) -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/video.js/8.18.0/video-js.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/8.18.0/video.min.js"></script>
Next, using Video.js is as simple as creating a <video>
element, but with an additional data-setup
attribute. At a minimum, this attribute must have a value of '{}'
, but it can include any Video.js options - just make sure it contains valid JSON!
<video
id="my-player"
class="video-js"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png"
data-setup='{}'>
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4"></source>
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm"></source>
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
When the page loads, Video.js will find this element and automatically setup a player in its place.
If you don't want to use automatic setup, you can leave off the data-setup
attribute and initialize a <video>
element manually using the videojs
function:
var player = videojs('my-player');
The videojs
function also accepts an options
object and a callback to be invoked when the player is ready:
var options = {};
var player = videojs('my-player', options, function onPlayerReady() {
videojs.log('Your player is ready!');
// In this context, `this` is the player that was created by Video.js.
this.play();
// How about an event listener?
this.on('ended', function() {
videojs.log('Awww...over so soon?!');
});
});
If you're ready to dive in, the Getting Started page and documentation are the best places to go for more information. If you get stuck, head over to our Slack!
Contributing
Video.js is a free and open source library, and we appreciate any help you're willing to give - whether it's fixing bugs, improving documentation, or suggesting new features. Check out the contributing guide for more!
Video.js uses BrowserStack for compatibility testing.
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
License
Video.js is licensed under the Apache License, Version 2.0.
Video.js is a registered trademark of Brightcove, Inc.
Top Related Projects
The HTML5 video player for the web
:clapper: An extensible media player for the web.
JW Player is the world's most popular embeddable media player.
HTML5 <audio> or <video> player with support for MP4, WebM, and MP3 as well as HLS, Dash, YouTube, Facebook, SoundCloud and others with a common HTML5 MediaElement API, enabling a consistent UI in all browsers.
HTML5 FLV Player
A simple HTML5, YouTube and Vimeo player
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot