mirror of https://github.com/ekimekim/wubloader
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7 lines
4.5 KiB
JavaScript
7 lines
4.5 KiB
JavaScript
/**
|
|
* videojs-hls-quality-selector
|
|
* @version 0.0.8
|
|
* @copyright 2018 Chris Boustead (chris@forgemotion.com)
|
|
* @license MIT
|
|
*/
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],e):t.videojsHlsQualitySelector=e(t.videojs)}(this,function(i){"use strict";i=i&&i.hasOwnProperty("default")?i.default:i;var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=(function(){function s(t){this.value=t}function t(i){var r,u;function l(t,e){try{var n=i[t](e),o=n.value;o instanceof s?Promise.resolve(o.value).then(function(t){l("next",t)},function(t){l("throw",t)}):a(n.done?"return":"normal",n.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?l(r.key,r.arg):u=null}this._invoke=function(o,i){return new Promise(function(t,e){var n={key:o,arg:i,resolve:t,reject:e,next:null};u?u=u.next=n:(r=u=n,l(o,i))})},"function"!=typeof i.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(t){return this._invoke("next",t)},t.prototype.throw=function(t){return this._invoke("throw",t)},t.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),s=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},c=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},r={},t=i.registerPlugin||i.plugin,l=function(){function n(t,e){a(this,n),this.player=t,this.player.qualityLevels&&this.getHls()&&(this.createQualityButton(),this.bindPlayerEvents())}return n.prototype.getHls=function(){return this.player.tech({IWillNotUseThisInPlugins:!0}).hls},n.prototype.bindPlayerEvents=function(){this.player.qualityLevels().on("addqualitylevel",this.onAddQualityLevel.bind(this))},n.prototype.createQualityButton=function(){var n=this.player,t=function(t){function e(){return a(this,e),c(this,t.call(this,n,{title:n.localize("Quality")}))}return s(e,t),e.prototype.createItems=function(){return[]},e}(i.getComponent("MenuButton"));this._qualityButton=new t;var e=n.controlBar.children().length-2,o=n.controlBar.addChild(this._qualityButton,{componentClass:"qualitySelector"},e);o.addClass("vjs-quality-selector"),o.menuButton_.$(".vjs-icon-placeholder").className+=" vjs-icon-hd",o.removeClass("vjs-hidden")},n.prototype.getQualityMenuItem=function(l){var t=this.player;return new(function(r){function u(t,e,n,o){a(this,u);var i=c(this,r.call(this,t,{label:l.label,selectable:!0,selected:l.selected||!1}));return i.item=e,i.qualityButton=n,i.plugin=o,i}return s(u,r),u.prototype.handleClick=function(){for(var t=0;t<this.qualityButton.items.length;++t)this.qualityButton.items[t].selected(!1);this.plugin.setQuality(this.item.value),this.selected(!0)},u}(i.getComponent("MenuItem")))(t,l,this._qualityButton,this)},n.prototype.onAddQualityLevel=function(){for(var n=this,t=this.player,o=t.qualityLevels().levels_||[],i=[],e=function(e){if(!i.filter(function(t){return t.item&&t.item.value===o[e].height}).length){var t=n.getQualityMenuItem.call(n,{label:o[e].height+"p",value:o[e].height});i.push(t)}},r=0;r<o.length;++r)e(r);i.sort(function(t,e){return"object"!==(void 0===t?"undefined":u(t))||"object"!==(void 0===e?"undefined":u(e))?-1:t.item.value<e.item.value?-1:t.item.value>e.item.value?1:0}),i.push(this.getQualityMenuItem.call(this,{label:t.localize("Auto"),value:"auto",selected:!0})),this._qualityButton&&(this._qualityButton.createItems=function(){return i},this._qualityButton.update())},n.prototype.setQuality=function(t){for(var e=this.player.qualityLevels(),n=0;n<e.length;++n){var o=e[n];o.enabled=o.height===t||"auto"===t}this._qualityButton.unpressButton()},n}(),e=function(n){var o=this;this.ready(function(){var t,e;t=o,e=i.mergeOptions(r,n),t.addClass("vjs-hls-quality-selector"),t.hlsQualitySelector=new l(t,e)})};return t("hlsQualitySelector",e),e.VERSION="0.0.8",e}); |