1
2
3
4
5
6
7
8
9
|
/*!
* videojs-wavesurfer
* @version 2.5.1
* @see https://github.com/collab-project/videojs-wavesurfer
* @copyright 2014-2018 Collab
* @license MIT
*/
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("videojs"),require("WaveSurfer")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["videojs","WaveSurfer"],r):"object"==typeof exports?exports.VideojsWavesurfer=r(require("videojs"),require("WaveSurfer")):e.VideojsWavesurfer=r(e.videojs,e.WaveSurfer)}(window,function(e,r){return function(e){var r={};function t(i){if(r[i])return r[i].exports;var s=r[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,t),s.l=!0,s.exports}return t.m=e,t.c=r,t.d=function(e,r,i){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var s in e)t.d(i,s,function(r){return e[r]}.bind(null,s));return i},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1),e.exports=t(9)},function(e,r,t){"use strict";var i=function(){function e(e,r){for(var t=0;t<r.length;t++){var i=r[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(r,t,i){return t&&e(r.prototype,t),i&&e(r,i),r}}(),s=h(t(2)),o=h(t(3)),a=h(t(4)),n=h(t(5)),l=h(t(7)),u=h(t(8));function h(e){return e&&e.__esModule?e:{default:e}}function p(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}var f=l.default.getPlugin("plugin"),d=function(e){function r(e,t){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);var i=p(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));if(e.addClass("vjs-wavesurfer"),t=l.default.mergeOptions(a.default,t),i.waveReady=!1,i.waveFinished=!1,i.liveMode=!1,i.debug="true"===t.debug.toString(),i.msDisplayMax=parseFloat(t.msDisplayMax),i.textTracksEnabled=i.player.options_.tracks.length>0,"live"===t.src){if(void 0===u.default.microphone)return i.onWaveError("Could not find wavesurfer.js microphone plugin!"),p(i);i.liveMode=!0,i.waveReady=!0}return i.player.one("ready",i.initialize.bind(i)),i}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}(r,f),i(r,[{key:"initialize",value:function(){(this.player.bigPlayButton.hide(),!0===this.player.usingNativeControls_&&void 0!==this.player.tech_.el_&&(this.player.tech_.el_.controls=!1),!0===this.player.options_.controls)&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",this.player.controlBar.progressControl.hide(),[this.player.controlBar.currentTimeDisplay,this.player.controlBar.timeDivider,this.player.controlBar.durationDisplay].forEach(function(e){void 0!==e&&(e.el_.style.display="block",e.show())}),void 0!==this.player.controlBar.remainingTimeDisplay&&this.player.controlBar.remainingTimeDisplay.hide(),this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.liveMode||this.player.controlBar.playToggle.hide());var e=this.parseOptions(this.player.options_.plugins.wavesurfer);this.surfer=u.default.create(e),this.surfer.on("error",this.onWaveError.bind(this)),this.surfer.on("finish",this.onWaveFinish.bind(this)),!0===this.liveMode&&this.surfer.microphone.on("deviceError",this.onWaveError.bind(this)),this.surferReady=this.onWaveReady.bind(this),this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.liveMode||this.setupPlaybackEvents(!0),this.player.on("volumechange",this.onVolumeChange.bind(this)),this.player.on("fullscreenchange",this.onScreenChange.bind(this)),this.player.muted()&&this.setVolume(0),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.responsiveWave=u.default.util.debounce(this.onResizeChange.bind(this),150),n.default.addEventListener("resize",this.responsiveWave)),this.textTracksEnabled&&(this.player.controlBar.currentTimeDisplay.off(this.player,"timeupdate",this.player.controlBar.currentTimeDisplay.throttledUpdateContent),this.player.tech_.trackCurrentTime()),this.startPlayers()}},{key:"parseOptions",value:function(e){var r=this.player.el_.getBoundingClientRect();this.originalWidth=this.player.options_.width||r.width,this.originalHeight=this.player.options_.height||r.height;var t=this.player.controlBar.height();if(!0===this.player.options_.controls&&0===t&&(t=30),void 0===e.container&&(e.container=this.player.el_),void 0===e.waveformHeight){var i=r.height;e.height=i-t}else e.height=opts.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),!0===this.liveMode&&(e.plugins=[u.default.microphone.create(e)],this.log("wavesurfer.js microphone plugin enabled.")),e}},{key:"startPlayers",value:function(){var e=this.player.options_.plugins.wavesurfer;void 0!==e.src?void 0===this.surfer.microphone?(this.player.loadingSpinner.show(),this.load(e.src,e.peaks)):(this.player.loadingSpinner.hide(),e.wavesurfer=this.surfer):this.player.loadingSpinner.hide()}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un("ready",this.surferReady),this.surfer.un("audioprocess",this.surferProgress),this.surfer.un("seek",this.surferSeek)):!0===e&&(this.surfer.on("ready",this.surferReady),this.surfer.on("audioprocess",this.surferProgress),this.surfer.on("seek",this.surferSeek))}},{key:"load",value:function(e,r){var t=this;if(e instanceof Blob||e instanceof File)this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e);else if(void 0!==r)if(Array.isArray(r))this.log("Loading URL: "+e),this.surfer.load(e,r);else{var i={url:r,responseType:"json"};void 0!==this.player.options_.plugins.wavesurfer.xhr&&(i.xhr=this.player.options_.plugins.wavesurfer.xhr);var s=u.default.util.ajax(i);s.on("success",function(i,s){t.log("Loaded Peak Data URL: "+r),t.surfer.load(e,i.data)}),s.on("error",function(i){t.log("Unable to retrieve peak data from "+r+". Status code: "+i.target.status,"warn"),t.log("Loading URL: "+e),t.surfer.load(e)})}else this.log("Loading URL: "+e),this.surfer.load(e)}},{key:"play",value:function(){(this.player.controlBar.playToggle.handlePlay(),this.liveMode)?this.surfer.microphone.active?!this.surfer.microphone.paused?this.pause():(this.log("Resume microphone"),this.surfer.microphone.play()):(this.log("Start microphone"),this.surfer.microphone.start()):(this.log("Start playback"),this.player.play(),this.surfer.play())}},{key:"pause",value:function(){this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePause(),this.liveMode?(this.log("Pause microphone"),this.surfer.microphone.pause()):(this.log("Pause playback"),this.waveFinished?this.waveFinished=!1:this.surfer.pause(),this.setCurrentTime())}},{key:"dispose",value:function(){this.surfer&&(this.liveMode&&this.surfer.microphone&&(this.surfer.microphone.destroy(),this.log("Destroyed microphone plugin")),this.surfer.destroy()),this.textTracksEnabled&&this.player.tech_.stopTrackingCurrentTime(),this.log("Destroyed plugin")}},{key:"isDestroyed",value:function(){return this.player&&null===this.player.children()}},{key:"destroy",value:function(){this.player.dispose()}},{key:"setVolume",value:function(e){void 0!==e&&(this.log("Changing volume to: "+e),this.player.volume(e))}},{key:"exportImage",value:function(e,r){return this.surfer.exportImage(e,r)}},{key:"setAudioOutput",value:function(e){var r=this;e&&this.surfer.setSinkId(e).then(function(e){r.player.trigger("audioOutputReady")}).catch(function(e){r.player.trigger("error",e),r.log(e,"error")})}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,r){void 0===e&&(e=this.surfer.getCurrentTime()),void 0===r&&(r=this.surfer.getDuration()),e=isNaN(e)?0:e,r=isNaN(r)?0:r;var t=Math.min(e,r);this.player.controlBar.currentTimeDisplay.contentEl()&&(this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,o.default)(t,r,this.msDisplayMax)),this.textTracksEnabled&&this.player.tech_.setCurrentTime(e)}},{key:"getDuration",value:function(){var e=this.surfer.getDuration();return e=isNaN(e)?0:e}},{key:"setDuration",value:function(e){void 0===e&&(e=this.surfer.getDuration()),e=isNaN(e)?0:e,this.player.controlBar.durationDisplay.contentEl()&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,o.default)(e,e,this.msDisplayMax))}},{key:"onWaveReady",value:function(){this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger("waveReady"),this.setCurrentTime(),this.setDuration(),this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.show(),this.player.loadingSpinner.contentEl()&&this.player.loadingSpinner.hide(),!0===this.player.options_.autoplay&&this.play()}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger("playbackFinish"),!0===this.player.options_.loop?(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.pause(),this.player.trigger("ended"),this.surfer.once("seek",function(){e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger("pause")}))}},{key:"onWaveProgress",value:function(e){this.setCurrentTime()}},{key:"onWaveSeek",value:function(){this.setCurrentTime()}},{key:"onWaveError",value:function(e){this.player.trigger("error",e),this.log(e,"error")}},{key:"onPlayToggle",value:function(){this.player.controlBar.playToggle.hasClass("vjs-ended")&&this.player.controlBar.playToggle.removeClass("vjs-ended"),this.surfer.isPlaying()?this.pause():this.play()}},{key:"onVolumeChange",value:function(){var e=this.player.volume();this.player.muted()&&(e=0),this.surfer.setVolume(e)}},{key:"onScreenChange",value:function(){var e=this,r=this.player.setInterval(function(){var t=void 0,i=void 0;if(e.player.isFullscreen()||(t=e.originalWidth,i=e.originalHeight),e.waveReady){if(e.liveMode&&!e.surfer.microphone.active)return;e.redrawWaveform(t,i)}e.player.clearInterval(r)},100)}},{key:"onResizeChange",value:function(){void 0!==this.surfer&&this.redrawWaveform()}},{key:"redrawWaveform",value:function(e,r){if(!this.isDestroyed()){if(this.player.el_){var t=this.player.el_.getBoundingClientRect();void 0===e&&(e=t.width),void 0===r&&(r=t.height)}this.surfer.drawer.destroy(),this.surfer.params.width=e,this.surfer.params.height=r-this.player.controlBar.height(),this.surfer.createDrawer(),this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,r){(0,s.default)(e,r,this.debug)}}]),r}();d.VERSION="2.5.1",l.default.Wavesurfer=d,void 0===l.default.getPlugin("wavesurfer")&&l.default.registerPlugin("wavesurfer",d),e.exports={Wavesurfer:d}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,r,t){!0===t&&("error"===r?videojs.log.error(e):"warn"===r?videojs.log.warn(e):videojs.log(e))},e.exports=r.default},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,r,t){e=e<0?0:e,r=r||e;var i=Math.floor(e%60),s=Math.floor(e/60%60),o=Math.floor(e/3600),a=Math.floor(r/60%60),n=Math.floor(r/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(o=s=i=l="-"),r>0&&r<t?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",(o=o>0||n>0?o+":":"")+(s=((o||a>=10)&&s<10?"0"+s:s)+":")+(i=i<10?"0"+i:i)+l},e.exports=r.default},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default={debug:!1,msDisplayMax:3},e.exports=r.default},function(e,r,t){(function(r){var t;t="undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:{},e.exports=t}).call(this,t(6))},function(e,r){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(r,t){r.exports=e},function(e,t){e.exports=r},function(e,r,t){}])});
//# sourceMappingURL=videojs.wavesurfer.min.js.map
|