VideoJS: Upgrade and stuff

* Upgrade to the latest stable version 6.2.8
* Move JS files to blender-cloud
* Introducing Hotkeys support (a'la YouTube)
* Introducing Loop button (and a way to easily add new buttons)
* Fix Analytics plugin to work with the VideoJS 6
* Minor style tweaks to work with the latest update
This commit is contained in:
Pablo Vazquez 2017-10-24 12:38:11 +02:00
parent 4f3fc91c0a
commit ed55a73d04
5 changed files with 14 additions and 34 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1 @@
/*
* videojs-ga - v0.4.2 - 2015-02-06
* Copyright (c) 2015 Michael Bensoussan
* Licensed MIT
*/
(function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};videojs.plugin("ga",function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;return null==b&&(b={}),c={},this.options()["data-setup"]&&(l=JSON.parse(this.options()["data-setup"]),l.ga&&(c=l.ga)),d=["loaded","percentsPlayed","start","end","seek","play","pause","resize","volumeChange","error","fullscreen"],i=b.eventsToTrack||c.eventsToTrack||d,o=b.percentsPlayedInterval||c.percentsPlayedInterval||10,g=b.eventCategory||c.eventCategory||"Video",h=b.eventLabel||c.eventLabel,b.debug=b.debug||!1,n=[],s=r=0,t=!1,k=function(){h||(h=this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")),a.call(i,"loadedmetadata")>=0&&u("loadedmetadata",!0)},v=function(){var b,c,d,e,f;for(b=Math.round(this.currentTime()),c=Math.round(this.duration()),e=Math.round(b/c*100),d=f=0;99>=f;d=f+=o)e>=d&&a.call(n,d)<0&&(a.call(i,"start")>=0&&0===d&&e>0?u("start",!0):a.call(i,"percentsPlayed")>=0&&0!==e&&u("percent played",!0,d),e>0&&n.push(d));a.call(i,"seek")>=0&&(s=r,r=b,Math.abs(s-r)>1&&(t=!0,u("seek start",!1,s),u("seek end",!1,r)))},e=function(){u("end",!0)},p=function(){var a;a=Math.round(this.currentTime()),u("play",!0,a),t=!1},m=function(){var a,b;a=Math.round(this.currentTime()),b=Math.round(this.duration()),a===b||t||u("pause",!1,a)},w=function(){var a;a=this.muted()===!0?0:this.volume(),u("volume change",!1,a)},q=function(){u("resize - "+this.width()+"*"+this.height(),!0)},f=function(){var a;a=Math.round(this.currentTime()),u("error",!0,a)},j=function(){var a;a=Math.round(this.currentTime()),("function"==typeof this.isFullscreen?this.isFullscreen():void 0)||("function"==typeof this.isFullScreen?this.isFullScreen():void 0)?u("enter fullscreen",!1,a):u("exit fullscreen",!1,a)},u=function(a,c,d){window.ga?ga("send","event",{eventCategory:g,eventAction:a,eventLabel:h,eventValue:d,nonInteraction:c}):window._gaq?_gaq.push(["_trackEvent",g,a,h,d,c]):b.debug&&console.log("Google Analytics not detected")},this.ready(function(){return this.on("loadedmetadata",k),this.on("timeupdate",v),a.call(i,"end")>=0&&this.on("ended",e),a.call(i,"play")>=0&&this.on("play",p),a.call(i,"pause")>=0&&this.on("pause",m),a.call(i,"volumeChange")>=0&&this.on("volumechange",w),a.call(i,"resize")>=0&&this.on("resize",q),a.call(i,"error")>=0&&this.on("error",f),a.call(i,"fullscreen")>=0?this.on("fullscreenchange",j):void 0}),{sendbeacon:u}})}).call(this);
(function(){var e=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};videojs.registerPlugin("ga",function(t){var n,a,r,i,s,l,o,u,c,d,h,v,f,p,g,y,m,M,T,b,k;return null==t&&(t={}),n={},this.options()["data-setup"]&&(d=JSON.parse(this.options()["data-setup"])).ga&&(n=d.ga),a=["loaded","percentsPlayed","start","end","seek","play","pause","resize","volumeChange","error","fullscreen"],o=t.eventsToTrack||n.eventsToTrack||a,f=t.percentsPlayedInterval||n.percentsPlayedInterval||10,s=t.eventCategory||n.eventCategory||"Video",l=t.eventLabel||n.eventLabel,t.debug=t.debug||!1,v=[],m=y=0,M=!1,c=function(){l||(l=this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")),e.call(o,"loadedmetadata")>=0&&T("loadedmetadata",!0)},b=function(){var t,n,a,r,i;for(t=Math.round(this.currentTime()),n=Math.round(this.duration()),r=Math.round(t/n*100),a=i=0;i<=99;a=i+=f)r>=a&&e.call(v,a)<0&&(e.call(o,"start")>=0&&0===a&&r>0?T("start",!0):e.call(o,"percentsPlayed")>=0&&0!==r&&T("percent played",!0,a),r>0&&v.push(a));e.call(o,"seek")>=0&&(m=y,y=t,Math.abs(m-y)>1&&(M=!0,T("seek start",!1,m),T("seek end",!1,y)))},r=function(){T("end",!0)},p=function(){var e;e=Math.round(this.currentTime()),T("play",!0,e),M=!1},h=function(){var e;(e=Math.round(this.currentTime()))===Math.round(this.duration())||M||T("pause",!1,e)},k=function(){var e;e=!0===this.muted()?0:this.volume(),T("volume change",!1,e)},g=function(){T("resize - "+this.width()+"*"+this.height(),!0)},i=function(){var e;e=Math.round(this.currentTime()),T("error",!0,e)},u=function(){var e;e=Math.round(this.currentTime()),("function"==typeof this.isFullscreen?this.isFullscreen():void 0)||("function"==typeof this.isFullScreen?this.isFullScreen():void 0)?T("enter fullscreen",!1,e):T("exit fullscreen",!1,e)},T=function(e,n,a){window.ga?ga("send","event",{eventCategory:s,eventAction:e,eventLabel:l,eventValue:a,nonInteraction:n}):window._gaq?_gaq.push(["_trackEvent",s,e,l,a,n]):t.debug&&console.log("Google Analytics not detected")},this.ready(function(){if(this.on("loadedmetadata",c),this.on("timeupdate",b),e.call(o,"end")>=0&&this.on("ended",r),e.call(o,"play")>=0&&this.on("play",p),e.call(o,"pause")>=0&&this.on("pause",h),e.call(o,"volumeChange")>=0&&this.on("volumechange",k),e.call(o,"resize")>=0&&this.on("resize",g),e.call(o,"error")>=0&&this.on("error",i),e.call(o,"fullscreen")>=0)return this.on("fullscreenchange",u)}),{sendbeacon:T}})}).call(this);

View File

@ -0,0 +1,2 @@
/* videojs-hotkeys v0.2.20 - https://github.com/ctd1500/videojs-hotkeys */
!function(e,t){"function"==typeof define&&define.amd?define("videojs-hotkeys",["video.js"],function(e){return t(e.default||e)}):"undefined"!=typeof module&&module.exports?module.exports=t(require("video.js")):t(videojs)}(0,function(e){"use strict";"undefined"!=typeof window&&(window.videojs_hotkeys={version:"0.2.20"});(e.registerPlugin||e.plugin)("hotkeys",function(t){var r=this,n=r.el(),o=document,u={volumeStep:.1,seekStep:5,enableMute:!0,enableVolumeScroll:!0,enableFullscreen:!0,enableNumbers:!0,enableJogStyle:!1,alwaysCaptureHotkeys:!1,enableModifiersForNumbers:!0,enableInactiveFocus:!0,skipInitialFocus:!1,playPauseKey:function(e){return 32===e.which||179===e.which},rewindKey:function(e){return 37===e.which||177===e.which},forwardKey:function(e){return 39===e.which||176===e.which},volumeUpKey:function(e){return 38===e.which},volumeDownKey:function(e){return 40===e.which},muteKey:function(e){return 77===e.which},fullscreenKey:function(e){return 70===e.which},customKeys:{}},l=e.mergeOptions||e.util.mergeOptions,i=(t=l(u,t||{})).volumeStep,a=t.seekStep,c=t.enableMute,s=t.enableVolumeScroll,m=t.enableFullscreen,y=t.enableNumbers,f=t.enableJogStyle,v=t.alwaysCaptureHotkeys,d=t.enableModifiersForNumbers,p=t.enableInactiveFocus,b=t.skipInitialFocus;n.hasAttribute("tabIndex")||n.setAttribute("tabIndex","-1"),n.style.outline="none",!v&&r.autoplay()||b||r.one("play",function(){n.focus()}),p&&r.on("userinactive",function(){var e=function(){clearTimeout(t)},t=setTimeout(function(){r.off("useractive",e),o.activeElement.parentElement==n.querySelector(".vjs-control-bar")&&n.focus()},10);r.one("useractive",e)}),r.on("play",function(){var e=n.querySelector(".iframeblocker");e&&""===e.style.display&&(e.style.display="block",e.style.bottom="39px")});var h=function(e){if(r.controls()){var t=e.relatedTarget||e.toElement||o.activeElement;if((v||t==n||t==n.querySelector(".vjs-tech")||t==n.querySelector(".iframeblocker")||t==n.querySelector(".vjs-control-bar"))&&s){e=window.event||e;var u=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail));e.preventDefault(),1==u?r.volume(r.volume()+i):-1==u&&r.volume(r.volume()-i)}}},w=function(e,r){return t.playPauseKey(e,r)?1:t.rewindKey(e,r)?2:t.forwardKey(e,r)?3:t.volumeUpKey(e,r)?4:t.volumeDownKey(e,r)?5:t.muteKey(e,r)?6:t.fullscreenKey(e,r)?7:void 0};return r.on("keydown",function(e){var u,l,s=e.which,p=e.preventDefault,b=r.duration();if(r.controls()){var h=o.activeElement;if(v||h==n||h==n.querySelector(".vjs-tech")||h==n.querySelector(".vjs-control-bar")||h==n.querySelector(".iframeblocker"))switch(w(e,r)){case 1:p(),v&&e.stopPropagation(),r.paused()?r.play():r.pause();break;case 2:u=!r.paused(),p(),u&&r.pause(),l=r.currentTime()-a,r.currentTime()<=a&&(l=0),r.currentTime(l),u&&r.play();break;case 3:u=!r.paused(),p(),u&&r.pause(),(l=r.currentTime()+a)>=b&&(l=u?b-.001:b),r.currentTime(l),u&&r.play();break;case 5:p(),f?(l=r.currentTime()-1,r.currentTime()<=1&&(l=0),r.currentTime(l)):r.volume(r.volume()-i);break;case 4:p(),f?((l=r.currentTime()+1)>=b&&(l=b),r.currentTime(l)):r.volume(r.volume()+i);break;case 6:c&&r.muted(!r.muted());break;case 7:m&&(r.isFullscreen()?r.exitFullscreen():r.requestFullscreen());break;default:if((s>47&&s<59||s>95&&s<106)&&(d||!(e.metaKey||e.ctrlKey||e.altKey))&&y){var k=48;s>95&&(k=96);var K=s-k;p(),r.currentTime(r.duration()*K*.1)}for(var S in t.customKeys){var T=t.customKeys[S];T&&T.key&&T.handler&&T.key(e)&&(p(),T.handler(r,t,e))}}}}),r.on("dblclick",function(e){if(r.controls()){var t=e.relatedTarget||e.toElement||o.activeElement;t!=n&&t!=n.querySelector(".vjs-tech")&&t!=n.querySelector(".iframeblocker")||m&&(r.isFullscreen()?r.exitFullscreen():r.requestFullscreen())}}),r.on("mousewheel",h),r.on("DOMMouseScroll",h),this})});

View File

@ -71,9 +71,9 @@ link(href="{{ url_for('static_pillar', filename='assets/jstree/themes/default/st
link(rel="amphtml", href="{{ url_for('nodes.view', node_id=node._id, _external=True, format='amp') }}")
| {% endif %}
script(src="{{ url_for('static', filename='assets/js/vendor/videojs-6.2.8.min.js', v=17320171) }}")
script(src="{{ url_for('static', filename='assets/js/vendor/videojs-ga-0.4.2.min.js', v=17320171) }}")
script(src="{{ url_for('static', filename='assets/js/vendor/videojs-hotkeys-0.2.20.min.js', v=17320171) }}")
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/videojs-6.2.8.min.js', v=17320171) }}")
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/videojs-ga-0.4.2.min.js', v=17320171) }}")
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/videojs-hotkeys-0.2.20.min.js', v=17320171) }}")
| {% endblock %}
| {% block css %}