UNPKG

@e10in/videojs-record

Version:

A video.js plugin for recording audio/video/image files.

8 lines 4.63 kB
/*! * lamejs plugin for @e10in/videojs-record * @version 4.4.4 * @see https://github.com/collab-project/videojs-record * @copyright 2014-2021 Collab * @license MIT */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define("VideojsRecord",["video.js"],t):"object"==typeof exports?exports.VideojsRecord=t(require("video.js")):(e.VideojsRecord=e.VideojsRecord||{},e.VideojsRecord.lamejs=t(e.videojs))}(self,(function(e){return t={1506:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},4575:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},3913:e=>{function t(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,o,r){return o&&t(e.prototype,o),r&&t(e,r),e}},9754:e=>{function t(o){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(o)}e.exports=t},2205:(e,t,o)=>{var r=o(9489);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},5318:e=>{e.exports=function(e){return e&&e.__esModule?e:{default:e}}},8585:(e,t,o)=>{var r=o(8),n=o(1506);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?n(e):t}},9489:e=>{function t(o,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(o,r)}e.exports=t},8:e=>{function t(o){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(o)}e.exports=t},6541:(e,t,o)=>{"use strict";var r=o(5318);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(o(4575)),i=r(o(3913)),s=r(o(2205)),u=r(o(8585)),c=r(o(9754)),a=r(o(4390));function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,r=(0,c.default)(e);if(t){var n=(0,c.default)(this).constructor;o=Reflect.construct(r,arguments,n)}else o=r.apply(this,arguments);return(0,u.default)(this,o)}}var d=function(e){(0,s.default)(o,e);var t=f(o);function o(e,r){var i;return(0,n.default)(this,o),(i=t.call(this,e,r)).debug=!1,i.sampleRate=44100,i.bitRate=128,i.audioWorkerURL="worker-realtime.js",i.audioType="audio/mpeg",i}return(0,i.default)(o,[{key:"setup",value:function(e,t,o){this.inputStream=e,this.mediaType=t,this.debug=o,this.config={debug:this.debug,sampleRate:this.sampleRate,bitRate:this.bitRate},this.engine=new Worker(this.audioWorkerURL),this.engine.onmessage=this.onWorkerMessage.bind(this),this.engine.postMessage({cmd:"init",config:this.config})}},{key:"start",value:function(){var e=window.AudioContext||window.webkitAudioContext;this.audioContext=new e,this.audioSourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.processor=this.audioContext.createScriptProcessor(0,1,1),this.processor.onaudioprocess=this.onAudioProcess.bind(this),this.audioSourceNode.connect(this.processor),this.processor.connect(this.audioContext.destination)}},{key:"stop",value:function(){this.processor&&this.audioSourceNode&&(this.audioSourceNode.disconnect(),this.processor.disconnect(),this.processor.onaudioprocess=null),this.audioContext&&this.audioContext.close().then((function(){})).catch((function(e){})),this.engine.postMessage({cmd:"finish"})}},{key:"onWorkerMessage",value:function(e){switch(e.data.cmd){case"end":this.onStopRecording(new Blob(e.data.buf,{type:this.audioType}));break;case"error":this.player().trigger("error",e.data.error);break;default:this.player().trigger("error",e.data)}}},{key:"onAudioProcess",value:function(e){var t=e.inputBuffer.getChannelData(0);this.engine.postMessage({cmd:"encode",buf:t})}}]),o}(a.default.getComponent("RecordEngine"));a.default.LamejsEngine=d;var p=d;t.default=p,e.exports=t.default},4390:t=>{"use strict";t.exports=e}},o={},function e(r){var n=o[r];if(void 0!==n)return n.exports;var i=o[r]={exports:{}};return t[r](i,i.exports,e),i.exports}(6541);var t,o}));