Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

videojs-hls-source-selector

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-hls-source-selector - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

79

dist/videojs-http-source-selector.cjs.js

@@ -7,3 +7,3 @@ 'use strict';

var version = "1.0.0";
var version = "1.0.1";

@@ -71,6 +71,6 @@ var classCallCheck = function (instance, Constructor) {

options.selectable = true;
var qualityLevels = player.qualityLevels();
//var qualityLevels = this.player().qualityLevels();
qualityLevels.on('change', videojs.bind(_this, _this.update));
player.on('resolutionchange', videojs.bind(_this, _this.update));
//qualityLevels.on('change', videojs.bind(this, this.update));
//this.player.on('resolutionchange', videojs.bind(this, this.update));
return _this;

@@ -82,13 +82,13 @@ }

console.log("qualityLevels: ");
console.log(player.qualityLevels());
console.log(this.player().qualityLevels());
this.selected_ = true;
this.selected(true);
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < this.player().qualityLevels().length; i++) {
//If this is the Auto option, enable all renditions for adaptive selection
if (this.options_.index == player.qualityLevels().length) {
player.qualityLevels()[i].enabled = true;
if (this.options_.index == this.player().qualityLevels().length) {
this.player().qualityLevels()[i].enabled = true;
} else if (i == this.options_.index) {
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;
}

@@ -99,3 +99,3 @@ }

SourceMenuItem.prototype.update = function update() {
var selection = player.qualityLevels().selectedIndex;
var selection = this.player().qualityLevels().selectedIndex;
console.log(this.options_.index + " == " + selection);

@@ -130,3 +130,3 @@ console.log("menuItem.index === qualityLevels().selectedIndex");

MenuButton.apply(_this, arguments);
var qualityLevels = player.qualityLevels();
var qualityLevels = _this.player().qualityLevels();
// Handle options: We accept an options.default value of ( high || low )

@@ -136,20 +136,20 @@ // This determines a bias to set initial resolution selection.

console.log("options.default: " + options.default);
console.log("player.qualityLevels(): ");
console.log(player.qualityLevels());
console.log("player.qualityLevels().length: ");
console.log(player.qualityLevels().length);
console.log("this.player().qualityLevels(): ");
console.log(_this.player().qualityLevels());
console.log("this.player().qualityLevels().length: ");
console.log(_this.player().qualityLevels().length);
if (options.default == 'low') {
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == 0) {
player.qualityLevels()[i].enabled = true;
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}
}
} else if (options.default = 'high') {
for (var i = 0; i < player.qualityLevels().length; i++) {
if (i == player.qualityLevels().length - 1) {
player.qualityLevels()[i].enabled = true;
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == _this.player().qualityLevels().length - 1) {
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}

@@ -160,3 +160,3 @@ }

// Bind update to qualityLevels changes
qualityLevels.on(['change', 'addqualitylevel'], videojs.bind(_this, _this.update));
//qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
return _this;

@@ -184,15 +184,15 @@ }

var menuItems = [];
var labels = player.qualityLevels || {};
var labels = this.player.qualityLevels || {};
for (var i = 0; i < player.qualityLevels().length; i++) {
var j = player.qualityLevels().length - (i + 1);
for (var i = 0; i < this.player().qualityLevels().length; i++) {
var j = this.player().qualityLevels().length - (i + 1);
//console.log(player.qualityLevels()[j].id);
//console.log(player.qualityLevels()[j]);
//console.log(this.player().qualityLevels()[j].id);
//console.log(this.player().qualityLevels()[j]);
var label = "" + j;
//Display height if height metadata is provided with the stream, else use bitrate
if (player.qualityLevels()[j].height) {
label = player.qualityLevels()[j].height;
} else if (player.qualityLevels()[j].bitrate) {
label = Math.floor(player.qualityLevels()[j].bitrate / 1e3) + ' kbps';
if (this.player().qualityLevels()[j].height) {
label = this.player().qualityLevels()[j].height;
} else if (this.player().qualityLevels()[j].bitrate) {
label = Math.floor(this.player().qualityLevels()[j].bitrate / 1e3) + ' kbps';
}

@@ -203,10 +203,10 @@

index: j,
selected: j === (player.qualityLevels.selectedIndex ? label : false)
selected: j === (this.player().qualityLevels().selectedIndex ? label : false)
}));
}
//If there are more than one quality levels, offer an 'auto' option
if (player.qualityLevels().length > 1) {
if (this.player().qualityLevels().length > 1) {
menuItems.push(new SourceMenuItem(this.player_, {
label: 'Auto',
index: player.qualityLevels().length,
index: this.player().qualityLevels().length,
selected: false

@@ -246,3 +246,2 @@ }));

var qualityLevels = player.qualityLevels();
console.log("player.techName_:" + player.techName_);

@@ -260,2 +259,3 @@ //This plugin only supports level selection for HLS playback

player.on(['loadedmetadata'], function (e) {
var qualityLevels = player.qualityLevels();
videojs$1.log('loadmeadata event');

@@ -265,9 +265,7 @@ // hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.

console.log("player.videojs_http_source_selector_initialized == true");
return;
} else {
console.log("player.videojs_http_source_selector_initialized == false");
player.videojs_http_source_selector_initialized = true;
player.getChild('controlBar').addChild('SourceMenuButton', {});
}
player.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -293,2 +291,3 @@ };

onPlayerReady(_this, videojs$1.mergeOptions(defaults, options));
//this.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -295,0 +294,0 @@

import videojs$1 from 'video.js';
var version = "1.0.0";
var version = "1.0.1";

@@ -66,6 +66,6 @@ var classCallCheck = function (instance, Constructor) {

options.selectable = true;
var qualityLevels = player.qualityLevels();
//var qualityLevels = this.player().qualityLevels();
qualityLevels.on('change', videojs.bind(_this, _this.update));
player.on('resolutionchange', videojs.bind(_this, _this.update));
//qualityLevels.on('change', videojs.bind(this, this.update));
//this.player.on('resolutionchange', videojs.bind(this, this.update));
return _this;

@@ -77,13 +77,13 @@ }

console.log("qualityLevels: ");
console.log(player.qualityLevels());
console.log(this.player().qualityLevels());
this.selected_ = true;
this.selected(true);
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < this.player().qualityLevels().length; i++) {
//If this is the Auto option, enable all renditions for adaptive selection
if (this.options_.index == player.qualityLevels().length) {
player.qualityLevels()[i].enabled = true;
if (this.options_.index == this.player().qualityLevels().length) {
this.player().qualityLevels()[i].enabled = true;
} else if (i == this.options_.index) {
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;
}

@@ -94,3 +94,3 @@ }

SourceMenuItem.prototype.update = function update() {
var selection = player.qualityLevels().selectedIndex;
var selection = this.player().qualityLevels().selectedIndex;
console.log(this.options_.index + " == " + selection);

@@ -125,3 +125,3 @@ console.log("menuItem.index === qualityLevels().selectedIndex");

MenuButton.apply(_this, arguments);
var qualityLevels = player.qualityLevels();
var qualityLevels = _this.player().qualityLevels();
// Handle options: We accept an options.default value of ( high || low )

@@ -131,20 +131,20 @@ // This determines a bias to set initial resolution selection.

console.log("options.default: " + options.default);
console.log("player.qualityLevels(): ");
console.log(player.qualityLevels());
console.log("player.qualityLevels().length: ");
console.log(player.qualityLevels().length);
console.log("this.player().qualityLevels(): ");
console.log(_this.player().qualityLevels());
console.log("this.player().qualityLevels().length: ");
console.log(_this.player().qualityLevels().length);
if (options.default == 'low') {
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == 0) {
player.qualityLevels()[i].enabled = true;
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}
}
} else if (options.default = 'high') {
for (var i = 0; i < player.qualityLevels().length; i++) {
if (i == player.qualityLevels().length - 1) {
player.qualityLevels()[i].enabled = true;
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == _this.player().qualityLevels().length - 1) {
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}

@@ -155,3 +155,3 @@ }

// Bind update to qualityLevels changes
qualityLevels.on(['change', 'addqualitylevel'], videojs.bind(_this, _this.update));
//qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
return _this;

@@ -179,15 +179,15 @@ }

var menuItems = [];
var labels = player.qualityLevels || {};
var labels = this.player.qualityLevels || {};
for (var i = 0; i < player.qualityLevels().length; i++) {
var j = player.qualityLevels().length - (i + 1);
for (var i = 0; i < this.player().qualityLevels().length; i++) {
var j = this.player().qualityLevels().length - (i + 1);
//console.log(player.qualityLevels()[j].id);
//console.log(player.qualityLevels()[j]);
//console.log(this.player().qualityLevels()[j].id);
//console.log(this.player().qualityLevels()[j]);
var label = "" + j;
//Display height if height metadata is provided with the stream, else use bitrate
if (player.qualityLevels()[j].height) {
label = player.qualityLevels()[j].height;
} else if (player.qualityLevels()[j].bitrate) {
label = Math.floor(player.qualityLevels()[j].bitrate / 1e3) + ' kbps';
if (this.player().qualityLevels()[j].height) {
label = this.player().qualityLevels()[j].height;
} else if (this.player().qualityLevels()[j].bitrate) {
label = Math.floor(this.player().qualityLevels()[j].bitrate / 1e3) + ' kbps';
}

@@ -198,10 +198,10 @@

index: j,
selected: j === (player.qualityLevels.selectedIndex ? label : false)
selected: j === (this.player().qualityLevels().selectedIndex ? label : false)
}));
}
//If there are more than one quality levels, offer an 'auto' option
if (player.qualityLevels().length > 1) {
if (this.player().qualityLevels().length > 1) {
menuItems.push(new SourceMenuItem(this.player_, {
label: 'Auto',
index: player.qualityLevels().length,
index: this.player().qualityLevels().length,
selected: false

@@ -241,3 +241,2 @@ }));

var qualityLevels = player.qualityLevels();
console.log("player.techName_:" + player.techName_);

@@ -255,2 +254,3 @@ //This plugin only supports level selection for HLS playback

player.on(['loadedmetadata'], function (e) {
var qualityLevels = player.qualityLevels();
videojs$1.log('loadmeadata event');

@@ -260,9 +260,7 @@ // hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.

console.log("player.videojs_http_source_selector_initialized == true");
return;
} else {
console.log("player.videojs_http_source_selector_initialized == false");
player.videojs_http_source_selector_initialized = true;
player.getChild('controlBar').addChild('SourceMenuButton', {});
}
player.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -288,2 +286,3 @@ };

onPlayerReady(_this, videojs$1.mergeOptions(defaults, options));
//this.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -290,0 +289,0 @@

/**
* videojs-hls-source-selector
* @version 1.0.0
* @version 1.0.1
* @copyright 2018 Justin Fujita <Justin@pivotshare.com>

@@ -15,3 +15,3 @@ * @license MIT

var version = "1.0.0";
var version = "1.0.1";

@@ -79,6 +79,6 @@ var classCallCheck = function (instance, Constructor) {

options.selectable = true;
var qualityLevels = player.qualityLevels();
//var qualityLevels = this.player().qualityLevels();
qualityLevels.on('change', videojs.bind(_this, _this.update));
player.on('resolutionchange', videojs.bind(_this, _this.update));
//qualityLevels.on('change', videojs.bind(this, this.update));
//this.player.on('resolutionchange', videojs.bind(this, this.update));
return _this;

@@ -90,13 +90,13 @@ }

console.log("qualityLevels: ");
console.log(player.qualityLevels());
console.log(this.player().qualityLevels());
this.selected_ = true;
this.selected(true);
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < this.player().qualityLevels().length; i++) {
//If this is the Auto option, enable all renditions for adaptive selection
if (this.options_.index == player.qualityLevels().length) {
player.qualityLevels()[i].enabled = true;
if (this.options_.index == this.player().qualityLevels().length) {
this.player().qualityLevels()[i].enabled = true;
} else if (i == this.options_.index) {
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;
}

@@ -107,3 +107,3 @@ }

SourceMenuItem.prototype.update = function update() {
var selection = player.qualityLevels().selectedIndex;
var selection = this.player().qualityLevels().selectedIndex;
console.log(this.options_.index + " == " + selection);

@@ -138,3 +138,3 @@ console.log("menuItem.index === qualityLevels().selectedIndex");

MenuButton.apply(_this, arguments);
var qualityLevels = player.qualityLevels();
var qualityLevels = _this.player().qualityLevels();
// Handle options: We accept an options.default value of ( high || low )

@@ -144,20 +144,20 @@ // This determines a bias to set initial resolution selection.

console.log("options.default: " + options.default);
console.log("player.qualityLevels(): ");
console.log(player.qualityLevels());
console.log("player.qualityLevels().length: ");
console.log(player.qualityLevels().length);
console.log("this.player().qualityLevels(): ");
console.log(_this.player().qualityLevels());
console.log("this.player().qualityLevels().length: ");
console.log(_this.player().qualityLevels().length);
if (options.default == 'low') {
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == 0) {
player.qualityLevels()[i].enabled = true;
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}
}
} else if (options.default = 'high') {
for (var i = 0; i < player.qualityLevels().length; i++) {
if (i == player.qualityLevels().length - 1) {
player.qualityLevels()[i].enabled = true;
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == _this.player().qualityLevels().length - 1) {
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}

@@ -168,3 +168,3 @@ }

// Bind update to qualityLevels changes
qualityLevels.on(['change', 'addqualitylevel'], videojs.bind(_this, _this.update));
//qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
return _this;

@@ -192,15 +192,15 @@ }

var menuItems = [];
var labels = player.qualityLevels || {};
var labels = this.player.qualityLevels || {};
for (var i = 0; i < player.qualityLevels().length; i++) {
var j = player.qualityLevels().length - (i + 1);
for (var i = 0; i < this.player().qualityLevels().length; i++) {
var j = this.player().qualityLevels().length - (i + 1);
//console.log(player.qualityLevels()[j].id);
//console.log(player.qualityLevels()[j]);
//console.log(this.player().qualityLevels()[j].id);
//console.log(this.player().qualityLevels()[j]);
var label = "" + j;
//Display height if height metadata is provided with the stream, else use bitrate
if (player.qualityLevels()[j].height) {
label = player.qualityLevels()[j].height;
} else if (player.qualityLevels()[j].bitrate) {
label = Math.floor(player.qualityLevels()[j].bitrate / 1e3) + ' kbps';
if (this.player().qualityLevels()[j].height) {
label = this.player().qualityLevels()[j].height;
} else if (this.player().qualityLevels()[j].bitrate) {
label = Math.floor(this.player().qualityLevels()[j].bitrate / 1e3) + ' kbps';
}

@@ -211,10 +211,10 @@

index: j,
selected: j === (player.qualityLevels.selectedIndex ? label : false)
selected: j === (this.player().qualityLevels().selectedIndex ? label : false)
}));
}
//If there are more than one quality levels, offer an 'auto' option
if (player.qualityLevels().length > 1) {
if (this.player().qualityLevels().length > 1) {
menuItems.push(new SourceMenuItem(this.player_, {
label: 'Auto',
index: player.qualityLevels().length,
index: this.player().qualityLevels().length,
selected: false

@@ -254,3 +254,2 @@ }));

var qualityLevels = player.qualityLevels();
console.log("player.techName_:" + player.techName_);

@@ -268,2 +267,3 @@ //This plugin only supports level selection for HLS playback

player.on(['loadedmetadata'], function (e) {
var qualityLevels = player.qualityLevels();
videojs$1.log('loadmeadata event');

@@ -273,9 +273,7 @@ // hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.

console.log("player.videojs_http_source_selector_initialized == true");
return;
} else {
console.log("player.videojs_http_source_selector_initialized == false");
player.videojs_http_source_selector_initialized = true;
player.getChild('controlBar').addChild('SourceMenuButton', {});
}
player.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -301,2 +299,3 @@ };

onPlayerReady(_this, videojs$1.mergeOptions(defaults, options));
//this.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -303,0 +302,0 @@

/**
* videojs-hls-source-selector
* @version 1.0.0
* @version 1.0.1
* @copyright 2018 Justin Fujita <Justin@pivotshare.com>
* @license MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],t):e.videojsHttpSourceSelector=t(e.videojs)}(this,function(l){"use strict";l=l&&l.hasOwnProperty("default")?l.default:l;var a=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},n=function(o){function n(e,t){a(this,n);var l=r(this,o.call(this,e,t));return t.selectable=!0,e.qualityLevels().on("change",videojs.bind(l,l.update)),e.on("resolutionchange",videojs.bind(l,l.update)),l}return e(n,o),n.prototype.handleClick=function(){console.log("Change quality to "+this.options_.label),console.log("qualityLevels: "),console.log(player.qualityLevels()),this.selected_=!0,this.selected(!0);for(var e=0;e<player.qualityLevels().length;e++)this.options_.index==player.qualityLevels().length?player.qualityLevels()[e].enabled=!0:e==this.options_.index?player.qualityLevels()[e].enabled=!0:player.qualityLevels()[e].enabled=!1},n.prototype.update=function(){var e=player.qualityLevels().selectedIndex;console.log(this.options_.index+" == "+e),console.log("menuItem.index === qualityLevels().selectedIndex"),this.selected(this.options_.index==e),this.selected_=this.options_.index===e},n}(videojs.getComponent("MenuItem")),u=videojs.getComponent("MenuButton"),o=function(i){function s(e,t){a(this,s);var l=r(this,i.call(this,e,t));u.apply(l,arguments);var o=e.qualityLevels();if(t&&t.default)if(console.log("options.default: "+t.default),console.log("player.qualityLevels(): "),console.log(e.qualityLevels()),console.log("player.qualityLevels().length: "),console.log(e.qualityLevels().length),"low"==t.default)for(var n=0;n<e.qualityLevels().length;n++)e.qualityLevels()[n].enabled=0==n;else if(t.default="high")for(n=0;n<e.qualityLevels().length;n++)n==e.qualityLevels().length-1?e.qualityLevels()[n].enabled=!0:e.qualityLevels()[n].enabled=!1;return o.on(["change","addqualitylevel"],videojs.bind(l,l.update)),l}return e(s,i),s.prototype.createEl=function(){return videojs.dom.createEl("div",{className:"vjs-http-source-selector vjs-menu-button vjs-menu-button-popup vjs-control vjs-button"})},s.prototype.buildCSSClass=function(){return u.prototype.buildCSSClass.call(this)+" vjs-icon-cog"},s.prototype.update=function(){return u.prototype.update.call(this)},s.prototype.createItems=function(){for(var e=[],t=(player.qualityLevels,0);t<player.qualityLevels().length;t++){var l=player.qualityLevels().length-(t+1),o=""+l;player.qualityLevels()[l].height?o=player.qualityLevels()[l].height:player.qualityLevels()[l].bitrate&&(o=Math.floor(player.qualityLevels()[l].bitrate/1e3)+" kbps"),e.push(new n(this.player_,{label:o,index:l,selected:l===(!!player.qualityLevels.selectedIndex&&o)}))}return 1<player.qualityLevels().length&&e.push(new n(this.player_,{label:"Auto",index:player.qualityLevels().length,selected:!1})),e},s}(u),i={},t=l.registerPlugin||l.plugin,s=function(e){var t=this;this.ready(function(){!function(t,e){t.addClass("vjs-http-source-selector"),console.log("videojs-http-source-selector initialized!");t.qualityLevels();if(console.log("player.techName_:"+t.techName_),"Html5"!=t.techName_)return;t.on(["loadedmetadata"],function(e){l.log("loadmeadata event"),"undefined"!=t.videojs_http_source_selector_initialized&&1!=t.videojs_http_source_selector_initialized?(console.log("player.videojs_http_source_selector_initialized == false"),t.videojs_http_source_selector_initialized=!0,t.getChild("controlBar").addChild("SourceMenuButton",{})):console.log("player.videojs_http_source_selector_initialized == true")})}(t,l.mergeOptions(i,e))}),l.registerComponent("SourceMenuButton",o),l.registerComponent("SourceMenuItem",n)};return t("httpSourceSelector",s),s.VERSION="1.0.0",s});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],t):e.videojsHttpSourceSelector=t(e.videojs)}(this,function(l){"use strict";l=l&&l.hasOwnProperty("default")?l.default:l;var n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},a=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},r=function(o){function i(e,t){n(this,i);var l=a(this,o.call(this,e,t));return t.selectable=!0,l}return e(i,o),i.prototype.handleClick=function(){console.log("Change quality to "+this.options_.label),console.log("qualityLevels: "),console.log(this.player().qualityLevels()),this.selected_=!0,this.selected(!0);for(var e=0;e<this.player().qualityLevels().length;e++)this.options_.index==this.player().qualityLevels().length?this.player().qualityLevels()[e].enabled=!0:e==this.options_.index?this.player().qualityLevels()[e].enabled=!0:this.player().qualityLevels()[e].enabled=!1},i.prototype.update=function(){var e=this.player().qualityLevels().selectedIndex;console.log(this.options_.index+" == "+e),console.log("menuItem.index === qualityLevels().selectedIndex"),this.selected(this.options_.index==e),this.selected_=this.options_.index===e},i}(videojs.getComponent("MenuItem")),u=videojs.getComponent("MenuButton"),o=function(i){function s(e,t){n(this,s);var l=a(this,i.call(this,e,t));u.apply(l,arguments);l.player().qualityLevels();if(t&&t.default)if(console.log("options.default: "+t.default),console.log("this.player().qualityLevels(): "),console.log(l.player().qualityLevels()),console.log("this.player().qualityLevels().length: "),console.log(l.player().qualityLevels().length),"low"==t.default)for(var o=0;o<l.player().qualityLevels().length;o++)l.player().qualityLevels()[o].enabled=0==o;else if(t.default="high")for(o=0;o<l.player().qualityLevels().length;o++)o==l.player().qualityLevels().length-1?l.player().qualityLevels()[o].enabled=!0:l.player().qualityLevels()[o].enabled=!1;return l}return e(s,i),s.prototype.createEl=function(){return videojs.dom.createEl("div",{className:"vjs-http-source-selector vjs-menu-button vjs-menu-button-popup vjs-control vjs-button"})},s.prototype.buildCSSClass=function(){return u.prototype.buildCSSClass.call(this)+" vjs-icon-cog"},s.prototype.update=function(){return u.prototype.update.call(this)},s.prototype.createItems=function(){for(var e=[],t=(this.player.qualityLevels,0);t<this.player().qualityLevels().length;t++){var l=this.player().qualityLevels().length-(t+1),o=""+l;this.player().qualityLevels()[l].height?o=this.player().qualityLevels()[l].height:this.player().qualityLevels()[l].bitrate&&(o=Math.floor(this.player().qualityLevels()[l].bitrate/1e3)+" kbps"),e.push(new r(this.player_,{label:o,index:l,selected:l===(!!this.player().qualityLevels().selectedIndex&&o)}))}return 1<this.player().qualityLevels().length&&e.push(new r(this.player_,{label:"Auto",index:this.player().qualityLevels().length,selected:!1})),e},s}(u),i={},t=l.registerPlugin||l.plugin,s=function(e){var t=this;this.ready(function(){!function(t,e){if(t.addClass("vjs-http-source-selector"),console.log("videojs-http-source-selector initialized!"),console.log("player.techName_:"+t.techName_),"Html5"!=t.techName_)return;t.on(["loadedmetadata"],function(e){t.qualityLevels(),l.log("loadmeadata event"),"undefined"==t.videojs_http_source_selector_initialized||1==t.videojs_http_source_selector_initialized?console.log("player.videojs_http_source_selector_initialized == true"):(console.log("player.videojs_http_source_selector_initialized == false"),t.videojs_http_source_selector_initialized=!0,t.getChild("controlBar").addChild("SourceMenuButton",{}))})}(t,l.mergeOptions(i,e))}),l.registerComponent("SourceMenuButton",o),l.registerComponent("SourceMenuItem",r)};return t("httpSourceSelector",s),s.VERSION="1.0.1",s});
{
"name": "videojs-hls-source-selector",
"version": "1.0.0",
"version": "1.0.1",
"description": "VideoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-selectable level selection options for adaptive http streams.",

@@ -5,0 +5,0 @@ "main": "dist/videojs-http-source-selector.cjs.js",

@@ -1,8 +0,10 @@

# ~~videojs-hls-source-selector~~ is now [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector)
# ~~videojs-hls-source-selector~~ HAS MOVED
VideoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-selectable level selection options for adaptive http (hls+dash) streams.
videojs-hls-source-selector is now [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector):
A videoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-selectable level selection options for adaptive http (hls+dash) streams.
## Deprecated/New!
This plugin should be compatible with both HTTP streaming protocols (HLS + DASH) and thus has been moved from videojs-hls-source-selector to videojs-**http**-source-selector. The latest version of this lib (0.0.8) has been brought up to coincide with the source maintained on the [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector) repo. Consider this repo deprecated in favor of updates that will be published to [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector).
This plugin should be compatible with both HTTP streaming protocols (HLS + DASH) and thus has been moved from videojs-hls-source-selector to [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector). The latest version of this lib (1.0.1) has been brought up to coincide with the source maintained on the [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector) repo. Consider this repo deprecated in favor of updates that will be published to [videojs-http-source-selector](https://www.npmjs.com/package/videojs-http-source-selector).

@@ -9,0 +11,0 @@ ## Updating from an older version

@@ -18,3 +18,3 @@ import SourceMenuItem from './SourceMenuItem';

MenuButton.apply(this, arguments);
var qualityLevels = player.qualityLevels();
var qualityLevels = this.player().qualityLevels();
// Handle options: We accept an options.default value of ( high || low )

@@ -25,13 +25,13 @@ // This determines a bias to set initial resolution selection.

console.log("options.default: "+options.default);
console.log("player.qualityLevels(): ");
console.log(player.qualityLevels());
console.log("player.qualityLevels().length: ");
console.log(player.qualityLevels().length);
console.log("this.player().qualityLevels(): ");
console.log(this.player().qualityLevels());
console.log("this.player().qualityLevels().length: ");
console.log(this.player().qualityLevels().length);
if(options.default == 'low')
{
for(var i = 0; i < player.qualityLevels().length; i++)
for(var i = 0; i < this.player().qualityLevels().length; i++)
{
if(i == 0)
{
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;

@@ -41,3 +41,3 @@ }

{
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;

@@ -49,7 +49,7 @@ }

{
for(var i = 0; i < player.qualityLevels().length; i++)
for(var i = 0; i < this.player().qualityLevels().length; i++)
{
if(i == player.qualityLevels().length - 1)
if(i == this.player().qualityLevels().length - 1)
{
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;

@@ -59,3 +59,3 @@ }

{
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;

@@ -67,3 +67,3 @@ }

// Bind update to qualityLevels changes
qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
//qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
};

@@ -95,19 +95,19 @@

var menuItems = [];
var labels = (player.qualityLevels) || {};
var labels = (this.player.qualityLevels) || {};
for(var i = 0; i < player.qualityLevels().length; i++)
for(var i = 0; i < this.player().qualityLevels().length; i++)
{
var j = player.qualityLevels().length - (i + 1);
var j = this.player().qualityLevels().length - (i + 1);
//console.log(player.qualityLevels()[j].id);
//console.log(player.qualityLevels()[j]);
//console.log(this.player().qualityLevels()[j].id);
//console.log(this.player().qualityLevels()[j]);
var label = ""+j;
//Display height if height metadata is provided with the stream, else use bitrate
if(player.qualityLevels()[j].height)
if(this.player().qualityLevels()[j].height)
{
label = player.qualityLevels()[j].height;
label = this.player().qualityLevels()[j].height;
}
else if(player.qualityLevels()[j].bitrate)
else if(this.player().qualityLevels()[j].bitrate)
{
label = Math.floor(player.qualityLevels()[j].bitrate / 1e3)+' kbps';
label = Math.floor(this.player().qualityLevels()[j].bitrate / 1e3)+' kbps';
}

@@ -120,3 +120,3 @@

index: j,
selected: j === (player.qualityLevels.selectedIndex ? label : false)
selected: j === (this.player().qualityLevels().selectedIndex ? label : false)
})

@@ -126,3 +126,3 @@ );

//If there are more than one quality levels, offer an 'auto' option
if(player.qualityLevels().length > 1)
if(this.player().qualityLevels().length > 1)
{

@@ -133,3 +133,3 @@ menuItems.push(new SourceMenuItem(

label:'Auto',
index:player.qualityLevels().length,
index:this.player().qualityLevels().length,
selected: false

@@ -136,0 +136,0 @@ })

@@ -10,6 +10,6 @@ const MenuItem = videojs.getComponent('MenuItem');

options.selectable = true;
var qualityLevels = player.qualityLevels();
//var qualityLevels = this.player().qualityLevels();
qualityLevels.on('change', videojs.bind(this, this.update));
player.on('resolutionchange', videojs.bind(this, this.update));
//qualityLevels.on('change', videojs.bind(this, this.update));
//this.player.on('resolutionchange', videojs.bind(this, this.update));
}

@@ -21,19 +21,19 @@

console.log("qualityLevels: ");
console.log(player.qualityLevels());
console.log(this.player().qualityLevels());
this.selected_=true;
this.selected(true);
for(var i = 0; i < player.qualityLevels().length; i++)
for(var i = 0; i < this.player().qualityLevels().length; i++)
{
//If this is the Auto option, enable all renditions for adaptive selection
if(this.options_.index == player.qualityLevels().length)
if(this.options_.index == this.player().qualityLevels().length)
{
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
}
else if(i == this.options_.index)
{
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
}
else
{
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;
}

@@ -45,3 +45,3 @@ }

{
var selection = player.qualityLevels().selectedIndex;
var selection = this.player().qualityLevels().selectedIndex;
console.log(this.options_.index+" == "+selection);

@@ -48,0 +48,0 @@ console.log("menuItem.index === qualityLevels().selectedIndex");

@@ -33,3 +33,2 @@ import videojs from 'video.js';

var qualityLevels = player.qualityLevels();
console.log("player.techName_:"+player.techName_);

@@ -49,2 +48,3 @@ //This plugin only supports level selection for HLS playback

{
var qualityLevels = player.qualityLevels();
videojs.log('loadmeadata event');

@@ -55,3 +55,2 @@ // hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.

console.log("player.videojs_http_source_selector_initialized == true");
return;
}

@@ -62,5 +61,4 @@ else

player.videojs_http_source_selector_initialized = true;
player.getChild('controlBar').addChild('SourceMenuButton', {});
}
player.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -84,2 +82,3 @@ };

onPlayerReady(this, videojs.mergeOptions(defaults, options));
//this.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -86,0 +85,0 @@

@@ -37,3 +37,3 @@ (function (QUnit,sinon,videojs$1) {

var version = "1.0.0";
var version = "1.0.1";

@@ -117,6 +117,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

options.selectable = true;
var qualityLevels = player.qualityLevels();
//var qualityLevels = this.player().qualityLevels();
qualityLevels.on('change', videojs.bind(_this, _this.update));
player.on('resolutionchange', videojs.bind(_this, _this.update));
//qualityLevels.on('change', videojs.bind(this, this.update));
//this.player.on('resolutionchange', videojs.bind(this, this.update));
return _this;

@@ -128,13 +128,13 @@ }

console.log("qualityLevels: ");
console.log(player.qualityLevels());
console.log(this.player().qualityLevels());
this.selected_ = true;
this.selected(true);
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < this.player().qualityLevels().length; i++) {
//If this is the Auto option, enable all renditions for adaptive selection
if (this.options_.index == player.qualityLevels().length) {
player.qualityLevels()[i].enabled = true;
if (this.options_.index == this.player().qualityLevels().length) {
this.player().qualityLevels()[i].enabled = true;
} else if (i == this.options_.index) {
player.qualityLevels()[i].enabled = true;
this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
this.player().qualityLevels()[i].enabled = false;
}

@@ -145,3 +145,3 @@ }

SourceMenuItem.prototype.update = function update() {
var selection = player.qualityLevels().selectedIndex;
var selection = this.player().qualityLevels().selectedIndex;
console.log(this.options_.index + " == " + selection);

@@ -176,3 +176,3 @@ console.log("menuItem.index === qualityLevels().selectedIndex");

MenuButton.apply(_this, arguments);
var qualityLevels = player.qualityLevels();
var qualityLevels = _this.player().qualityLevels();
// Handle options: We accept an options.default value of ( high || low )

@@ -182,20 +182,20 @@ // This determines a bias to set initial resolution selection.

console.log("options.default: " + options.default);
console.log("player.qualityLevels(): ");
console.log(player.qualityLevels());
console.log("player.qualityLevels().length: ");
console.log(player.qualityLevels().length);
console.log("this.player().qualityLevels(): ");
console.log(_this.player().qualityLevels());
console.log("this.player().qualityLevels().length: ");
console.log(_this.player().qualityLevels().length);
if (options.default == 'low') {
for (var i = 0; i < player.qualityLevels().length; i++) {
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == 0) {
player.qualityLevels()[i].enabled = true;
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}
}
} else if (options.default = 'high') {
for (var i = 0; i < player.qualityLevels().length; i++) {
if (i == player.qualityLevels().length - 1) {
player.qualityLevels()[i].enabled = true;
for (var i = 0; i < _this.player().qualityLevels().length; i++) {
if (i == _this.player().qualityLevels().length - 1) {
_this.player().qualityLevels()[i].enabled = true;
} else {
player.qualityLevels()[i].enabled = false;
_this.player().qualityLevels()[i].enabled = false;
}

@@ -206,3 +206,3 @@ }

// Bind update to qualityLevels changes
qualityLevels.on(['change', 'addqualitylevel'], videojs.bind(_this, _this.update));
//qualityLevels.on(['change', 'addqualitylevel'], videojs.bind( this, this.update) );
return _this;

@@ -230,15 +230,15 @@ }

var menuItems = [];
var labels = player.qualityLevels || {};
var labels = this.player.qualityLevels || {};
for (var i = 0; i < player.qualityLevels().length; i++) {
var j = player.qualityLevels().length - (i + 1);
for (var i = 0; i < this.player().qualityLevels().length; i++) {
var j = this.player().qualityLevels().length - (i + 1);
//console.log(player.qualityLevels()[j].id);
//console.log(player.qualityLevels()[j]);
//console.log(this.player().qualityLevels()[j].id);
//console.log(this.player().qualityLevels()[j]);
var label = "" + j;
//Display height if height metadata is provided with the stream, else use bitrate
if (player.qualityLevels()[j].height) {
label = player.qualityLevels()[j].height;
} else if (player.qualityLevels()[j].bitrate) {
label = Math.floor(player.qualityLevels()[j].bitrate / 1e3) + ' kbps';
if (this.player().qualityLevels()[j].height) {
label = this.player().qualityLevels()[j].height;
} else if (this.player().qualityLevels()[j].bitrate) {
label = Math.floor(this.player().qualityLevels()[j].bitrate / 1e3) + ' kbps';
}

@@ -249,10 +249,10 @@

index: j,
selected: j === (player.qualityLevels.selectedIndex ? label : false)
selected: j === (this.player().qualityLevels().selectedIndex ? label : false)
}));
}
//If there are more than one quality levels, offer an 'auto' option
if (player.qualityLevels().length > 1) {
if (this.player().qualityLevels().length > 1) {
menuItems.push(new SourceMenuItem(this.player_, {
label: 'Auto',
index: player.qualityLevels().length,
index: this.player().qualityLevels().length,
selected: false

@@ -292,3 +292,2 @@ }));

var qualityLevels = player.qualityLevels();
console.log("player.techName_:" + player.techName_);

@@ -306,2 +305,3 @@ //This plugin only supports level selection for HLS playback

player.on(['loadedmetadata'], function (e) {
var qualityLevels = player.qualityLevels();
videojs$1.log('loadmeadata event');

@@ -311,9 +311,7 @@ // hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.

console.log("player.videojs_http_source_selector_initialized == true");
return;
} else {
console.log("player.videojs_http_source_selector_initialized == false");
player.videojs_http_source_selector_initialized = true;
player.getChild('controlBar').addChild('SourceMenuButton', {});
}
player.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -339,2 +337,3 @@ };

onPlayerReady(_this, videojs$1.mergeOptions(defaults, options));
//this.getChild('controlBar').addChild('SourceMenuButton', {});
});

@@ -341,0 +340,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc