Giter Club home page Giter Club logo

foxcouncil / videojs-max-quality-selector Goto Github PK

View Code? Open in Web Editor NEW
21.0 6.0 8.0 1.2 MB

A Videojs Plugin to help you list out resolutions and bit-rates from Live, Adaptive and Progressive streams.

Home Page: https://www.npmjs.com/package/videojs-max-quality-selector

License: MIT License

HTML 7.47% JavaScript 72.55% CSS 19.98%
videojs videojs-plugin resolutions bit-rates progressive-streams adaptive-streams live-streams live adaptive progressive

videojs-max-quality-selector's Introduction

videojs-max-quality-selector

NPM Publish

Test It Out!

A Videojs Plugin to help you list out resolutions and bit-rates from Live, Adaptive and Progressive streams.

Screenshot1 Screenshot2

Table of Contents

Installation

npm install --save videojs-max-quality-selector

Options

autoLabel :string

Default: 'Auto'

This option lets you rename the string value that represents the auto bitrate selection system.

var player = videojs('my-video');
player.maxQualitySelector({
  'autoLabel': 'ABR' // Change the label from 'Auto' (default) to 'ABR'.
});

defaultQuality :number

This option lets you control which level of quality is selected first.

0 = Default Behaviour (The default from playlist), 1 = Lowest (Start the video with the lowest quality stream selected), 2 = Highest (Start the video with the highest quality stream selected)

Default: 0

var player = videojs('my-video');
player.maxQualitySelector({
  'defaultQuality': 2 // Make the video start playing at the highest quality possible
});

disableAuto :boolean

This option disables the auto bitrate selection system and focuses on a single quality level.

Default: false

var player = videojs('my-video');
player.maxQualitySelector({
  'disableAuto': true // Turn off the auto bitrate selection system
});

displayMode :number

This option lets you control how the default quality level is displayed to the screen.

Note: This option is ignored if you override the quality level with a label in DefaultOptions.labels

0 = Both (Includes both the resolution, in height, and the quality marketing name), 1 = Resolution (Include just the resolution, in height), 2 = Name (Include just the quality marketing name)

Default: 0

var player = videojs('my-video');
player.maxQualitySelector({
  'displayMode': 1 // Only render out the height name of the video in the quality button and list
});

filterDuplicateHeights :boolean

This option enabled the filtering of duplicate quality levels when their height all match.

Tip: This is useful if you want to avoid showing different bitrates to users.

Default: true

var player = videojs('my-video');
player.maxQualitySelector({
  'filterDuplicateHeights': false // Turn off filtering of duplicate quality levels with different bitrates
});

filterDuplicates :boolean

This option enabled the filtering of duplicate quality levels when their width, height, bitrate all match.

Tip: This is useful if you want to avoid showing different endpoints to users.

Default: true

var player = videojs('my-video');
player.maxQualitySelector({
  'filterDuplicates': false // Turn off filtering of duplicate quality levels
});

index :number

This option helps you position the button in the VideoJS control bar.

Default: -1

var player = videojs('my-video');
player.maxQualitySelector({
  'index': -2 // Put the button before the closed-captioning button.
});

labels :Array|Object

This options lets you override the name of the listed quality levels.

Tip: Use maxQualitySelector.getLevelNames(); output to find the ID to overwrite.

Default: []

var player = videojs('my-video');

// Quick and useful if only a few contiguous quality levels
var labelsArray = [ 'High', 'Low' ];

// Useful if you need to specify labels in a sparce list
var labelsObject =  { 0: 'High', 8: 'Medium', 16: 'Low', 24: 'Super Low' };

player.maxQualitySelector({
  'labels': labelsArray | labelsObject
});

maxHeight :number

This options lets you specify the maximum height resolution to show in the menu.

Default: 0

var player = videojs('my-video');
player.maxQualitySelector({
  'maxHeight': 1080 // Do not list any resolutions larger than 1080p.
});

minHeight :number

This options lets you specify the minimum height resolution to show in the menu.

Default: 0

var player = videojs('my-video');
player.maxQualitySelector({
  'minHeight': 480 // Do not list any resolutions smaller than 480p.
});

showBitrates :boolean

This option enables showing the bitrate in the button and menu.

Default: false

var player = videojs('my-video');
player.maxQualitySelector({
  'showBitrates': true // Turn on showing bitrates in the button and menu.
});

showSingleItemMenu :boolean

This option enabled to show the menu even if there is only one quality level.

Default: false

var player = videojs('my-video');
player.maxQualitySelector({
  'showSingleItemMenu': true // Turn off hidding menu if there is only one quality level.
});

sort :number

This option enables sorting direction the quality levels in the menu.

0 = Descending (Qualities are listed from highest to lowest top down by height), 1 = Ascending (Qualities are listed from lowest to highest top down by height)

Default: 0

var player = videojs('my-video');
player.maxQualitySelector({
  'sort': 1 // List the qualities from lowest to highest top down.
});

sortEnabled :boolean

This option enables sorting the quality levels in the menu.

Default: true

var player = videojs('my-video');
player.maxQualitySelector({
  'sortEnabled': false // List the quality levels as they have been specified.
});

Usage

โš  Warning: โš  For versions of VideoJS 7 and below, we require the https://github.com/videojs/videojs-contrib-quality-levels plugin to be included before ours.

To include videojs-max-quality-selector on your website or web application, use any of the following methods.

<link> & <script> Tag

This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include [video.js][videojs], so that the videojs global is available.

<link src="//path/to/videojs-max-quality-selector.css" rel="stylesheet">
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-contrib-quality-levels.min.js"></script>
<script src="//path/to/videojs-max-quality-selector.min.js"></script>
<script>
  var player = videojs('my-video');

  player.maxQualitySelector();
</script>

Browserify/CommonJS

When using with Browserify, install videojs-max-quality-selector via npm and require the plugin as you would any other module.

var videojs = require('video.js');

// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
require('videojs-max-quality-selector');

var player = videojs('my-video');

player.maxQualitySelector();

RequireJS/AMD

When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:

require(['video.js', 'videojs-max-quality-selector'], function(videojs) {
  var player = videojs('my-video');

  player.maxQualitySelector();
});

Content Delivery Network CDN

We're using unpkg to serve our files.

File Explorer: https://unpkg.com/videojs-max-quality-selector/

Latest: https://unpkg.com/videojs-max-quality-selector/dist/videojs-max-quality-selector.css https://unpkg.com/videojs-max-quality-selector/dist/videojs-max-quality-selector.min.js

Contributing

We welcome contributions from everyone! Find out how to contribute...

Code of Conduct

Contributor Covenant Code of Conduct

License

MIT. Copyright (c) Fox ([email protected])

videojs-max-quality-selector's People

Contributors

foxcouncil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

videojs-max-quality-selector's Issues

unable to get levels

Maybe I'm doing this wrong but when I try to access the method it always comes back empty.

player.maxQualitySelector().getLevelNames()

How exactly do you use getLevelNames()?

e.log.createLogger is not a function

While trying to call player.maxQualitySelector() get below error.

videojs-max-quality-selector.min.js:2 
        
       Uncaught TypeError: e.log.createLogger is not a function
    at new s (VM5207 videojs-max-quality-selector.min.js:2)
    at Player.maxQualitySelector (VM5200 video.js:24706)
    at Player.onPlayerReady (player.js:133)
    at Player.<anonymous> (VM5200 video.js:3881)
    at Array.forEach (<anonymous>)
    at Player.<anonymous> (VM5200 video.js:3880)
    at bound (VM5200 video.js:2345)

The changelevel method condition seems to always be true

In changeLevel method the value is always true for obj.enabled.

 if (levelIndex < 0) {
      this.qlInternal.levels_.forEach(function(obj, idx) {
        if (self.options.minHeight !== 0 && obj.height >= self.options.minHeight || self.options.maxHeight !== 0 && obj.height <= self.options.maxHeight) {
          obj.enabled = true;
        } else {
          obj.enabled = true;
        }
      });
      this.update();
      return;
    }

Clicking menu item prevents control bar from hiding.

After clicking on one of the menu items the control bar won't 'auto hide' any more. Clicking the main button does not result in the same behavior, just clicking a menu item does.
The expected behavior should be that after you click on a different resolution menu item than what the 'Auto' pre-selects, the control bar should continue to act as expected and auto hide(fade away) once the mouse has left the area of the video.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.