<p><a href="https://videojs.com"><img src="https://videojs.com/logo-white.png" alt="Video.js logo"></a></p>
<h1 id="id-videojsĀ®---web-video-player">Video.jsĀ® - Web Video Player</h1>
<p><a href="https://nodei.co/npm/video.js/"><img src="https://nodei.co/npm/video.js.png?downloads=true&downloadRank=true" alt="NPM"></a></p>
<p>Video.js is a full featured, open source video player for all web-based platforms.</p>
<p>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 <a href="https://videojs.com/plugins/">plugins</a>.</p>
<p>Video.js was started in the middle of 2010 and is now used on over <del>50,000</del> <del>100,000</del> <del>200,000</del> <del>400,000</del> <del>700,000</del> <a href="https://trends.builtwith.com/media/VideoJS">800,000 websites</a>.</p>
<h2 id="id-table-of-contents">Table of Contents</h2>
<ul>
<li><a href="#quick-start">Quick Start</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#code-of-conduct">Code of Conduct</a></li>
<li><a href="#license">License</a></li>
</ul>
<h2 id="id-quick-start"><a href="https://videojs.com/getting-started/">Quick Start</a></h2>
<p>Thanks to the awesome folks over at <a href="https://www.fastly.com/">Fastly</a>, there&#39;s a free, CDN hosted version of Video.js that anyone can use. Add these tags to your document&#39;s <code>&lt;head&gt;</code>:</p>
<pre><code class="hljs language-html"><span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;//vjs.zencdn.net/8.23.3/video-js.min.css&quot;</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;//vjs.zencdn.net/8.23.3/video.min.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Alternatively, you can include Video.js by getting it from <a href="https://videojs.com/getting-started/#install-via-npm">npm</a>, downloading it from <a href="https://github.com/videojs/video.js/releases">GitHub releases</a> or by including it via <a href="https://unpkg.com">unpkg</a> or another JavaScript CDN, like CDNjs.</p>
<pre><code class="hljs language-html"><span class="hljs-comment">&lt;!-- unpkg : use the latest version of Video.js --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://unpkg.com/video.js/dist/video-js.min.css&quot;</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://unpkg.com/video.js/dist/video.min.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- unpkg : use a specific version of Video.js (change the version numbers as necessary) --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://unpkg.com/video.js@8.23.3/dist/video-js.min.css&quot;</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://unpkg.com/video.js@8.23.3/dist/video.min.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- cdnjs : use a specific version of Video.js (change the version numbers as necessary) --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://cdnjs.cloudflare.com/ajax/libs/video.js/8.23.3/video-js.min.css&quot;</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://cdnjs.cloudflare.com/ajax/libs/video.js/8.23.3/video.min.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Next, using Video.js is as simple as creating a <code>&lt;video&gt;</code> element, but with an additional <code>data-setup</code> attribute. At a minimum, this attribute must have a value of <code>&#39;{}&#39;</code>, but it can include any Video.js <a href="https://videojs.com/guides/options/">options</a> - just make sure it contains valid JSON!</p>
<pre><code class="hljs language-html">&lt;video
    <span class="hljs-built_in">id</span>=<span class="hljs-string">&quot;my-player&quot;</span>
    class=<span class="hljs-string">&quot;video-js&quot;</span>
    controls
    preload=<span class="hljs-string">&quot;auto&quot;</span>
    poster=<span class="hljs-string">&quot;//vjs.zencdn.net/v/oceans.png&quot;</span>
    data-setup=<span class="hljs-string">&#x27;{}&#x27;</span>&gt;
  &lt;<span class="hljs-built_in">source</span> src=<span class="hljs-string">&quot;//vjs.zencdn.net/v/oceans.mp4&quot;</span> <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;video/mp4&quot;</span>&gt;&lt;/source&gt;
  &lt;<span class="hljs-built_in">source</span> src=<span class="hljs-string">&quot;//vjs.zencdn.net/v/oceans.webm&quot;</span> <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;video/webm&quot;</span>&gt;&lt;/source&gt;
  &lt;<span class="hljs-built_in">source</span> src=<span class="hljs-string">&quot;//vjs.zencdn.net/v/oceans.ogv&quot;</span> <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;video/ogg&quot;</span>&gt;&lt;/source&gt;
  &lt;p class=<span class="hljs-string">&quot;vjs-no-js&quot;</span>&gt;
    To view this video please <span class="hljs-built_in">enable</span> JavaScript, and consider upgrading to a
    web browser that
    &lt;a href=<span class="hljs-string">&quot;https://videojs.com/html5-video-support/&quot;</span> target=<span class="hljs-string">&quot;_blank&quot;</span>&gt;
      supports HTML5 video
    &lt;/a&gt;
  &lt;/p&gt;
&lt;/video&gt;
</code></pre>
<p>When the page loads, Video.js will find this element and automatically setup a player in its place.</p>
<p>If you don&#39;t want to use automatic setup, you can leave off the <code>data-setup</code> attribute and initialize a <code>&lt;video&gt;</code> element manually using the <code>videojs</code> function:</p>
<pre><code class="hljs language-js"><span class="hljs-keyword">var</span> player = <span class="hljs-title function_">videojs</span>(<span class="hljs-string">&#x27;my-player&#x27;</span>);
</code></pre>
<p>The <code>videojs</code> function also accepts an <code>options</code> object and a callback to be invoked when the player is ready:</p>
<pre><code class="hljs language-js"><span class="hljs-keyword">var</span> options = {};

<span class="hljs-keyword">var</span> player = <span class="hljs-title function_">videojs</span>(<span class="hljs-string">&#x27;my-player&#x27;</span>, options, <span class="hljs-keyword">function</span> <span class="hljs-title function_">onPlayerReady</span>(<span class="hljs-params"></span>) {
  videojs.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;Your player is ready!&#x27;</span>);

  <span class="hljs-comment">// In this context, `this` is the player that was created by Video.js.</span>
  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">play</span>();

  <span class="hljs-comment">// How about an event listener?</span>
  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">on</span>(<span class="hljs-string">&#x27;ended&#x27;</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) {
    videojs.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;Awww...over so soon?!&#x27;</span>);
  });
});
</code></pre>
<p>If you&#39;re ready to dive in, the <a href="https://videojs.com/getting-started/">Getting Started</a> page and <a href="https://docs.videojs.com">documentation</a> are the best places to go for more information. If you get stuck, head over to our <a href="https://slack.videojs.com">Slack</a>!</p>
<h2 id="id-contributing"><a href="https://github.com/videojs/admin/blob/main/CONTRIBUTING.md">Contributing</a></h2>
<p>Video.js is a free and open source library, and we appreciate any help you&#39;re willing to give - whether it&#39;s fixing bugs, improving documentation, or suggesting new features. Check out the <a href="https://github.com/videojs/admin/blob/main/CONTRIBUTING.md">contributing guide</a> for more!</p>
<p><em>Video.js uses <a href="https://browserstack.com">BrowserStack</a> for compatibility testing.</em></p>
<h2 id="id-code-of-conduct"><a href="https://github.com/videojs/admin/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></h2>
<p>Please note that this project is released with a <a href="https://github.com/videojs/admin/blob/main/CODE_OF_CONDUCT.md">Contributor Code of Conduct</a>. By participating in this project you agree to abide by its terms.</p>
<h2 id="id-license"><a href="LICENSE">License</a></h2>
<p>Video.js is <a href="LICENSE">licensed</a> under the Apache License, Version 2.0.</p>
<p>Video.js is a registered trademark of <a href="https://www.brightcove.com/">Brightcove, Inc</a>.</p>