audiolooper
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AudioLooper=e():t.AudioLooper=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=n(1),i=r(o),u=n(2),a=r(u),c=n(21),f=r(c),s=n(23),l=function(){function t(e,n){(0,i.default)(this,t),this.onPlay=e,this.onStop=n,this.bootstrap()}return(0,a.default)(t,[{key:"bootstrap",value:function(){var t=this;this.worker=(0,f.default)(),this.worker.addEventListener("message",function(e){var n=e.data;return t.onWorkerMessage(JSON.parse(n))})}},{key:"onWorkerMessage",value:function(t){var e=t.type,n=t.id;t.payload;switch(e){case s.PLAY:this.onPlay(n);break;case s.STOP:this.onStop(n)}}},{key:"addTrack",value:function(t){var e=t.id,n=t.duration;this.post({type:s.ADD_TRACK,payload:{id:e,duration:n}})}},{key:"removeTrack",value:function(t){var e=t.id;this.post({type:s.REMOVE_TRACK,payload:{id:e}})}},{key:"play",value:function(t){var e=t.id;this.post({type:s.PLAY,payload:{id:e}})}},{key:"stop",value:function(t){var e=t.id;this.post({type:s.STOP,payload:{id:e}})}},{key:"syncFirstTrack",value:function(t){var e=this;setInterval(function(){e.post({type:s.SYNC,payload:t.currentTime})},300)}},{key:"post",value:function(t){this.worker.postMessage(JSON.stringify(t))}}]),t}();e.default=l},function(t,e){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var o=n(3),i=r(o);e.default=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,i.default)(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()},function(t,e,n){t.exports={default:n(4),__esModule:!0}},function(t,e,n){n(5);var r=n(8).Object;t.exports=function(t,e,n){return r.defineProperty(t,e,n)}},function(t,e,n){var r=n(6);r(r.S+r.F*!n(16),"Object",{defineProperty:n(12).f})},function(t,e,n){var r=n(7),o=n(8),i=n(9),u=n(11),a="prototype",c=function(t,e,n){var f,s,l,d=t&c.F,p=t&c.G,v=t&c.S,y=t&c.P,h=t&c.B,T=t&c.W,m=p?o:o[e]||(o[e]={}),b=m[a],w=p?r:v?r[e]:(r[e]||{})[a];p&&(n=e);for(f in n)s=!d&&w&&void 0!==w[f],s&&f in m||(l=s?w[f]:n[f],m[f]=p&&"function"!=typeof w[f]?n[f]:h&&s?i(l,r):T&&w[f]==l?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e[a]=t[a],e}(l):y&&"function"==typeof l?i(Function.call,l):l,y&&((m.virtual||(m.virtual={}))[f]=l,t&c.R&&b&&!b[f]&&u(b,f,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){var r=n(10);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var r=n(12),o=n(20);t.exports=n(16)?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e,n){var r=n(13),o=n(15),i=n(19),u=Object.defineProperty;e.f=n(16)?Object.defineProperty:function(t,e,n){if(r(t),e=i(e,!0),r(n),o)try{return u(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var r=n(14);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){t.exports=!n(16)&&!n(17)(function(){return 7!=Object.defineProperty(n(18)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){t.exports=!n(17)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,n){var r=n(14),o=n(7).document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e,n){var r=n(14);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(){return new a.default(i)}function i(){function t(t,e){var n=void 0;f(function(r){var o=t.find(function(t){return t.isFirstTrack});o&&(o.currentPercentualTime+=r/1e3/o.duration,n=s(t,e,n))})}function e(t,e,n){var r=0===t.length,o=1;if(!r){var i=t.find(function(t){return t.isFirstTrack});o=Math.ceil(e/i.duration)}t.push({id:n,duration:e,isFirstTrack:r,shouldPlay:!0,currentPercentualTime:0,maxPercentualTime:o})}var n="ADD_TRACK",r="PLAY",o="STOP",i="REMOVE_TRACK",u="SYNC",a=function(t){self.postMessage(JSON.stringify(t))},c=[],f=function(t){var e=performance.now();setInterval(function(){var n=performance.now(),r=n-e;e=n,t(r)},0)},s=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=t.find(function(t){return t.isFirstTrack});return n+1<r.currentPercentualTime&&(n+=1,t.forEach(function(t){n%t.maxPercentualTime===0&&t.shouldPlay&&e(t.id)})),n};self.addEventListener("message",function(t){var f=JSON.parse(t.data),s=f.type,l=f.payload,d=l.id;switch(s){case n:var p=l.duration;e(c,p,d);break;case i:c.splice(c.find(function(t){return t.id===d}),1);break;case r:var v=c.find(function(t){return t.id===d});v.shouldPlay=!0;break;case o:c.find(function(t){return t.id===d});v.shouldPlay=!1,a({type:o,id:d});break;case u:var y=l,h=c.find(function(t){return t.isFirstTrack});h.currentPercentualTime+=y/h.duration-(h.currentPercentualTime-Math.floor(h.currentPercentualTime))}}),t(c,function(t){a({type:r,id:t})})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(22),a=r(u)},function(t,e){(function(e){function n(t,n){function o(t){setTimeout(function(){u.onmessage({data:t})},0)}var i,u=this;return n=n||{},r?(i=t.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1],new e.Worker(e.URL.createObjectURL(new e.Blob([i],{type:"text/javascript"})))):(this.self=n,this.self.postMessage=o,void setTimeout(t.bind(n,n),0))}var r=!!(e===e.window&&e.URL&&e.Blob&&e.Worker);n.prototype.postMessage=function(t){var e=this;setTimeout(function(){e.self.onmessage({data:t})},0)},t.exports=n}).call(e,function(){return this}())},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ADD_TRACK="ADD_TRACK",e.REMOVE_TRACK="REMOVE_TRACK",e.PLAY="PLAY",e.STOP="STOP",e.SYNC="SYNC"}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AudioLooper=e():t.AudioLooper=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=n(1),i=r(o),u=n(2),a=r(u),c=n(21),f=r(c),s=n(23),l=function(){function t(e,n){(0,i.default)(this,t),this.onPlay=e,this.onStop=n,this.bootstrap()}return(0,a.default)(t,[{key:"bootstrap",value:function(){var t=this;this.worker=(0,f.default)(),this.worker.addEventListener("message",function(e){var n=e.data;return t.onWorkerMessage(JSON.parse(n))})}},{key:"onWorkerMessage",value:function(t){var e=t.type,n=t.id;t.payload;switch(e){case s.PLAY:this.onPlay(n);break;case s.STOP:this.onStop(n)}}},{key:"addTrack",value:function(t){var e=t.id,n=t.duration;this.post({type:s.ADD_TRACK,payload:{id:e,duration:n}})}},{key:"removeTrack",value:function(t){var e=t.id;this.post({type:s.REMOVE_TRACK,payload:{id:e}})}},{key:"play",value:function(t){var e=t.id;this.post({type:s.PLAY,payload:{id:e}})}},{key:"stop",value:function(t){var e=t.id;this.post({type:s.STOP,payload:{id:e}})}},{key:"syncFirstTrack",value:function(t){var e=this;setInterval(function(){e.post({type:s.SYNC,payload:t.currentTime})},300)}},{key:"post",value:function(t){this.worker.postMessage(JSON.stringify(t))}},{key:"dispose",value:function(){this.woker.terminate()}}]),t}();e.default=l},function(t,e){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var o=n(3),i=r(o);e.default=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,i.default)(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()},function(t,e,n){t.exports={default:n(4),__esModule:!0}},function(t,e,n){n(5);var r=n(8).Object;t.exports=function(t,e,n){return r.defineProperty(t,e,n)}},function(t,e,n){var r=n(6);r(r.S+r.F*!n(16),"Object",{defineProperty:n(12).f})},function(t,e,n){var r=n(7),o=n(8),i=n(9),u=n(11),a="prototype",c=function(t,e,n){var f,s,l,d=t&c.F,p=t&c.G,v=t&c.S,y=t&c.P,h=t&c.B,T=t&c.W,m=p?o:o[e]||(o[e]={}),w=m[a],b=p?r:v?r[e]:(r[e]||{})[a];p&&(n=e);for(f in n)s=!d&&b&&void 0!==b[f],s&&f in m||(l=s?b[f]:n[f],m[f]=p&&"function"!=typeof b[f]?n[f]:h&&s?i(l,r):T&&b[f]==l?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e[a]=t[a],e}(l):y&&"function"==typeof l?i(Function.call,l):l,y&&((m.virtual||(m.virtual={}))[f]=l,t&c.R&&w&&!w[f]&&u(w,f,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){var r=n(10);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var r=n(12),o=n(20);t.exports=n(16)?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e,n){var r=n(13),o=n(15),i=n(19),u=Object.defineProperty;e.f=n(16)?Object.defineProperty:function(t,e,n){if(r(t),e=i(e,!0),r(n),o)try{return u(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var r=n(14);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){t.exports=!n(16)&&!n(17)(function(){return 7!=Object.defineProperty(n(18)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){t.exports=!n(17)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,n){var r=n(14),o=n(7).document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e,n){var r=n(14);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(){return new a.default(i)}function i(){function t(t,e){var n=void 0;f(function(r){var o=t.find(function(t){return t.isFirstTrack});o&&(o.currentPercentualTime+=r/1e3/o.duration,n=s(t,e,n))})}function e(t,e,n){var r=0===t.length,o=1;if(!r){var i=t.find(function(t){return t.isFirstTrack});o=Math.ceil(e/i.duration)}t.push({id:n,duration:e,isFirstTrack:r,shouldPlay:!0,currentPercentualTime:0,maxPercentualTime:o})}var n="ADD_TRACK",r="PLAY",o="STOP",i="REMOVE_TRACK",u="SYNC",a=function(t){self.postMessage(JSON.stringify(t))},c=[],f=function(t){var e=performance.now();setInterval(function(){var n=performance.now(),r=n-e;e=n,t(r)},0)},s=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=t.find(function(t){return t.isFirstTrack});return n+1<r.currentPercentualTime&&(n+=1,t.forEach(function(t){n%t.maxPercentualTime===0&&t.shouldPlay&&e(t.id)})),n};self.addEventListener("message",function(t){var f=JSON.parse(t.data),s=f.type,l=f.payload,d=l.id;switch(s){case n:var p=l.duration;e(c,p,d);break;case i:c.splice(c.find(function(t){return t.id===d}),1);break;case r:var v=c.find(function(t){return t.id===d});v.shouldPlay=!0;break;case o:c.find(function(t){return t.id===d});v.shouldPlay=!1,a({type:o,id:d});break;case u:var y=l,h=c.find(function(t){return t.isFirstTrack});h.currentPercentualTime+=y/h.duration-(h.currentPercentualTime-Math.floor(h.currentPercentualTime))}}),t(c,function(t){a({type:r,id:t})})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(22),a=r(u)},function(t,e){(function(e){function n(t,n){function o(t){setTimeout(function(){u.onmessage({data:t})},0)}var i,u=this;return n=n||{},r?(i=t.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1],new e.Worker(e.URL.createObjectURL(new e.Blob([i],{type:"text/javascript"})))):(this.self=n,this.self.postMessage=o,void setTimeout(t.bind(n,n),0))}var r=!!(e===e.window&&e.URL&&e.Blob&&e.Worker);n.prototype.postMessage=function(t){var e=this;setTimeout(function(){e.self.onmessage({data:t})},0)},t.exports=n}).call(e,function(){return this}())},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ADD_TRACK="ADD_TRACK",e.REMOVE_TRACK="REMOVE_TRACK",e.PLAY="PLAY",e.STOP="STOP",e.SYNC="SYNC"}])}); |
{ | ||
"name": "audiolooper", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "AudioLooper - Loop your tracks with automatic synchronization.", | ||
@@ -35,4 +35,5 @@ "main": "build/bundle.js", | ||
"audiochnl": "*", | ||
"file-loader": "^0.9.0", | ||
"inline-worker": "^1.1.0" | ||
} | ||
} |
@@ -67,3 +67,3 @@ # AudioLooper - Looping made easy | ||
```javascript | ||
.add( { id, duration } ) | ||
.addTrack( { id, duration } ) | ||
``` | ||
@@ -83,3 +83,3 @@ | ||
```javascript | ||
.remove( { id } ) | ||
.removeTrack( { id } ) | ||
``` | ||
@@ -111,2 +111,9 @@ | ||
### Disposing the looper | ||
If you don't need the looper anymore, you should consider disposing it, otherwise the thread will keep running in the background. To do so, just call: | ||
```javascript | ||
.dispose() | ||
``` | ||
### Syncing the _virtual_ first track with _real_ first track | ||
@@ -113,0 +120,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21499
138
3
+ Addedfile-loader@^0.9.0
+ Addedbig.js@3.2.0(transitive)
+ Addedemojis-list@2.1.0(transitive)
+ Addedfile-loader@0.9.0(transitive)
+ Addedjson5@0.5.1(transitive)
+ Addedloader-utils@0.2.17(transitive)
+ Addedobject-assign@4.1.1(transitive)