diff --git a/dist/videojs-abloop.min.js b/dist/videojs-abloop.min.js index 2afd40b..c761afd 100644 --- a/dist/videojs-abloop.min.js +++ b/dist/videojs-abloop.min.js @@ -1 +1 @@ -!function(t,e){"function"==typeof define&&define.amd?define([],e.bind(this,t,t.videojs)):"undefined"!=typeof module&&module.exports?module.exports=e(t,t.videojs):e(t,t.videojs)}(window,function(t,e){"use strict";var n=function(n){var o=this,r=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},a=function(t){var e={};return t&&"[object Function]"===e.toString.call(t)},i=function(t){return!!t},u=function(t,e){var n={};return e.forEach(function(e){void 0!==t[e]&&(n[e]=t[e])}),n},f=function(t,n){return n=n||1,e.formatTime(t)+"."+Math.floor(t%1*Math.pow(10,n))},c=function(t,e){var n=Math.pow(10,e);return Math.floor(t*n)/n},l=function(t){if(void 0!==t){if(r(t))return t;if(/^([+\-])?([\d\.]+)$/i.test(t))return parseFloat(t);var e=/^([+\-])?((([\d]+)(h|:(?=.*:)))?(([\d]+)(m|:|$))?)?(([\d\.]+)s?)?$/i.exec(t);if(!e)return null;var n={match:e[0],sign:e[1],hours:e[4]||0,mins:e[7]||0,secs:e[10]||0},o="-"==n.sign?-1:1,a=60*parseFloat(n.hours)*60+60*parseFloat(n.mins)+parseFloat(n.secs);return r(a)?o*a:null}},p={},s={start:{default:0,validate:function(t){return!1===t?t:r(t)&&t>=0?t:0}},end:{default:!1,validate:function(t){if(!1===t)return t;if(r(t)){var e=o.duration();if(void 0===e||0===e){if(t>=0)return t}else{if(t>=0&&t<=e)return t;if(t>e)return e}}return!1}},enabled:{default:!1,validate:i},loopIfBeforeStart:{default:!0,validate:i},loopIfAfterEnd:{default:!0,validate:i},pauseBeforeLooping:{default:!1,validate:i},pauseAfterLooping:{default:!1,validate:i}},d={onLoopCallBack:{default:void 0,check:a},onOptionsChange:{default:void 0,check:a}},g=Object.keys(s),h=Object.keys(d),L=function(){n=n||{};var t=function(t){return function(e){void 0===n[e]&&(n[e]=t[e].default)}};g.forEach(t(s)),h.forEach(t(d))},v=function(){h.forEach(function(t){d[t].check(n[t])&&(J[t]=n[t])})},m=function(){return g.forEach(function(t){p[t]=s[t].validate(p[t])}),J},y=function(){return b(n,!0)},b=function(t,e){return g.forEach(function(n){(e||void 0!==t[n])&&(p[n]=t[n])}),m(),J},U=!1,E=function(t){return t?p.pauseBeforeLooping&&!1===U?(o.pause(),U=!0):(U=!1,o.currentTime(p.start),p.pauseAfterLooping&&o.pause(),d.onLoopCallBack.check(J.onLoopCallBack)&&J.onLoopCallBack(J,o)):(U=!1,o.currentTime(p.start)),J},A=function(t){return function(e){return!1===e?p[t]=!1:(void 0!==e&&(e=l(e)),null!==e&&(e=void 0===e?o.currentTime():e,p[t]=e)),J}},B=function(t){return function(e){return e=l(e),r(e)&&(p[t]+=e),J}},O=function(){return p.enabled=!0,J},k=function(t){return function(){return p[t]=!p[t],J}},S=function(e){if(!e.match(/^https?:\/\//)&&t&&t.document){var n=t.document.createElement("div");n.innerHTML='x',e=n.firstChild.href}return e},T=function(t){(t=t||{}).decimalPlaces=Math.floor(t.decimalPlaces)||3;var e=!1!==p.start?parseFloat(p.start):0,n="#t="+c(e,t.decimalPlaces);if(!1!==p.end){var o=parseFloat(p.end);n+=","+c(o,t.decimalPlaces)}return n},F=function(t){t=t||{};var e=o.currentSrc();return e.src&&(e=e.src),e+T(t)},P=function(t){if("string"==typeof t&&(t=e.parseUrl(t)),t.hash){var n=/^(#?t=)?([^,]*)(,(.*))?$/,o=t.hash.replace(n,"$2"),a=t.hash.replace(n,"$4");o=l(o),a=l(a),r(o)&&(p.start=parseFloat(o)),r(a)&&(p.end=parseFloat(a))}return J},x=function(t){var e=t;return"string"==typeof t?e=[t]:void 0!==t&&Array.isArray(t)||(e=null!==t&&"object"==typeof t?Object.keys(t):Object.keys(s)),u(p,e)},j=function(t,e){var n=!e;return e=e||{},g.forEach(function(t){e[t]=!!e[t]||n}),function(){var n=arguments,r=x(),a=t.apply(null,n),i={changed:e,oldOpts:r,newOpts:x()};return J.onOptionsChange&&J.onOptionsChange(i,J,o),G(e),a}},C=!1,K=function(){var t,e,n;if(m(),t=o.currentTime(),e=$(),(n=w())>e){if(C=!0,te&&(t-e<1||p.loopIfAfterEnd||p.loopIfBeforeStart))return!0}else{if(C=!1,t=e&&(t-e<1||p.loopIfAfterEnd))return!0}return!1},w=function(){return!1===p.start?0:p.start},$=function(){return!1===p.end?o.duration():p.end},I=!1,M=r(n.minLoopLength)&&n.minLoopLength>0?n.minLoopLength:200,R=function(t){!I&&p.enabled&&!o.paused()&&K()&&(I=!0,setTimeout(function(){I=!1},M),E(!0))},N={},D=[{name:"start",optionsUsed:["start"],leftclick:function(t,e){e.shiftKey?t.adjustStart(-.5):t.setStart()},rightclick:function(t,e){e.shiftKey?t.adjustStart(.5):t.goToStart()},defaultText:"Start",textFunction:function(t){return f(t.start)}},{name:"end",optionsUsed:["end"],leftclick:function(t,e){e.shiftKey?t.adjustEnd(-.5):e.ctrlKey?t.adjustEnd(-.05):t.setEnd()},rightclick:function(t,e){e.shiftKey?t.adjustEnd(.5):e.ctrlKey?t.adjustEnd(.05):t.goToEnd()},defaultText:"End",textFunction:function(t){return f(t.end)}},{name:"enabled",optionsUsed:["enabled","pauseAfterLooping","pauseBeforeLooping"],leftclick:function(e,n){t&&t.prompt?n.ctrlKey?e.applyUrl(H("Set new URL",e.getAbsoluteUrl())):n.altKey?e.applyUrl(H("Set new URL",e.getUrl())):n.shiftKey?e.applyUrlFragment(H("Set new URL fragment",e.getUrlFragment())):e.toggle():e.toggle()},rightclick:function(e,n){var o;t&&t.prompt&&(n.ctrlKey?o=e.getAbsoluteUrl():n.altKey?o=e.getUrl():n.shiftKey&&(o=e.getUrlFragment())),o?q(o):e.cyclePauseOnLooping()},defaultText:"Loop",textFunction:function(t){return t.enabled?t.pauseBeforeLooping&&t.pauseAfterLooping?"PAUSE LOOP PAUSE":t.pauseAfterLooping?"LOOP& PAUSE":t.pauseBeforeLooping?"PAUSE &LOOP":"LOOP ON":"Loop off"}}],q=function(e){t&&t.prompt&&t.prompt("Copy to clipboard: Ctrl+C, Enter",e)},H=function(e,n){return!(!t||!t.prompt)&&t.prompt(e,n)},V=function(t,e){var n=function(t,n){return function(o){(void 0===n||o.which&&o.which==n)&&(t(e.abLoopPlugin,o),this.updateText())}},o=e.controlBar.addChild("Button");return t.leftclick&&o.on("click",n(t.leftclick)),t.rightclick&&(o.el().onmousedown=n(t.rightclick,3).bind(o),o.on("contextmenu",function(t){return t.preventDefault&&t.preventDefault(),t.preventDefault&&t.stopPropagation(),!1})),o.updateText=function(t,e){return function(){var n=e(p)||t;this.el().textContent=n}}(t.defaultText,t.textFunction),o.optionsUsed=t.optionsUsed,o.addClass("abLoopButton"),o.addClass(t.name),o.updateText(),o},z=function(t){t.forEach(function(t){void 0===N[t.name]&&(N[t.name]=V(t,o))})},G=function(t){for(var e in N){var n=N[e];(!n.optionsUsed||n.optionsUsed.reduce(function(e,n){return e||t[n]},!1))&&n.updateText()}},J={validateOptions:j(m),resetToInitialOptions:j(y),setOptions:j(b),getOptions:x,goToStart:E,goToEnd:function(){return U=!1,o.currentTime(p.end),J},setStart:j(A("start"),{start:!0}),setEnd:j(A("end"),{end:!0}),adjustStart:j(B("start"),{start:!0}),adjustEnd:j(B("end"),{end:!0}),enable:j(O,{enabled:!0}),disable:j(function(){return p.enabled=!1,J},{enabled:!0}),toggle:j(k("enabled"),{enabled:!0}),togglePauseAfterLooping:j(k("pauseAfterLooping"),{pauseAfterLooping:!0}),togglePauseBeforeLooping:j(k("pauseBeforeLooping"),{pauseBeforeLooping:!0}),cyclePauseOnLooping:j(function(){var t=p.pauseAfterLooping,e=p.pauseBeforeLooping;return b(t||e?t&&!e?{pauseAfterLooping:!1,pauseBeforeLooping:!0}:!t&&e?{pauseAfterLooping:!0,pauseBeforeLooping:!0}:{pauseAfterLooping:!1,pauseBeforeLooping:!1}:{pauseAfterLooping:!0,pauseBeforeLooping:!1}),J},{pauseBeforeLooping:!0,pauseAfterLooping:!0}),player:o,version:"0.4.5",getAbsoluteUrl:function(t){return S(F(t))},getUrl:F,getUrlFragment:T,applyUrl:j(function(t){var e=t.replace(/^(.*?)(#.*)?$/,"$1"),n=t.replace(/^(.*?)(#.*)?$/,"$2"),r=o.currentSrc();return r!=e&&r!=t&&t!=n&&o.src(e),n&&P(n),J},{start:!0,end:!0}),applyUrlFragment:j(P,{start:!0,end:!0}),loopRequired:K,playLoop:j(function(){return m(),E(!1),O(),o.play(),J})};return L(),v(),j(y)(),o.ready(function(){0!=n.createButtons&&z(D),o.on("ended",function(){C&&p.enabled&&!o.loop()&&o.play()})}),o.abLoopPlugin=J,o.on("timeupdate",R),J.loaded=!0,J};n.loaded=!1,n.VERSION="0.4.5",e.plugin("abLoopPlugin",n)}); \ No newline at end of file +!function(e,t){"function"==typeof define&&define.amd?define([],t.bind(this,e,e.videojs)):"undefined"!=typeof module&&module.exports?module.exports=t(e,e.videojs):t(e,e.videojs)}(window,function(e,t){"use strict";var n="1.0.0",o=function(o){var r=this,a=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},i=function(e){return e&&"[object Function]"==={}.toString.call(e)},u=function(e){return!!e},f=function(e,n){return n=n||1,t.formatTime(e)+"."+Math.floor(e%1*Math.pow(10,n))},c=function(e,t){var n=Math.pow(10,t);return Math.floor(e*n)/n},l=function(e){if(void 0!==e){if(a(e))return e;if(/^([+\-])?([\d\.]+)$/i.test(e))return parseFloat(e);var t=/^([+\-])?((([\d]+)(h|:(?=.*:)))?(([\d]+)(m|:|$))?)?(([\d\.]+)s?)?$/i.exec(e);if(!t)return null;var n={match:t[0],sign:t[1],hours:t[4]||0,mins:t[7]||0,secs:t[10]||0},o="-"==n.sign?-1:1,r=60*parseFloat(n.hours)*60+60*parseFloat(n.mins)+parseFloat(n.secs);return a(r)?o*r:null}},s={},p={start:{default:0,validate:function(e){return!1===e?e:a(e)&&e>=0?e:0}},end:{default:!1,validate:function(e){if(!1===e)return e;if(a(e)){var t=r.duration();if(void 0===t||0===t){if(e>=0)return e}else{if(e>=0&&e<=t)return e;if(e>t)return t}}return!1}},enabled:{default:!1,validate:u},loopIfBeforeStart:{default:!0,validate:u},loopIfAfterEnd:{default:!0,validate:u},pauseBeforeLooping:{default:!1,validate:u},pauseAfterLooping:{default:!1,validate:u}},d={onLoopCallBack:{default:void 0,check:i},onOptionsChange:{default:void 0,check:i}},g=Object.keys(p),h=Object.keys(d),L=function(){return g.forEach(function(e){s[e]=p[e].validate(s[e])}),H},v=function(){return m(o,!0)},m=function(e,t){return g.forEach(function(n){(t||void 0!==e[n])&&(s[n]=e[n])}),L(),H},y=!1,b=function(e){return e?s.pauseBeforeLooping&&!1===y?(r.pause(),y=!0):(y=!1,r.currentTime(s.start),s.pauseAfterLooping&&r.pause(),d.onLoopCallBack.check(H.onLoopCallBack)&&H.onLoopCallBack(H,r)):(y=!1,r.currentTime(s.start)),H},U=function(e){return function(t){return!1===t?s[e]=!1:(void 0!==t&&(t=l(t)),null!==t&&(t=void 0===t?r.currentTime():t,s[e]=t)),H}},E=function(e){return function(t){return t=l(t),a(t)&&(s[e]+=t),H}},A=function(){return s.enabled=!0,H},B=function(e){return function(){return s[e]=!s[e],H}},O=function(e){(e=e||{}).decimalPlaces=Math.floor(e.decimalPlaces)||3;var t=!1!==s.start?parseFloat(s.start):0,n="#t="+c(t,e.decimalPlaces);if(!1!==s.end){var o=parseFloat(s.end);n+=","+c(o,e.decimalPlaces)}return n},k=function(e){e=e||{};var t=r.currentSrc();return t.src&&(t=t.src),t+O(e)},S=function(e){if("string"==typeof e&&(e=t.parseUrl(e)),e.hash){var n=/^(#?t=)?([^,]*)(,(.*))?$/,o=e.hash.replace(n,"$2"),r=e.hash.replace(n,"$4");o=l(o),r=l(r),a(o)&&(s.start=parseFloat(o)),a(r)&&(s.end=parseFloat(r))}return H},P=function(e){var t,n,o=e;return"string"==typeof e?o=[e]:void 0!==e&&Array.isArray(e)||(o=null!==e&&"object"==typeof e?Object.keys(e):Object.keys(p)),t=s,n={},o.forEach(function(e){void 0!==t[e]&&(n[e]=t[e])}),n},T=function(e,t){var n=!t;return t=t||{},g.forEach(function(e){t[e]=!!t[e]||n}),function(){var n=arguments,o=P(),a=e.apply(null,n),i={changed:t,oldOpts:o,newOpts:P()};return H.onOptionsChange&&H.onOptionsChange(i,H,r),q(t),a}},F=!1,x=function(){var e,t,n;if(L(),e=r.currentTime(),t=C(),(n=j())>t){if(F=!0,et&&(e-t<1||s.loopIfAfterEnd||s.loopIfBeforeStart))return!0}else{if(F=!1,e=t&&(e-t<1||s.loopIfAfterEnd))return!0}return!1},j=function(){return!1===s.start?0:s.start},C=function(){return!1===s.end?r.duration():s.end},K=!1,w=a(o.minLoopLength)&&o.minLoopLength>0?o.minLoopLength:200,$=function(e){!K&&s.enabled&&!r.paused()&&x()&&(K=!0,setTimeout(function(){K=!1},w),b(!0))},I={},M=[{name:"start",optionsUsed:["start"],leftclick:function(e,t){t.shiftKey?e.adjustStart(-.5):e.setStart()},rightclick:function(e,t){t.shiftKey?e.adjustStart(.5):e.goToStart()},defaultText:"Start",textFunction:function(e){return f(e.start)}},{name:"end",optionsUsed:["end"],leftclick:function(e,t){t.shiftKey?e.adjustEnd(-.5):t.ctrlKey?e.adjustEnd(-.05):e.setEnd()},rightclick:function(e,t){t.shiftKey?e.adjustEnd(.5):t.ctrlKey?e.adjustEnd(.05):e.goToEnd()},defaultText:"End",textFunction:function(e){return f(e.end)}},{name:"enabled",optionsUsed:["enabled","pauseAfterLooping","pauseBeforeLooping"],leftclick:function(t,n){e&&e.prompt?n.ctrlKey?t.applyUrl(N("Set new URL",t.getAbsoluteUrl())):n.altKey?t.applyUrl(N("Set new URL",t.getUrl())):n.shiftKey?t.applyUrlFragment(N("Set new URL fragment",t.getUrlFragment())):t.toggle():t.toggle()},rightclick:function(t,n){var o;e&&e.prompt&&(n.ctrlKey?o=t.getAbsoluteUrl():n.altKey?o=t.getUrl():n.shiftKey&&(o=t.getUrlFragment())),o?R(o):t.cyclePauseOnLooping()},defaultText:"Loop",textFunction:function(e){return e.enabled?e.pauseBeforeLooping&&e.pauseAfterLooping?"PAUSE LOOP PAUSE":e.pauseAfterLooping?"LOOP& PAUSE":e.pauseBeforeLooping?"PAUSE &LOOP":"LOOP ON":"Loop off"}}],R=function(t){e&&e.prompt&&e.prompt("Copy to clipboard: Ctrl+C, Enter",t)},N=function(t,n){return!(!e||!e.prompt)&&e.prompt(t,n)},D=function(e){e.forEach(function(e){var t,n,o,a,i,u;void 0===I[e.name]&&(I[e.name]=(t=e,i=function(e,t){return function(o){(void 0===t||o.which&&o.which==t)&&(e(n.abLoopPlugin,o),this.updateText())}},u=(n=r).controlBar.addChild("Button"),t.leftclick&&u.on("click",i(t.leftclick)),t.rightclick&&(u.el().onmousedown=i(t.rightclick,3).bind(u),u.on("contextmenu",function(e){return e.preventDefault&&e.preventDefault(),e.preventDefault&&e.stopPropagation(),!1})),u.updateText=(o=t.defaultText,a=t.textFunction,function(){var e=a(s)||o;this.el().textContent=e}),u.optionsUsed=t.optionsUsed,u.addClass("abLoopButton"),u.addClass(t.name),u.updateText(),u))})},q=function(e){var t=function(t,n){return t||e[n]};for(var n in I){var o=I[n];(!o.optionsUsed||o.optionsUsed.reduce(t,!1))&&o.updateText()}},H={validateOptions:T(L),resetToInitialOptions:T(v),setOptions:T(m),getOptions:P,goToStart:b,goToEnd:function(){return y=!1,r.currentTime(s.end),H},setStart:T(U("start"),{start:!0}),setEnd:T(U("end"),{end:!0}),adjustStart:T(E("start"),{start:!0}),adjustEnd:T(E("end"),{end:!0}),enable:T(A,{enabled:!0}),disable:T(function(){return s.enabled=!1,H},{enabled:!0}),toggle:T(B("enabled"),{enabled:!0}),togglePauseAfterLooping:T(B("pauseAfterLooping"),{pauseAfterLooping:!0}),togglePauseBeforeLooping:T(B("pauseBeforeLooping"),{pauseBeforeLooping:!0}),cyclePauseOnLooping:T(function(){var e=s.pauseAfterLooping,t=s.pauseBeforeLooping;return m(e||t?e&&!t?{pauseAfterLooping:!1,pauseBeforeLooping:!0}:!e&&t?{pauseAfterLooping:!0,pauseBeforeLooping:!0}:{pauseAfterLooping:!1,pauseBeforeLooping:!1}:{pauseAfterLooping:!0,pauseBeforeLooping:!1}),H},{pauseBeforeLooping:!0,pauseAfterLooping:!0}),player:r,version:n,getAbsoluteUrl:function(t){return function(t){if(!t.match(/^https?:\/\//)&&e&&e.document){var n=e.document.createElement("div");n.innerHTML='x',t=n.firstChild.href}return t}(k(t))},getUrl:k,getUrlFragment:O,applyUrl:T(function(e){var t=e.replace(/^(.*?)(#.*)?$/,"$1"),n=e.replace(/^(.*?)(#.*)?$/,"$2"),o=r.currentSrc();return o!=t&&o!=e&&e!=n&&r.src(t),n&&S(n),H},{start:!0,end:!0}),applyUrlFragment:T(S,{start:!0,end:!0}),loopRequired:x,playLoop:T(function(){return L(),b(!1),A(),r.play(),H})};return function(){o=o||{};var e=function(e){return function(t){void 0===o[t]&&(o[t]=e[t].default)}};g.forEach(e(p)),h.forEach(e(d))}(),h.forEach(function(e){d[e].check(o[e])&&(H[e]=o[e])}),T(v)(),r.ready(function(){0!=o.createButtons&&D(M),r.on("ended",function(){F&&s.enabled&&!r.loop()&&r.play()})}),r.abLoopPlugin=H,r.on("timeupdate",$),H.loaded=!0,H};return o.loaded=!1,o.VERSION=n,(t.registerPlugin||t.plugin)("abLoopPlugin",o)}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..d2b22d4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,414 @@ +{ + "name": "videojs-abloop", + "version": "0.4.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.9.tgz", + "integrity": "sha512-/+o3o6OV1cm3WKrO7U4wykU+ZICE6HiMEuravc2d03NIuM/VaRn5iMcoQ7NyxFXjvpmRICP2EER0YOnh4yIapA==", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=" + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "requires": { + "assertion-error": "1.1.0", + "check-error": "1.0.2", + "deep-eql": "3.0.1", + "get-func-name": "2.0.0", + "pathval": "1.1.0", + "type-detect": "4.0.8" + } + }, + "chai-as-promised": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", + "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "requires": { + "check-error": "1.0.2" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "core-js": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz", + "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "requires": { + "type-detect": "4.0.8" + } + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==" + }, + "es6-promise": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", + "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==" + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + }, + "http-shutdown": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-shutdown/-/http-shutdown-1.2.0.tgz", + "integrity": "sha1-3y2AZ6iFbpnRHp3OshYJWR4d9RQ=" + }, + "immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jszip": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", + "integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==", + "requires": { + "core-js": "2.3.0", + "es6-promise": "3.0.2", + "lie": "3.1.1", + "pako": "1.0.6", + "readable-stream": "2.0.6" + } + }, + "lie": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", + "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", + "requires": { + "immediate": "3.0.6" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.9" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.0.tgz", + "integrity": "sha512-ukB2dF+u4aeJjc6IGtPNnJXfeby5d4ZqySlIBT0OEyva/DrMjVm5HkQxKnHDLKEfEQBsEnwTg9HHhtPHJdTd8w==", + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node-static": { + "version": "0.7.10", + "resolved": "https://registry.npmjs.org/node-static/-/node-static-0.7.10.tgz", + "integrity": "sha512-bd7zO5hvCWzdglgwz9t82T4mYTEUzEG5pXnSqEzitvmEacusbhl8/VwuCbMaYR9g2PNK5191yBtAEQLJEmQh1A==", + "requires": { + "colors": "1.1.2", + "mime": "1.6.0", + "optimist": "0.6.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "requires": { + "minimist": "0.0.8", + "wordwrap": "0.0.3" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "pako": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "7.1.2" + } + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "selenium-webdriver": { + "version": "4.0.0-alpha.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz", + "integrity": "sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==", + "requires": { + "jszip": "3.1.5", + "rimraf": "2.6.2", + "tmp": "0.0.30", + "xml2js": "0.4.19" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "requires": { + "has-flag": "2.0.0" + } + }, + "tmp": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.30.tgz", + "integrity": "sha1-ckGdSovn1s51FI/YsyTlk6cRwu0=", + "requires": { + "os-tmpdir": "1.0.2" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, + "uglify-js": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.10.tgz", + "integrity": "sha512-dNib7aUDNZFJNTXFyq0CDmLRVOsnY1F+IQgt2FAOdZFx2+LvKVLbbIb/fL+BYKCv3YH3bPCE/6M/JaxChtQLHQ==", + "requires": { + "commander": "2.14.1", + "source-map": "0.6.1" + }, + "dependencies": { + "commander": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "requires": { + "sax": "1.2.4", + "xmlbuilder": "9.0.7" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" + } + } +} diff --git a/package.json b/package.json index 880303c..4190491 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,33 @@ -{ - "name": "videojs-abloop", - "version": "0.4.5", - "description": "A video.js plugin allowing looping of a section of video, with GUI and API interface", - "main": "videojs-abloop.js", - "scripts": { - "test": "mocha" - ,"min": "uglifyjs videojs-abloop.js --compress --mangle -o dist/videojs-abloop.min.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/phhu/videojs-abloop.git" - }, - "keywords": [ - "videojs-plugin","videojs" - ], - "author": "", - "license": "MIT", - "bugs": { - "url": "https://github.com/phhu/videojs-abloop/issues" - }, - "homepage": "https://github.com/phhu/videojs-abloop#readme", - "dependencies": { - "chai": "^3.5.0", - "chai-as-promised": "^5.2.0", - "mocha": "^2.4.5", - "node-static": "^0.7.7", - "selenium-webdriver": "^2.52.0", - "uglifyjs": "^2.4.10" - } -} +{ + "name": "videojs-abloop", + "version": "1.0.0", + "description": "A video.js plugin allowing looping of a section of video, with GUI and API interface", + "main": "videojs-abloop.js", + "scripts": { + "test": "mocha", + "min": "uglifyjs videojs-abloop.js --compress --mangle -o dist/videojs-abloop.min.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/phhu/videojs-abloop.git" + }, + "keywords": [ + "videojs-plugin", + "videojs" + ], + "author": "", + "license": "MIT", + "bugs": { + "url": "https://github.com/phhu/videojs-abloop/issues" + }, + "homepage": "https://github.com/phhu/videojs-abloop#readme", + "dependencies": { + "chai": "^4.1.2", + "chai-as-promised": "^7.1.1", + "http-shutdown": "^1.2.0", + "mocha": "^5.0.0", + "node-static": "^0.7.7", + "selenium-webdriver": "^4.0.0-alpha.1", + "uglify-js": "^3.3.10" + } +} diff --git a/test/videojs-abloop-test.js b/test/videojs-abloop-test.js index 6f13a20..0c55575 100644 --- a/test/videojs-abloop-test.js +++ b/test/videojs-abloop-test.js @@ -5,15 +5,19 @@ chai.use(chaiAsPromised); var expect = chai.expect; var should = chai.should(); var static = require('node-static'); - +var http = require('http'); +var port = 8081; + + //create a static server to serve out the samples var fileServer = new static.Server('.'); -require('http').createServer(function (request, response) { +var httpServer = http.createServer(function (request, response) { request.addListener('end', function () { fileServer.serve(request, response); }).resume(); -}).listen(8080); +}).listen(port); +httpServer = require('http-shutdown')(httpServer); describe('videojs-abloop', function() { @@ -28,11 +32,11 @@ describe('videojs-abloop', function() { withCapabilities(selenium.Capabilities.firefox()). build(); driver = this.driver; - driver.get('http://localhost:8080/sample') + driver.get('http://localhost:' + port + '/sample') .then(driver.wait(function () { return driver.executeScript("return videos[0] != undefined && videos[0].abLoopPlugin != undefined && videos[0].abLoopPlugin.loaded;"); }, 8000)) - .then(done); + .then(function(){done()}); }); beforeEach(function(done) { done(); @@ -41,18 +45,22 @@ describe('videojs-abloop', function() { // Close the website after each test is run (so that it is opened fresh each time) after(function(done) { - driver.quit().then(done); - //done(); + httpServer.shutdown(function(){console.log("shut down http server");}); + driver.quit().then(function(){done()}); }); + it('Should be enablable', function() { return driver.executeScript("return videos[0].abLoopPlugin.enable().getOptions().enabled;").should.eventually.equal(true); }); + it('Should go to start', function() { return driver.executeScript("return videos[0].abLoopPlugin.setStart(5).goToStart().player.currentTime();").should.eventually.equal(5); }); + it('Should go to end', function() { return driver.executeScript("return videos[0].abLoopPlugin.setEnd(7).goToEnd().player.currentTime();").should.eventually.equal(7); - }); + }); + it('Should apply URL fragments', function(done) { driver.executeScript("return videos[0].abLoopPlugin.applyUrlFragment('#t=2,0:00:03').getOptions();").then(function(opts){ expect(opts.start).to.equal(2); @@ -60,9 +68,11 @@ describe('videojs-abloop', function() { done(); }); }); + it('Should return URL fragments', function() { return driver.executeScript("return videos[1].abLoopPlugin.setStart(1).setEnd(\"0m4s\").getUrlFragment();").should.eventually.equal('#t=1,4'); }); + it('Should allow pausing before looping', function(done) { this.timeout(8000); driver.executeScript("return videos[1].abLoopPlugin.setOptions({'pauseBeforeLooping':true,'start':5,'end':7,'enabled':true}).goToStart().getOptions();").then(function(opts){ @@ -84,11 +94,5 @@ describe('videojs-abloop', function() { }, 2000); }); }); - /*it('Should have a body', function(done) { - this.driver.findElement(selenium.By.tagName('body')).getAttribute('id').then(function(id) { - expect(id).to.equal('body'); - done(); - }); - });*/ }); diff --git a/videojs-abloop.js b/videojs-abloop.js index a5829da..39fe751 100644 --- a/videojs-abloop.js +++ b/videojs-abloop.js @@ -16,7 +16,7 @@ })(window, function (window, videojs) { "use strict"; - var version = "0.4.5"; + var version = "1.0.0"; var abLoopPlugin = function (initialOptions) { //get reference to player @@ -831,6 +831,8 @@ abLoopPlugin.loaded = false; abLoopPlugin.VERSION = version; - videojs.plugin('abLoopPlugin', abLoopPlugin); + + var registerPlugin = videojs.registerPlugin || videojs.plugin; + return registerPlugin('abLoopPlugin', abLoopPlugin); });