forked from jasder/forgeplus
2 lines
8.6 KiB
JavaScript
2 lines
8.6 KiB
JavaScript
!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").removeClass("active"),this.$('a[data-playback-rate-select="'+t+'"]').addClass("active")}},{key:"buttonElement",value:function(){return this.$(".playback_rate button")}},{key:"getTitle",value:function(){var t=this,e=this.selectedRate;return this.playbackRates.forEach(function(a){a.value==t.selectedRate&&(e=a.label)}),e}},{key:"updateText",value:function(){this.buttonElement().text(this.getTitle()),this.setActiveListItem(this.selectedRate)}},{key:"name",get:function(){return"playback_rate"}},{key:"template",get:function(){return Object(i.template)(c.a)}},{key:"attributes",get:function(){return{class:this.name,"data-playback-rate-select":""}}},{key:"events",get:function(){return{"click [data-playback-rate-select]":"onRateSelect","click [data-playback-rate-button]":"onShowMenu"}}}]),e}(i.UICorePlugin);e.default=f,f.type="core",f.MEDIACONTROL_PLAYBACKRATE="playbackRate"},function(e,a){e.exports=t},function(t,e){t.exports='<button class="media-control-button media-control-icon" data-playback-rate-button>\n <%= title %>\n</button>\n<ul>\n <% for (var i = 0; i < playbackRates.length; i++) { %>\n <li><a href="#" data-playback-rate-select="<%= playbackRates[i].value %>"><%= playbackRates[i].label %></a></li>\n <% }; %>\n</ul>\n'},function(t,e,a){e=t.exports=a(4)(void 0),e.push([t.i,".media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] {\n float: right;\n margin-top: 5px;\n position: relative; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] button.media-control-button.media-control-icon {\n font-family: Roboto,\"Open Sans\",Arial,sans-serif;\n -webkit-font-smoothing: antialiased;\n font-size: 12px;\n cursor: pointer;\n padding: 10px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] button.media-control-button.media-control-icon:hover {\n color: #c9c9c9; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] button.media-control-button.media-control-icon.changing {\n -webkit-animation: pulse 0.5s infinite alternate; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] > ul {\n display: none;\n list-style-type: none;\n position: absolute;\n bottom: 25px;\n border: 1px solid black;\n border-radius: 4px;\n background-color: rgba(0, 0, 0, 0.7); }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li {\n position: relative;\n font-size: 12px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li[data-title] {\n padding: 5px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li a {\n color: #aaa;\n padding: 2px 10px 2px 15px;\n display: block;\n text-decoration: none; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li a.active {\n background-color: black;\n font-weight: bold;\n color: #fff; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li a.active:before {\n content: '\\2713';\n position: absolute;\n top: 2px;\n left: 4px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .playback_rate[data-playback-rate-select] li a:hover {\n color: #fff;\n text-decoration: none; }\n\n@-webkit-keyframes pulse {\n 0% {\n color: #fff; }\n 50% {\n color: #ff0101; }\n 100% {\n color: #B80000; } }\n",""])},function(t,e){function a(t,e){var a=t[1]||"",o=t[3];if(!o)return a;if(e&&"function"==typeof btoa){var r=n(o);return[a].concat(o.sources.map(function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"})).concat([r]).join("\n")}return[a].join("\n")}function n(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=a(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,a){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},o=0;o<this.length;o++){var r=this[o][0];"number"==typeof r&&(n[r]=!0)}for(o=0;o<t.length;o++){var i=t[o];"number"==typeof i[0]&&n[i[0]]||(a&&!i[2]?i[2]=a:a&&(i[2]="("+i[2]+") and ("+a+")"),e.push(i))}},e}}])});
|