forgeplus/public/javascripts/media/clappr-playback-rate-plugin...

2 lines
8.6 KiB
JavaScript
Raw Normal View History

2020-03-09 00:40:16 +08:00
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("clappr")):"function"==typeof define&&define.amd?define("clappr-playback-rate-plugin",["clappr"],e):"object"==typeof exports?exports["clappr-playback-rate-plugin"]=e(require("clappr")):t["clappr-playback-rate-plugin"]=e(t.clappr)}("undefined"!=typeof self?self:this,function(t){return function(t){function e(n){if(a[n])return a[n].exports;var o=a[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var a={};return e.m=t,e.c=a,e.d=function(t,a,n){e.o(t,a)||Object.defineProperty(t,a,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,"a",a),a},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,a){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(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}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var i=a(1),l=(a.n(i),a(2)),c=a.n(l),s=a(3),u=a.n(s),p=function(){function t(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,a,n){return a&&t(e.prototype,a),n&&t(e,n),e}}(),d=[{value:"0.5",label:"0.5x"},{value:"0.75",label:"0.75x"},{value:"1.0",label:"Normal"},{value:"1.5",label:"1.5x"},{value:"2.0",label:"2x"}],f=function(t){function e(){return n(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return r(e,t),p(e,[{key:"bindEvents",value:function(){this.listenTo(this.core.mediaControl,i.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.reload),this.listenTo(this.core.mediaControl,i.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,i.Events.MEDIACONTROL_HIDE,this.hideContextMenu),this.listenTo(this.core.mediaControl,e.MEDIACONTROL_PLAYBACKRATE,this.updatePlaybackRate)}},{key:"unBindEvents",value:function(){this.stopListening(this.core.mediaControl,i.Events.MEDIACONTROL_CONTAINERCHANGED),this.stopListening(this.core.mediaControl,i.Events.MEDIACONTROL_RENDERED),this.stopListening(this.core.mediaControl,i.Events.MEDIACONTROL_HIDE)}},{key:"reload",value:function(){this.unBindEvents(),this.bindEvents()}},{key:"shouldRender",value:function(){if(!this.core.activeContainer)return!1;var t=this.core.activePlayback;return"video"==t.tagName||"audio"==t.tagName}},{key:"render",value:function(){var t=this.core.options.playbackRateConfig||{};if(this.playbackRates||(this.playbackRates=t.options||d),this.selectedRate||(this.selectedRate=t.defaultValue||"1.0"),this.shouldRender()){var e=Object(i.template)(c.a),a=e({playbackRates:this.playbackRates,title:this.getTitle()});this.$el.html(a);var n=i.Styler.getStyleFor(u.a,{baseUrl:this.core.options.baseUrl});this.$el.append(n),this.core.mediaControl.$(".media-control-right-panel").append(this.el),this.updateText()}return this}},{key:"onRateSelect",value:function(t){var e=t.target.dataset.playbackRateSelect;return this.setSelectedRate(e),this.toggleContextMenu(),t.stopPropagation(),!1}},{key:"onShowMenu",value:function(t){this.toggleContextMenu()}},{key:"toggleContextMenu",value:function(){this.$(".playback_rate ul").toggle()}},{key:"hideContextMenu",value:function(){this.$(".playback_rate ul").hide()}},{key:"updatePlaybackRate",value:function(t){this.setSelectedRate(t)}},{key:"setSelectedRate",value:function(t){this.core.$el.find("video,audio").get(0).playbackRate=t,this.selectedRate=t,this.updateText()}},{key:"setActiveListItem",value:function(t){this.$("a")