No description
Find a file
2024-04-28 13:51:43 +02:00
.github/workflows ci: add GitHub Actions configuration 2023-04-20 08:58:35 -04:00
docs/demo Merge pull request #104 from yokuze/support_videojs_8 2023-11-15 10:55:02 -05:00
src Add the ability to hide quality options 2024-04-28 13:51:43 +02:00
tests refactor: use es6 classes 2022-12-26 22:48:28 -05:00
.browserslistrc chore: update to @silvermine/standardization v2.0.0 2022-12-26 22:46:30 -05:00
.editorconfig chore: use standardization library 2021-05-13 15:01:48 -04:00
.eslintrc.json refactor: use es6 classes 2022-12-26 22:48:28 -05:00
.gitignore chore: ignore intellij IDE config 2022-07-08 11:11:22 -04:00
.markdownlint.json chore: upgrade standardization and configure markdownlint 2021-09-10 10:49:11 -04:00
.npmignore chore: replace istanbul with nyc 2021-05-13 15:01:48 -04:00
.nvmrc chore: upgrade Node to 16.15.0 and NPM to 8.5.5 2022-07-14 11:42:46 -04:00
.nycrc.json chore: replace istanbul with nyc 2021-05-13 15:01:48 -04:00
.stylelintrc.yml chore: add @silvermine/standardization and configuration 2022-07-08 11:11:22 -04:00
CHANGELOG.md chore: update changelog for v1.3.1 2023-11-15 13:37:34 -05:00
commitlint.config.js refactor: use es6 classes 2022-12-26 22:48:28 -05:00
Gruntfile.js build: prevent error thrown when installed from a git URL 2022-12-27 11:24:22 -05:00
LICENSE Initial commit 2017-06-20 20:43:49 -04:00
package-lock.json chore: version bump: v1.3.1 2023-11-15 14:13:29 -05:00
package.json chore: version bump: v1.3.1 2023-11-15 14:13:29 -05:00
README.md docs: fix path to polyfilled/transpiled JS file 2023-11-15 12:30:03 -05:00

Silvermine VideoJS Quality/Resolution Selector

Build Status Coverage Status Dependency Status Dev Dependency Status

What is it?

A plugin for videojs versions 6+ that adds a button to the control bar which will allow the user to choose from available video qualities or resolutions.

How do I use it?

There are three primary steps to use this plug-in: (1) including, (2) providing sources, and (3) adding the component the to controlBar. Please see the following for information on each step.

Including/Requiring

Using <script> tag

The minified JS file can come from a downloaded copy or a CDN. When including it, make sure that the <script> tag for the plugin appears after the include for video.js (note that this plugin will look for videojs at window.videojs).

There is an example of this in docs/demo/index.html.

From local file
<script src="./path/to/video.min.js"></script>
<script src="./path/to/silvermine-videojs-quality-selector.min.js"></script>
From unpkg
<link href="https://unpkg.com/@silvermine/videojs-quality-selector/dist/css/quality-selector.css" rel="stylesheet">
<script src="./path/to/video.min.js"></script>
<script src="https://unpkg.com/@silvermine/videojs-quality-selector/dist/js/silvermine-videojs-quality-selector.min.js"></script>

Using require

When using NPM/Browserify, first install the plugin.

npm install --save @silvermine/videojs-quality-selector

For videojs to use the plug-in, the plugin needs to register itself with the instance of videojs. This can be accomplished by:

var videojs = require('videojs');

// The following registers the plugin with `videojs`
require('@silvermine/videojs-quality-selector')(videojs);

Remember to also add the CSS to your build. With most bundlers you can:

require('@silvermine/videojs-quality-selector/dist/css/quality-selector.css')

Warning

This plugin's source code uses ES6+ syntax and keywords, such as class and static. If you need to support browsers that do not support newer JavaScript syntax, you will need to use a tool like Babel to transpile and polyfill your code.

Alternatively, you can require('@silvermine/videojs-quality-selector/dist/js/silvermine-videojs-quality-selector.js') to use a JavaScript file that has already been polyfilled/transpiled down to ES5 compatibility.

Providing video sources

Sources can be provided with either the <source> tag or via the src function on the instance of a video.js player.

Using <source>

<video id="video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268">
   <source src="https://example.com/video_720.mp4" type="video/mp4" label="720P">
   <source src="https://example.com/video_480.mp4" type="video/mp4" label="480P" selected="true">
   <source src="https://example.com/video_360.mp4" type="video/mp4" label="360P">
</video>

Using player.src()

player.src([
   {
      src: 'https://example.com/video_720.mp4',
      type: 'video/mp4',
      label: '720P',
   },
   {
      src: 'https://example.com/video_480.mp4',
      type: 'video/mp4',
      label: '480P',
      selected: true,
   },
   {
      src: 'https://example.com/video_360.mp4',
      type: 'video/mp4',
      label: '360P',
   },
]);

Adding to the player

There are at least two ways to add the quality selector control to the player's control bar. The first is directly adding it via addChild. For example:

videojs('video_1', {}, function() {
   var player = this;

   player.controlBar.addChild('QualitySelector');
});

The second option is to add the control via the player's options, for instance:

var options, player;

options = {
   controlBar: {
      children: [
         'playToggle',
         'progressControl',
         'volumePanel',
         'qualitySelector',
         'fullscreenToggle',
      ],
   },
};

player = videojs('video_1', options);

How do I contribute?

We genuinely appreciate external contributions. See our extensive documentation on how to contribute.

License

This software is released under the MIT license. See the license file for more details.