From 9b6272bf85d4611ae30971bf92c74c6c16584ab8 Mon Sep 17 00:00:00 2001 From: Florian Larysch Date: Mon, 7 Aug 2017 23:10:01 +0200 Subject: relive: make playback rate adjustable --- assets/clapprio/clappr-playback-rate-plugin.js | 108 +++++++++++++++++++++ assets/clapprio/clappr-playback-rate-plugin.min.js | 17 ++++ .../clappr-playback-rate-plugin.min.js.map | 1 + assets/js/lustiges-script.js | 2 +- 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 assets/clapprio/clappr-playback-rate-plugin.js create mode 100644 assets/clapprio/clappr-playback-rate-plugin.min.js create mode 100644 assets/clapprio/clappr-playback-rate-plugin.min.js.map (limited to 'assets') diff --git a/assets/clapprio/clappr-playback-rate-plugin.js b/assets/clapprio/clappr-playback-rate-plugin.js new file mode 100644 index 0000000..12aa80c --- /dev/null +++ b/assets/clapprio/clappr-playback-rate-plugin.js @@ -0,0 +1,108 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("Clappr")); + else if(typeof define === 'function' && define.amd) + define(["Clappr"], factory); + else if(typeof exports === 'object') + exports["PlaybackRatePlugin"] = factory(require("Clappr")); + else + root["PlaybackRatePlugin"] = factory(root["Clappr"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "<%=baseUrl%>/"; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if('value' in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();var _get=function get(_x,_x2,_x3){var _again=true;_function: while(_again) {var object=_x,property=_x2,receiver=_x3;_again = false;if(object === null)object = Function.prototype;var desc=Object.getOwnPropertyDescriptor(object,property);if(desc === undefined){var parent=Object.getPrototypeOf(object);if(parent === null){return undefined;}else {_x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function;}}else if('value' in desc){return desc.value;}else {var getter=desc.get;if(getter === undefined){return undefined;}return getter.call(receiver);}}};function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{'default':obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function');}}function _inherits(subClass,superClass){if(typeof superClass !== 'function' && superClass !== null){throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _clappr=__webpack_require__(1);var _publicPlaybackRateSelectorHtml=__webpack_require__(2);var _publicPlaybackRateSelectorHtml2=_interopRequireDefault(_publicPlaybackRateSelectorHtml);var _publicStyleScss=__webpack_require__(3);var _publicStyleScss2=_interopRequireDefault(_publicStyleScss);var DEFAULT_PLAYBACK_RATES=[{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'}];var DEFAULT_PLAYBACK_RATE='1.0';var PlaybackRatePlugin=(function(_UICorePlugin){_inherits(PlaybackRatePlugin,_UICorePlugin);function PlaybackRatePlugin(){_classCallCheck(this,PlaybackRatePlugin);_get(Object.getPrototypeOf(PlaybackRatePlugin.prototype),'constructor',this).apply(this,arguments);}_createClass(PlaybackRatePlugin,[{key:'bindEvents',value:function bindEvents(){this.listenTo(this.core.mediaControl,_clappr.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload);this.listenTo(this.core.mediaControl,_clappr.Events.MEDIACONTROL_RENDERED,this.render);this.listenTo(this.core.mediaControl,_clappr.Events.MEDIACONTROL_HIDE,this.hideContextMenu);this.listenTo(this.core.mediaControl,PlaybackRatePlugin.MEDIACONTROL_PLAYBACKRATE,this.updatePlaybackRate);}},{key:'unBindEvents',value:function unBindEvents(){this.stopListening(this.core.mediaControl,_clappr.Events.MEDIACONTROL_CONTAINERCHANGED);this.stopListening(this.core.mediaControl,_clappr.Events.MEDIACONTROL_RENDERED);this.stopListening(this.core.mediaControl,_clappr.Events.MEDIACONTROL_HIDE);}},{key:'reload',value:function reload(){this.unBindEvents();this.bindEvents();}},{key:'shouldRender',value:function shouldRender(){if(!this.core.getCurrentContainer()){return false;}var currentPlayback=this.core.getCurrentPlayback();if(currentPlayback.tagName != 'video' && currentPlayback.tagName != 'audio'){ //console.warn('PlaybackRatePlugin#shouldRender: Cannot affect rate for playback', currentPlayback); + return false;}return true;}},{key:'render',value:function render(){ //console.log('PlaybackRatePlugin#render()'); + var cfg=this.core.options.playbackRateConfig || {};if(!this.playbackRates){this.playbackRates = cfg.options || DEFAULT_PLAYBACK_RATES;}if(!this.selectedRate){this.selectedRate = cfg.defaultValue || DEFAULT_PLAYBACK_RATE;}if(this.shouldRender()){var t=(0,_clappr.template)(_publicPlaybackRateSelectorHtml2['default']);var html=t({playbackRates:this.playbackRates,title:this.getTitle()});this.$el.html(html);var style=_clappr.Styler.getStyleFor(_publicStyleScss2['default'],{baseUrl:this.core.options.baseUrl});this.$el.append(style);this.core.mediaControl.$('.media-control-right-panel').append(this.el);this.updateText();}return this;}},{key:'onRateSelect',value:function onRateSelect(event){ //console.log('onRateSelect', event.target); + var rate=event.target.dataset.playbackRateSelect;this.setSelectedRate(rate);this.toggleContextMenu();event.stopPropagation();return false;}},{key:'onShowMenu',value:function onShowMenu(event){this.toggleContextMenu();}},{key:'toggleContextMenu',value:function toggleContextMenu(){this.$('.playback_rate ul').toggle();}},{key:'hideContextMenu',value:function hideContextMenu(){this.$('.playback_rate ul').hide();}},{key:'updatePlaybackRate',value:function updatePlaybackRate(rate){this.setSelectedRate(rate);}},{key:'setSelectedRate',value:function setSelectedRate(rate){ // Set