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.
3 lines
7.3 KiB
JavaScript
3 lines
7.3 KiB
JavaScript
/*! @name videojs-trimming-controls @version 0.0.0 @license MIT */
|
|
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],i):t.videojsTrimmingControls=i(t.videojs)}(this,function(t){"use strict";function i(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,t.__proto__=i}var e=(t=t&&t.hasOwnProperty("default")?t.default:t).getPlugin("plugin"),n={startTrim:60,endTrim:120,limitPlayback:!1},r=function(e){function r(i,r){var o;return(o=e.call(this,i)||this).options=t.mergeOptions(n,r),o.createTrimmingControls(),i.ready(function(){setTimeout(function(){o.updateTrimTimes(o.options.startTrim,o.options.endTrim)},100),i.on("timeupdate",function(){o.options.limitPlayback&&o.player.currentTime()>=o.options.endTrim&&(o.player.currentTime(o.options.endTrim),o.player.pause())}),i.on("playing",function(){t.log("playback began!"),o.updateTrimTimes(o.options.startTrim,o.options.endTrim)})}),o}i(r,e);var o=r.prototype;return o.createTrimmingControls=function(){var e=this.player,n=t.getComponent("Component"),r=function(n){function r(){return n.call(this,e,{title:e.localize("Trimming Controls")})||this}return i(r,n),r.prototype.createEl=function(){return t.dom.createEl("div",{className:"vjs-control-bar vjs-trimming-controls",dir:"ltr"})},r}(n),o=t.getComponent("Spacer"),s=t.getComponent("Button"),a=function(t){function n(i,n,r){var o;return(o=t.call(this,e,{})||this).trimmingControls=i,o.targetPosition=n,o.controlText(r),o.el().getElementsByClassName("vjs-icon-placeholder")[0].classList+=" material-icons",o}return i(n,t),n.prototype.handleClick=function(){0==this.targetPosition?this.player().currentTime(this.trimmingControls.options.startTrim):1==this.targetPosition&&this.player().currentTime(this.trimmingControls.options.endTrim)},n}(s),l=function(t){function n(i,n,r){var o;return(o=t.call(this,e,{})||this).trimmingControls=i,o.targetPosition=n,o.controlText(r),o.el().getElementsByClassName("vjs-icon-placeholder")[0].classList+=" material-icons",o}return i(n,t),n.prototype.handleClick=function(){0==this.targetPosition?this.trimmingControls.updateTrimTimes(this.player().currentTime(),this.trimmingControls.options.endTrim):1==this.targetPosition&&this.trimmingControls.updateTrimTimes(this.trimmingControls.options.startTrim,this.player().currentTime())},n}(s),m=function(n){function r(t){var i;return(i=n.call(this,e,{})||this).updateTimeContent(t),i}i(r,n);var o=r.prototype;return o.createEl=function(){return t.dom.createEl("input",{className:"vjs-time-display"})},o.updateTimeContent=function(i){t.dom.emptyEl(this.el()),this.el().value=t.formatTime(i,600.01)},r}(n),d=function(t){function n(i,n,r){var o;return(o=t.call(this,e,{})||this).trimmingControls=i,o.targetPosition=n,o.controlText(r),o.el().getElementsByClassName("vjs-icon-placeholder")[0].classList+=" material-icons",o}return i(n,t),n.prototype.handleClick=function(){0==this.targetPosition?this.player().currentTime(this.player().currentTime()-.1):1==this.targetPosition&&this.player().currentTime(this.player().currentTime()+.1)},n}(s),c=t.getComponent("PlayToggle"),p=function(t){function n(i,n){var r;return(r=t.call(this,e,{})||this).trimmingControls=i,r.controlText(n),r.el().getElementsByClassName("vjs-icon-placeholder")[0].classList+=" material-icons",r}return i(n,t),n.prototype.handleClick=function(){this.trimmingControls.options.limitPlayback=!this.trimmingControls.options.limitPlayback,this.toggleClass("playbackLimited")},n}(s);this._trimSeekControlBar=new r;var h=e.addChild(this._trimSeekControlBar,{componentClass:"trimControlBar"},e.children().length);h.addClass("vljs-trim-seek"),h.el().innerHTML='<div id="trimBarPlaceholderContainer"><div id="trimBarPlaceholder"></div></div>',this._trimControlBar=new r,e.addChild(this._trimControlBar,{componentClass:"trimControlBar"},e.children().length).addClass("vljs-trim-buttons"),this._spacer=new o;this._trimControlBar.addChild(this._spacer,{componentClass:"spacer"},0);this._startGoToButton=new a(this,0,"Go to start of trim segment");var u=this._trimControlBar.addChild(this._startGoToButton,{componentClass:"goToButton"},5);u.addClass("vljs-trimming-button"),u.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="skip_previous",this._startTrimTimeDisplay=new m(this.options.startTrim);var T=this._trimControlBar.addChild(this._startTrimTimeDisplay,{componentClass:"trimTimeDisplay"},10);T.on("change",function(){this.player_.trimmingControls().setTimestamps(T.el().value,0)}),this._startTrimButton=new l(this,0,"Set trim start at playhead");var C=this._trimControlBar.addChild(this._startTrimButton,{componentClass:"trimButton"},20);C.addClass("vljs-trimming-button"),C.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="edit",this._frameBackButton=new d(this,0,"Move back 1 frame");var g=this._trimControlBar.addChild(this._frameBackButton,{componentClass:"frameButton"},22);g.addClass("vljs-trimming-button"),g.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="fast_rewind",this._playPauseButton=new c(this.player);this._trimControlBar.addChild(this._playPauseButton,{componentClass:"playPauseButton"},25);this._frameForwardButton=new d(this,1,"Move forward 1 frame");var y=this._trimControlBar.addChild(this._frameForwardButton,{componentClass:"frameButton"},27);y.addClass("vljs-trimming-button"),y.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="fast_forward",this._endTrimButton=new l(this,1,"Set trim end at playhead");var f=this._trimControlBar.addChild(this._endTrimButton,{componentClass:"trimButton"},30);f.addClass("vljs-trimming-button"),f.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="edit",this._endTrimTimeDisplay=new m(this.options.endTrim);var v=this._trimControlBar.addChild(this._endTrimTimeDisplay,{componentClass:"trimTimeDisplay"},40);v.on("change",function(){this.player_.trimmingControls().setTimestamps(v.el().value,1)}),this._endGoToButton=new a(this,1,"Go to end of trim segment");var B=this._trimControlBar.addChild(this._endGoToButton,{componentClass:"goToButton"},50);B.addClass("vljs-trimming-button"),B.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="skip_next",this._playbackEndToggle=new p(this,"End playback at trim endpoint");var _=this._trimControlBar.addChild(this._playbackEndToggle,{componentClass:"playbackEndToggle"},60);_.addClass("vljs-trimming-button"),_.el().getElementsByClassName("vjs-icon-placeholder")[0].innerText="stop"},o.updateTrimTimes=function(t,i){this.options.startTrim=t,this.options.endTrim=i,this._startTrimTimeDisplay.updateTimeContent(t),this._endTrimTimeDisplay.updateTimeContent(i),document.getElementById("trimBarPlaceholder").style.marginLeft=t/this.player.duration()*100+"%",document.getElementById("trimBarPlaceholder").style.marginRight=100-i/this.player.duration()*100+"%"},o.setTimestamps=function(t,i){/^\d*:?\d*:?\d*\.?\d*$/.test(t)?0===i?this.updateTrimTimes(this.getSeconds(t),this.options.endTrim):1===i&&this.updateTrimTimes(this.options.startTrim,this.getSeconds(t)):(this._startTrimTimeDisplay.updateTimeContent(startValue),this._endTrimTimeDisplay.updateTimeContent(endValue))},o.getSeconds=function(t){for(var i=t.split(":"),e=0,n=1;i.length>0;)e+=n*i.pop(),n*=60;return e},r}(e);return r.defaultState={},r.VERSION="0.0.0",t.registerPlugin("trimmingControls",r),r});
|