Installations
npm install videojs-contrib-quality-levels
Score
79
Supply Chain
96
Quality
83.7
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Developer
videojs
Developer Guide
Module System
CommonJS, UMD
Min. Node Version
>=16
Typescript Support
Yes
Node Version
16.20.2
NPM Version
8.19.4
Statistics
157 Stars
72 Commits
51 Forks
29 Watching
2 Branches
22 Contributors
Updated on 16 Nov 2024
Bundle Size
2.02 kB
Minified
884.00 B
Minified + Gzipped
Languages
JavaScript (81.87%)
HTML (17.44%)
Shell (0.69%)
Total Downloads
Cumulative downloads
Total Downloads
27,088,885
Last day
-8.2%
45,429
Compared to previous day
Last week
4.2%
250,226
Compared to previous week
Last month
7.4%
1,038,026
Compared to previous month
Last year
1.4%
10,094,626
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Dev Dependencies
25
videojs-contrib-quality-levels
A plugin that provides a framework of working with source quality levels.
Maintenance Status: Stable
Installation
Installation
1npm install --save videojs-contrib-quality-levels
The npm installation is preferred, but Bower works, too.
1bower install --save videojs-contrib-quality-levels
Using
The list of QualityLevels
can be accessed using qualityLevels()
on the Player object.
With this list, you can:
- See which quality levels are available for the current source
- Enable or disable specific quality levels to change which levels are selected by ABR
- See which quality level is currently selected by ABR
- Detect when the selected quality level changes
Example
1let player = videojs('my-video'); 2 3let qualityLevels = player.qualityLevels(); 4 5// disable quality levels with less than 720 horizontal lines of resolution when added 6// to the list. 7qualityLevels.on('addqualitylevel', function(event) { 8 let qualityLevel = event.qualityLevel; 9 10 if (qualityLevel.height >= 720) { 11 qualityLevel.enabled = true; 12 } else { 13 qualityLevel.enabled = false; 14 } 15}); 16 17// example function that will toggle quality levels between SD and HD, defining and HD 18// quality as having 720 horizontal lines of resolution or more 19let toggleQuality = (function() { 20 let enable720 = true; 21 22 return function() { 23 for (let qualityLevel of qualityLevels) { 24 if (qualityLevel.height >= 720) { 25 qualityLevel.enabled = enable720; 26 } else { 27 qualityLevel.enabled = !enable720; 28 } 29 } 30 enable720 = !enable720; 31 }; 32})(); 33 34let currentSelectedQualityLevelIndex = qualityLevels.selectedIndex; // -1 if no level selected 35 36// Listen to change events for when the player selects a new quality level 37qualityLevels.on('change', function() { 38 console.log('Quality Level changed!'); 39 console.log('New level:', qualityLevels[qualityLevels.selectedIndex]); 40});
Supporting Quality Levels for your source
This project provides the framework for working with source quality levels. Just including this project alongside videojs does not necessarily mean that there will be levels available in the list or that any events will be triggered. Some projects within the videojs org supports this project and automatically populates the list and triggers change
events when the selected quality level changes. See the Supported Projects section for a list of these projects.
If you are not using one of the supported projects, but still want to use quality levels with your source, you will have to implement your own plugin that populates the list and triggers change events when selected level changes. Implementing such a plugin is very specific to the source in question, so it is difficult to provide specific examples, but will most likely require a custom middleware, source handler, or tech.
Populating the list
Initially the list of quality levels will be empty. You can add quality levels to the list by using QualityLevelList.addQualityLevel
for each quality level specific to your source. QualityLevelList.addQualityLevel
takes in a Representation
object (or generic object with the required properties). All properties are required except width
, height
and frameRate
.
Example Representation
1Representation { 2 id: string, 3 width: number, 4 height: number, 5 bitrate: number, 6 frameRate: number, 7 enabled: function 8}
The enabled
function should take an optional boolean to enable or disable the representation and return whether it is currently enabled.
You can also remove quality levels from the list using QualityLevelList.removeQualityLevel
. Call this function with the reference to the QualityLevel
object you wish to remove. The QualityLevelList.selectedIndex
property will automatically be updated when a quality level is removed so that it still refers to the correct level. If the currently selected level is removed, the selectedIndex
will be set to -1
.
Triggering the 'change' event
When your playback plugin changes the selected quality for playback, you will also have to trigger the change
event on the QualityLevelList
and update the QualityLevelList.selectedIndex_
, as it does not have knowledge of which quality is active in playback.
1let player = videojs('my-video'); 2 3let qualityLevels = player.qualityLevels(); 4 5qualityLevels.selectedIndex_ = 0; 6qualityLevels.trigger({ type: 'change', selectedIndex: 0 });
Supported Projects
The following projects have built-in support for videojs-contrib-quality-levels and will automatically populate the list with available levels and trigger change
events when the quality level changes.
- HLS
- @videojs/http-streaming
- Recommended for HLS
- http-streaming is included by default with video.js version 7+
- videojs-contrib-hls
- version 4.1+
- @videojs/http-streaming
- DASH
- @videojs/http-streaming
- http-streaming is included by default with video.js version 7+
- @videojs/http-streaming
Including the Plugin
To include videojs-contrib-quality-levels on your website or web application, use any of the following methods.
<script>
Tag
This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs
global is available.
1<script src="//path/to/video.min.js"></script> 2<script src="//path/to/videojs-contrib-quality-levels.min.js"></script> 3<script> 4 var player = videojs('my-video'); 5 6 player.qualityLevels(); 7</script>
Browserify
When using with Browserify, install videojs-contrib-quality-levels via npm and require
the plugin as you would any other module.
1var videojs = require('video.js'); 2 3// The actual plugin function is exported by this module, but it is also 4// attached to the `Player.prototype`; so, there is no need to assign it 5// to a variable. 6require('videojs-contrib-quality-levels'); 7 8var player = videojs('my-video'); 9 10player.qualityLevels();
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:
1require(['video.js', 'videojs-contrib-quality-levels'], function(videojs) { 2 var player = videojs('my-video'); 3 4 player.qualityLevels(); 5});
License
Apache-2.0. Copyright (c) Brightcove, Inc.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
Found 17/26 approved changesets -- score normalized to 6
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/videojs-contrib-quality-levels/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/videojs-contrib-quality-levels/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/videojs-contrib-quality-levels/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:64: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/videojs-contrib-quality-levels/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/videojs-contrib-quality-levels/ci.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:62
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to videojs-contrib-quality-levels
@types/videojs-contrib-quality-levels
TypeScript definitions for videojs-contrib-quality-levels
videojs-http-source-selector
VideoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-selectable level selection options for adaptive http streams.
jb-videojs-hls-quality-selector
Adds a quality selector menu for HLS sources played in videojs. Requires `videojs-contrib-hls` and videojs-contrib-quality-levels plugins.
videojs-http-quality-selector
VideoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-selectable level selection options for adaptive http streams. Based on videojs-http-source-selector