diff --git a/.gitignore b/.gitignore index 3c3629e..efa2d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,15 @@ +# dependencies node_modules + +# production +dist + +# misc +.DS_Store + +npm-debug.log +yarn-error.log +yarn.lock +.yarnclean +.vscode +temp \ No newline at end of file diff --git a/README.md b/README.md index b00a3d3..9762030 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,7 @@ videojs.addLanguage(language, { ## TODO -- Review setting menu -- Update setting menu related docs -- Limit Hls quality options +- Allow user easier to handle the click action if `SettingSubMenuitem`
diff --git a/dist/audio-track/videojs-plus.audio-track.min.js b/dist/audio-track/videojs-plus.audio-track.min.js index ddaf3b3..42bc6e0 100644 --- a/dist/audio-track/videojs-plus.audio-track.min.js +++ b/dist/audio-track/videojs-plus.audio-track.min.js @@ -1 +1 @@ -!function(e){"use strict";function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var i=e.getComponent("SettingMenuItem"),o=function(e){function i(t,i){var o;o=e.call(this,t,Object.assign(i,{name:"AudioSettingItem",label:"Audio",icon:"vjs-icon-audiotrack",entries:i.quality||[]}))||this,o.addClass("vjs-setting-audio");var r,a=function(e){"hls-audio-change"===e.name?(clearTimeout(r),r=setTimeout(o.handleAudioChangeEvent.bind(n(n(o))),10)):"hls-alternate-audio"===e.name&&o.onAlternateAudio()};return t.tech().on("usage",a),t.on("dispose",function(){t.tech().off("usage",a)}),t.on("loadstart",function(){o.hide()}),o}t(i,e);var o=i.prototype;return o.update=function(t){e.prototype.update.call(this,t),this.player_.audio().pick(t.value.index)},o.onAlternateAudio=function(){var e=this.player_.audio().values(),t=e.map(function(e,t){return{id:e.id,kind:e.kind,label:e.label,language:e.language,index:t}});this.player_.trigger("before-audio-setup",t),this.setEntries(t),this.show(),this.player_.trigger("audio",t)},o.handleAudioChangeEvent=function(){var e=this,t=this.player_.audio().values(),n=t.reduce(function(t,n,i){return n.enabled&&(t=e.entries[i]),t},{});this.player_.trigger("audiochange",n)},i}(i);e.getComponent("SettingMenuButton").prototype.options_.entries.push("AudioSettingItem"),e.registerComponent("AudioSettingItem",o);var r=function(e){function n(t,n){var i;return void 0===n&&(n={}),i=e.call(this,t,n)||this,i.current=i.values().find(function(e){return e.enabled}),t.on("audiochange",function(e,t){var n=t.index;i.current=i.values()[n]}),i}t(n,e);var i=n.prototype;return i.values=function(){for(var e=this.player.audioTracks(),t=[],n=0;n\n \n \n \n \n \n '});return this.path=e.querySelector("path"),e},i.handleClick=function(){this.player_.getChild("BeforePlayNextLayer").timeup()},n}(o);a.prototype.controlText_="PlayNext",t.registerComponent("PlayNextSpinner",a);var l=t.getComponent("Component"),s=function(i){function o(t,e){var o;o=i.call(this,t,e)||this,o.addChild("PlayNextSpinner",{},2),o.addChild("CancelPlayNextEl",{text:"✕",className:"vjs-cancel-playnext-cross"},{},2),o.addChild("CancelPlayNextEl",{text:"Cancel",className:"vjs-cancel-playnext-button"},{},2),o.originPoster=t.poster()||t.playlist.current().poster,t.poster(o.getNext().poster);var a=o.dispose.bind(n(n(o))),l=["timeupdate","loadstart"];return t.one(l,a),o.on("dispose",function(){t.off(l,a),t.removeClass("vjs-play-next-ready")}),o.countdown(t.options_.playNextCountDown),t.addClass("vjs-play-next-ready"),o}e(o,i);var a=o.prototype;return a.getNext=function(){var t=this.player_.playlist;return this.next=t.values[t.calc(1)],this.next},a.createEl=function(){var e=this.getNext().title,n=t.dom.createEl("div",{className:"vjs-before-playnext"});return this.contentEl_=t.dom.createEl("div",{className:"vjs-before-playnext-content",innerHTML:'\n
'+this.localize("Up Next")+'
\n
\n
'+e+"
\n
\n "}),n.appendChild(this.contentEl_),n},a.countdown=function(t){if(void 0===t&&(t=10),0==t)return this.timeup(),!1;var e=this,n=0,i=Math.PI,o=t;o=o/360*1e3,function t(){n++,n%=360;var a=n*i/180,l=125*Math.sin(a),s=-125*Math.cos(a),r=n>180?1:0,p="M 0 0 v -125 A 125 125 1 "+r+" 1 "+l+" "+s+" z";e.getChild("PlayNextSpinner").path.setAttribute("d",p),0===n?e.timeup():e.timer=setTimeout(t,o)}()},a.timeup=function(){this.player_.playlist.next(),this.player_.playlist.play(),this.dispose()},a.cancel=function(){return this.player_.poster(this.originPoster),this},a.dispose=function(){clearTimeout(this.timer),this.player_.removeChild(this),i.prototype.dispose.call(this)},o}(l),r=function(){var t=this.player_,e=t.playlist,n=e.loop()||!e.ended();if(e.autoPlayNext()&&n){var i=t.getChild("ControlBar"),o=t.children().indexOf(i)-1;t.addChild("BeforePlayNextLayer",{},o)}else t.poster(e.current().poster||"")};t.registerPlugin("playNext",r),t.registerComponent("BeforePlayNextLayer",s);var p=t.getComponent("SettingMenuButton"),c=t.getComponent("SettingOnOffItem"),u=function(t){function n(e,n){var i;return i=t.call(this,e,{name:"ToggleAutoPlayNext",label:"Autoplay",icon:"vjs-icon-next-item"})||this,i.menu=n.menu,i.updateVisibility(),i.addClass("vjs-setting-autoplay"),e.on("playlist",function(){i.updateVisibility(),i.update(e.playlist.autoPlayNext_)}),i}e(n,t);var i=n.prototype;return i.updateVisibility=function(){var t=this.player_.playlist;t&&t.values.length>1?this.show():this.hide()},i.update=function(e){t.prototype.update.call(this,e),this.player_.playlist.autoPlayNext(this.active)},n}(c);t.registerComponent("ToggleAutoPlayNext",u),p.prototype.options_.entries.splice(0,0,"ToggleAutoPlayNext");var h=t.getComponent("Button"),d=function(t){function i(e,i){var o;return o=t.call(this,e,i)||this,o.updateVisibility(),o.controlText(i.controlText),e.on("playlist",o.updateVisibility.bind(n(n(o)))),o}e(i,t);var o=i.prototype;return o.buildCSSClass=function(){return this.options_.className+" "+t.prototype.buildCSSClass.call(this)},o.updateVisibility=function(){var t=this.player_.playlist;t&&t.values.length>1?this.show():this.hide()},o.createEl=function(e,n,i){return t.prototype.createEl.call(this,e,{innerHTML:''},i)},o.handleClick=function(){var t=this.options_.controlText.toLowerCase();this.player_.playlist[t](),this.player_.playlist.play()},i}(h),y=t.getComponent("ControlBar"),v=y.prototype.options_.children,x=v.indexOf("PlayToggle");-1!==x&&(v.splice(0,0,{name:"PrevNextButton",className:"vjs-prev-control",icon:"vjs-icon-previous-item",controlText:"Prev"}),v.splice(x+2,0,{name:"PrevNextButton",className:"vjs-next-control",icon:"vjs-icon-next-item",controlText:"Next"})),t.registerComponent("PrevNextButton",d);var f=t.getComponent("ClickableComponent"),g=function(t){function n(e,n){var i;return i=t.call(this,e,n)||this,i.el_.querySelector(".vjs-icon-placeholder").innerHTML=i.localize(n.text),i}e(n,t);var i=n.prototype;return i.buildCSSClass=function(){return"vjs-cancel-playnext "+this.options_.className},i.handleClick=function(){this.player_.getChild("BeforePlayNextLayer").cancel().dispose()},n}(f);g.prototype.controlText_="Cancel PlayNext",t.registerComponent("CancelPlayNextEl",g);var m=function(t){function n(e,n,i){var o;return void 0===i&&(i=0),o=t.call(this,n,i)||this,o.player=e,o.loadPoster_=!0,o.autoPlayNext_=!0,o.play(i),e.off("ended",e.playNext),e.on("ended",e.playNext),o}e(n,t);var i=n.prototype;return i.autoPlayNext=function(t){if(void 0===t)return this.autoPlayNext_;this.autoPlayNext_=!!t},i.play=function(t){void 0!==t&&this.index(t);var e=this.current(),n=e.poster,i=e.sources,o=e.title,a=this.player,l=function(){a.poster(n||"")};a.title(""),a.poster(""),this.loadPoster_?(this.loadPoster_=!1,a.autoplay()?a.one("autoplay-failure",l):l()):a.one("loadedmetadata",function(){a.play()}),"none"!==a.preload()&&(a.addClass("vjs-waiting"),a.one("loadedmetadata",function(){a.removeClass("vjs-waiting")})),a.src(i),a.title(o||""),a.trigger("playlistchange",Object.assign(this.current(),{index:this.index()}))},n}(i);t.registerPlugin("setPlayList",function(t){var e=this.player_;e.playlist=new m(e,t),e.trigger("playlist")}),t.hook("setup",function(t){var e=t.options_.playlist||[];e.length&&t.setPlayList(e)})}(videojs); +!function(t){"use strict";function e(){return e=Object.assign||function(t){for(var e=1;e\n \n \n \n \n \n '});return this.path=e.querySelector("path"),e},i.handleClick=function(){this.player_.getChild("BeforePlayNextLayer").timeup()},e}(a);l.prototype.controlText_="PlayNext",t.registerComponent("PlayNextSpinner",l);var r=t.getComponent("Component"),s=function(e){function o(t,n){var o;o=e.call(this,t,n)||this,o.addChild("PlayNextSpinner",{},2),o.addChild("CancelPlayNextEl",{text:"✕",className:"vjs-cancel-playnext-cross"},{},2),o.addChild("CancelPlayNextEl",{text:"Cancel",className:"vjs-cancel-playnext-button"},{},2),o.originPoster=t.poster()||t.playlist.current().poster,t.poster(o.getNext().poster);var a=o.dispose.bind(i(i(o))),l=["timeupdate","loadstart"];return t.one(l,a),o.on("dispose",function(){t.off(l,a),t.removeClass("vjs-play-next-ready")}),o.countdown(t.options_.playNextCountDown),t.addClass("vjs-play-next-ready"),o}n(o,e);var a=o.prototype;return a.getNext=function(){var t=this.player_.playlist;return this.next=t.values[t.calc(1)],this.next},a.createEl=function(){var e=this.getNext().title,n=t.dom.createEl("div",{className:"vjs-before-playnext"});return this.contentEl_=t.dom.createEl("div",{className:"vjs-before-playnext-content",innerHTML:'\n
'+this.localize("Up Next")+'
\n
\n
'+e+"
\n
\n "}),n.appendChild(this.contentEl_),n},a.countdown=function(t){if(void 0===t&&(t=10),0==t)return this.timeup(),!1;var e=this,n=0,i=Math.PI,o=t;o=o/360*1e3,function t(){n++,n%=360;var a=n*i/180,l=125*Math.sin(a),r=-125*Math.cos(a),s=n>180?1:0,p="M 0 0 v -125 A 125 125 1 "+s+" 1 "+l+" "+r+" z";e.getChild("PlayNextSpinner").path.setAttribute("d",p),0===n?e.timeup():e.timer=setTimeout(t,o)}()},a.timeup=function(){this.player_.playlist.next(),this.player_.playlist.play(),this.dispose()},a.cancel=function(){return this.player_.poster(this.originPoster),this},a.dispose=function(){clearTimeout(this.timer),this.player_.removeChild(this),e.prototype.dispose.call(this)},o}(r),p=function(){var t=this.player_,e=t.playlist,n=e.loop()||!e.ended();if(e.autoPlayNext()&&n){var i=t.getChild("ControlBar"),o=t.children().indexOf(i)-1;t.addChild("BeforePlayNextLayer",{},o)}else t.poster(e.current().poster||"")};t.registerPlugin("playNext",p),t.registerComponent("BeforePlayNextLayer",s);var c=t.getComponent("SettingMenuButton"),u=t.getComponent("SettingOnOffItem"),h=function(t){function e(e,n){var i;return i=t.call(this,e,{name:"ToggleAutoPlayNext",label:"Autoplay",icon:"vjs-icon-next-item"})||this,i.updateVisibility(),i.addClass("vjs-setting-autoplay"),e.on("playlist",function(){i.updateVisibility(),i.update(e.playlist.autoPlayNext_)}),e.on("autoplaynext",function(t,e){i.update(e)}),i}n(e,t);var i=e.prototype;return i.updateVisibility=function(){var t=this.player_.playlist;t&&t.values.length>1?this.show():this.hide()},i.update=function(e){t.prototype.update.call(this,e),this.player_.playlist.autoPlayNext_!==this.active&&this.player_.playlist.autoPlayNext(this.active)},e}(u);t.registerComponent("ToggleAutoPlayNext",h),c.prototype.options_.entries.splice(0,0,"ToggleAutoPlayNext");var d=t.getComponent("Button"),y=function(t){function e(e,n){var o;return o=t.call(this,e,n)||this,o.updateVisibility(),o.controlText(n.controlText),e.on("playlist",o.updateVisibility.bind(i(i(o)))),o}n(e,t);var o=e.prototype;return o.buildCSSClass=function(){return this.options_.className+" "+t.prototype.buildCSSClass.call(this)},o.updateVisibility=function(){var t=this.player_.playlist;t&&t.values.length>1?this.show():this.hide()},o.createEl=function(e,n,i){return t.prototype.createEl.call(this,e,{innerHTML:''},i)},o.handleClick=function(){var t=this.options_.controlText.toLowerCase();this.player_.playlist[t](),this.player_.playlist.play()},e}(d),v=t.getComponent("ControlBar"),x=v.prototype.options_.children,f=x.indexOf("PlayToggle");-1!==f&&(x.splice(0,0,{name:"PrevNextButton",className:"vjs-prev-control",icon:"vjs-icon-previous-item",controlText:"Prev"}),x.splice(f+2,0,{name:"PrevNextButton",className:"vjs-next-control",icon:"vjs-icon-next-item",controlText:"Next"})),t.registerComponent("PrevNextButton",y);var g=t.getComponent("ClickableComponent"),_=function(t){function e(e,n){var i;return i=t.call(this,e,n)||this,i.el_.querySelector(".vjs-icon-placeholder").innerHTML=i.localize(n.text),i}n(e,t);var i=e.prototype;return i.buildCSSClass=function(){return"vjs-cancel-playnext "+this.options_.className},i.handleClick=function(){this.player_.getChild("BeforePlayNextLayer").cancel().dispose()},e}(g);_.prototype.controlText_="Cancel PlayNext",t.registerComponent("CancelPlayNextEl",_);var C=function(t){function i(e,n,i){var o;return void 0===i&&(i=0),o=t.call(this,n,i)||this,o.player_=e,o.loadPoster_=!0,o.autoPlayNext_=!0,o.play(i),e.off("ended",e.playNext),e.on("ended",e.playNext),o}n(i,t);var o=i.prototype;return o.autoPlayNext=function(t){if(void 0===t)return this.autoPlayNext_;this.autoPlayNext_=!!t,this.player_.trigger("autoplaynext",this.autoPlayNext_)},o.play=function(t){void 0!==t&&this.index(t);var n=this.current(),i=n.poster,o=n.sources,a=n.title,l=this.player_,r=function(){l.poster(i||"")};l.title(""),l.poster(""),this.loadPoster_?(this.loadPoster_=!1,l.autoplay()?l.one("autoplay-failure",r):r()):l.one("loadedmetadata",function(){l.play()}),"none"!==l.preload()&&(l.addClass("vjs-waiting"),l.one("loadedmetadata",function(){l.removeClass("vjs-waiting")})),l.src(o),l.title(a||""),l.trigger("playlistchange",e({},n,{index:this.index()}))},i}(o);t.registerPlugin("setPlayList",function(t,e){var n=this.player_;n.playlist=new C(n,t,e),n.trigger("playlist",t)}),t.hook("setup",function(t){var e=t.options_.playlist;if(e&&e.length){var n=e.findIndex(function(t){return t.default});t.setPlayList(e,n)}})}(videojs); diff --git a/dist/quality-hls/videojs-plus.quality-hls.min.js b/dist/quality-hls/videojs-plus.quality-hls.min.js index 3af0245..8ea38ca 100644 --- a/dist/quality-hls/videojs-plus.quality-hls.min.js +++ b/dist/quality-hls/videojs-plus.quality-hls.min.js @@ -1 +1 @@ -!function(e){"use strict";function t(){return t=Object.assign||function(e){for(var t=1;t-1&&(ControlBar.prototype.options_.children=[{name:"ControlSeparator",className:"top",children:[]},{name:"ControlSeparator",className:"middle",children:n.splice(0,i+1)},{name:"ControlSeparator",className:"bottom",children:n}]),t}),video_js.hook("setup",function(e){var t=!1!==e.options_.mobileView;(function(e){return window.matchMedia?window.matchMedia("(max-width: "+e+"px)").matches:window.innerWidth<=e})(480)&&t&&(e.controlBar.hide(),e.one("playing",function(){var t=["mouseover","userinactive","touchstart"];e.one(t,function n(){e.off(t,n),e.controlBar.show()}),e.one("touchend",function(){e.userActive(!0)})}),e.addClass("vjs-mobile-view"))});var SeekBar=video_js.getComponent("SeekBar");SeekBar.prototype.getPercent=function(){var e=this.player_.currentTime(),t=e/this.player_.duration();return t>=1?1:t},SeekBar.prototype.handleMouseMove=function(e){var t=this.player_;if(video_js.dom.isSingleLeftClick(e)){var n=this.calculateDistance(e)*t.duration();n===t.duration()&&(n-=.1),t.currentTime(n),this.update()}},video_js.getComponent("ControlBar").prototype.options_.children=["PlayToggle","CustomControlSpacer","VolumePanel","CurrentTimeDisplay","TimeDivider","DurationDisplay","ProgressControl","CustomControlSpacer","SettingMenuButton","FullscreenToggle"],video_js.hook("setup",function(e){e.on("mouseleave",function(){e.userActive(!1)}),e.ready(function(){e.controls(!1!==e.options_.controls)})});var Title=function(e){function t(t,n){var i;return i=e.call(this,t,n)||this,i.title_=n.playerOptions.title||"",i.update(i.title_),i}_inheritsLoose(t,e);var n=t.prototype;return n.createEl=function(){var t=e.prototype.createEl.call(this,"div",{className:"vjs-title"});return this.contentEl_=video_js.dom.createEl("div",{className:"vjs-title-field"}),t.appendChild(this.contentEl_),t},n.update=function(e){e?this.show():this.hide(),this.player_.cache_.title=this.title_,this.title_=e,this.contentEl_.innerHTML=e},t}(video_js.getComponent("Component")),title=function(e){var t=this.player_.getChild("VideoTitle");if(void 0===e)return t.title_;t.update(e)};video_js.registerPlugin("title",title),video_js.registerComponent("VideoTitle",Title),video_js.getComponent("Player").prototype.options_.children.splice(2,0,"VideoTitle");var PlayToggleButton=video_js.getComponent("PlayToggle"),ClickableComponent=video_js.getComponent("ClickableComponent"),PlayToggleLayer=function(e){function t(t,n){return e.call(this,t,n)||this}_inheritsLoose(t,e);var n=t.prototype;return n.createEl=function(){return video_js.dom.createEl("div",{className:"vjs-play-toggle-layer"})},n.handleClick=function(e){(this.player_.userActive()||this.player_.paused())&&PlayToggleButton.prototype.handleClick.call(this,e)},t}(ClickableComponent);video_js.registerComponent("PlayToggleLayer",PlayToggleLayer);var playerChildren=video_js.getComponent("Player").prototype.options_.children,loadSpinnerIndex=playerChildren.indexOf("loadingSpinner");playerChildren.splice(loadSpinnerIndex,0,"PlayToggleLayer");var MenuItem=video_js.getComponent("MenuItem"),ContextMenuItem=function(e){function t(t,n){var i;return i=e.call(this,t,_extends({},n,{selectable:!0}))||this,i.addClass("vjs-context-menu-item"),i.controlText(n.label),i}_inheritsLoose(t,e);var n=t.prototype;return n.createEl=function(){for(var t,n=arguments.length,i=new Array(n),o=0;o