Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

videojs-wavesurfer

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-wavesurfer - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

5

CHANGES.md
# videojs-wavesurfer changelog
## 3.7.0 - 2021/03/23
- Remove unneccessary resize handler for `fluid` mode (#132)
## 3.6.0 - 2021/03/06

@@ -4,0 +9,0 @@

19

dist/videojs.wavesurfer.js
/*!
* videojs-wavesurfer
* @version 3.6.0
* @version 3.7.0
* @see https://github.com/collab-project/videojs-wavesurfer

@@ -359,4 +359,5 @@ * @copyright 2014-2021 Collab

/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }

@@ -566,5 +567,2 @@ /******/ // Create a new module (and put it into the cache)

this.surfer.drawer.wrapper.className = wavesurferClassName;
this.responsiveWave = _wavesurfer.default.util.debounce(this.onResizeChange.bind(this), 150);
_window.default.addEventListener(_event.default.RESIZE, this.responsiveWave);
}

@@ -971,9 +969,2 @@ }

}, {
key: "onResizeChange",
value: function onResizeChange() {
if (this.surfer !== undefined) {
this.redrawWaveform();
}
}
}, {
key: "redrawWaveform",

@@ -1021,3 +1012,3 @@ value: function redrawWaveform(newWidth, newHeight) {

exports.Wavesurfer = Wavesurfer;
Wavesurfer.VERSION = "3.6.0";
Wavesurfer.VERSION = "3.7.0";
_video.default.Wavesurfer = Wavesurfer;

@@ -1024,0 +1015,0 @@

/*!
* videojs-wavesurfer
* @version 3.6.0
* @version 3.7.0
* @see https://github.com/collab-project/videojs-wavesurfer

@@ -8,2 +8,2 @@ * @copyright 2014-2021 Collab

*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("video.js"),require("wavesurfer.js")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["video.js","wavesurfer.js"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("video.js"),require("wavesurfer.js")):e.VideojsWavesurfer=t(e.videojs,e.WaveSurfer)}(self,(function(e,t){return(()=>{var r={21:function(e,t,r){var i;!function(t){"use strict";function a(e,t){t=t||2;var r,i=Number(e)<0,a=e.toString();return i&&(a=a.slice(1)),r=t-a.length+1,(i?"-":"")+(a=new Array(r).join("0").concat(a))}void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}(this)},997:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={debug:!1,displayMilliseconds:!0};t.default=r,e.exports=t.default},537:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};r.READY="ready",r.ERROR="error",r.VOLUMECHANGE="volumechange",r.FULLSCREENCHANGE="fullscreenchange",r.TIMEUPDATE="timeupdate",r.ENDED="ended",r.PAUSE="pause",r.FINISH="finish",r.SEEK="seek",r.REDRAW="redraw",r.AUDIOPROCESS="audioprocess",r.DEVICE_READY="deviceReady",r.DEVICE_ERROR="deviceError",r.AUDIO_OUTPUT_READY="audioOutputReady",r.WAVE_READY="waveReady",r.PLAYBACK_FINISH="playbackFinish",r.ABORT="abort",r.RESIZE="resize",Object.freeze(r);var i=r;t.default=i,e.exports=t.default},200:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={setSource:function(e,t){if(this.player.usingPlugin("wavesurfer")){var r=this.player.wavesurfer().surfer.params.backend,i=e.src,a=e.peaks;switch(r){case"WebAudio":this.player.wavesurfer().load(i);break;default:t(null,e);var o=this.player.tech_.el();void 0===a?this.player.wavesurfer().load(o):this.player.wavesurfer().load(o,a)}}else t(null,e)}};t.default=r,e.exports=t.default},518:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(r(21)),a=o(r(455));function o(e){return e&&e.__esModule?e:{default:e}}var s=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=e<0?0:e,(isNaN(e)||e===1/0)&&(e=0);var o=(0,a.default)(1e3*e),s=o;void 0!==t&&(s=(0,a.default)(1e3*t));var n=(0,i.default)(o.hours),l=(0,i.default)(o.minutes),u=(0,i.default)(o.seconds),h=(0,i.default)(o.milliseconds,3);if(o.days>0||s.days>0){var c=(0,i.default)(o.days);return"".concat(c,":").concat(n,":").concat(l,":").concat(u)}return o.hours>0||s.hours>0?"".concat(n,":").concat(l,":").concat(u):r?"".concat(l,":").concat(u,":").concat(h):"".concat(l,":").concat(u)};t.default=s,e.exports=t.default},456:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,a=(i=r(390))&&i.__esModule?i:{default:i};var o=function(e,t,r){!0===r&&("error"===t?a.default.log.error(e):"warn"===t?a.default.log.warn(e):a.default.log(e))};t.default=o,e.exports=t.default},908:(e,t,r)=>{var i;i="undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},e.exports=i},455:e=>{"use strict";e.exports=e=>{if("number"!=typeof e)throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(1e3*e)%1e3,nanoseconds:t(1e6*e)%1e3}}},390:t=>{"use strict";t.exports=e},410:e=>{"use strict";e.exports=t}},i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={exports:{}};return r[e].call(t.exports,t,t.exports,a),t.exports}a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o={};return(()=>{"use strict";var e=o;function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Wavesurfer=void 0;var r=d(a(537)),i=d(a(456)),s=d(a(518)),n=d(a(997)),l=d(a(200)),u=d(a(908)),h=d(a(390)),c=d(a(410));function d(e){return e&&e.__esModule?e:{default:e}}function f(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(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 r,i=m(e);if(t){var a=m(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return v(this,r)}}function v(e,r){return!r||"object"!==t(r)&&"function"!=typeof r?g(e):r}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var b=h.default.getPlugin("plugin"),E="wavesurfer",k="vjs-wavedisplay",w="WebAudio",R="MediaElement",T=function(e){!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&&p(e,t)}(d,e);var t,a,o,l=y(d);function d(e,t){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),i=l.call(this,e,t),e.addClass("vjs-wavesurfer"),t=h.default.mergeOptions(n.default,t),i.waveReady=!1,i.waveFinished=!1,i.liveMode=!1,i.backend=null,i.debug="true"===t.debug.toString(),i.textTracksEnabled=i.player.options_.tracks.length>0,i.displayMilliseconds=t.displayMilliseconds,t.formatTime&&"function"==typeof t.formatTime?i.setFormatTime(t.formatTime):i.setFormatTime((function(e,t){return(0,s.default)(e,t,i.displayMilliseconds)})),i.player.one(r.default.READY,i.initialize.bind(g(i))),i}return t=d,(a=[{key:"initialize",value:function(){var e=this;void 0!==this.player.bigPlayButton&&this.player.bigPlayButton.hide();var t=this.parseOptions(this.player.options_.plugins.wavesurfer);!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",this.backend===w&&void 0!==this.player.controlBar.progressControl&&this.player.controlBar.progressControl.hide(),void 0!==this.player.controlBar.pictureInPictureToggle&&this.player.controlBar.pictureInPictureToggle.hide(),["currentTimeDisplay","timeDivider","durationDisplay"].forEach((function(t){void 0!==(t=e.player.controlBar[t])&&(t.el_.style.display="block",t.show())})),void 0!==this.player.controlBar.remainingTimeDisplay&&this.player.controlBar.remainingTimeDisplay.hide(),this.backend===w&&void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.player.controlBar.playToggle.hide())),this.surfer=c.default.create(t),this.surfer.on(r.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(r.default.FINISH,this.onWaveFinish.bind(this)),this.backend=this.surfer.params.backend,this.log("Using wavesurfer.js "+this.backend+" backend."),"microphone"in this.player.wavesurfer().surfer.getActivePlugins()&&(this.liveMode=!0,this.waveReady=!0,this.log("wavesurfer.js microphone plugin enabled."),this.player.controlBar.playToggle.show(),this.surfer.microphone.on(r.default.DEVICE_ERROR,this.onWaveError.bind(this))),this.surferReady=this.onWaveReady.bind(this),this.backend===w&&(this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.player.muted()&&this.setVolume(0)),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(r.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(r.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=k,this.responsiveWave=c.default.util.debounce(this.onResizeChange.bind(this),150),u.default.addEventListener(r.default.RESIZE,this.responsiveWave))}},{key:"parseOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.player.el_.getBoundingClientRect();this.originalWidth=this.player.options_.width||t.width,this.originalHeight=this.player.options_.height||t.height;var r=this.player.controlBar.height();if(!0===this.player.options_.controls&&0===r&&(r=30),void 0===e.container&&(e.container=this.player.el_),void 0===e.waveformHeight){var i=t.height;e.height=i-r}else e.height=e.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),"backend"in e?this.backend=e.backend:e.backend=this.backend=R,e}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(r.default.READY,this.surferReady),this.backend===w&&(this.surfer.un(r.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(r.default.SEEK,this.surferSeek))):!0===e&&(this.surfer.on(r.default.READY,this.surferReady),this.backend===w&&(this.surfer.on(r.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(r.default.SEEK,this.surferSeek)))}},{key:"load",value:function(e,t){e instanceof Blob||e instanceof File?(this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e)):void 0!==t?this.loadPeaks(e,t):("string"==typeof e?this.log("Loading URL: "+e):this.log("Loading element: "+e),this.surfer.load(e))}},{key:"loadPeaks",value:function(e,t){var i=this;if(Array.isArray(t))this.log("Loading URL with array of peaks: "+e),this.surfer.load(e,t);else{var a={url:t,responseType:"json"};void 0!==this.player.options_.plugins.wavesurfer.xhr&&(a.xhr=this.player.options_.plugins.wavesurfer.xhr);var o=c.default.util.fetchFile(a);o.once("success",(function(a){i.log("Loaded Peak Data URL: "+t),a&&a.data?i.surfer.load(e,a.data):(i.player.trigger(r.default.ERROR,"Could not load peaks data from "+t),i.log(err,"error"))})),o.once("error",(function(e){i.player.trigger(r.default.ERROR,"Unable to retrieve peak data from "+t+". Status code: "+o.response.status)}))}}},{key:"play",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePlay(),this.liveMode?this.surfer.microphone.active?this.surfer.microphone.paused?(this.log("Resume microphone"),this.surfer.microphone.play()):this.pause():(this.log("Start microphone"),this.surfer.microphone.start()):(this.log("Start playback"),this.player.play(),this.surfer.play())}},{key:"pause",value:function(){void 0!==this.player.controlBar.playToggle&&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.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,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"blob";return this.surfer.exportImage(e,t,r)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(r.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(r.default.ERROR,e),t.log(e,"error")}))}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){if(void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t,this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.contentEl()&&this.player.controlBar.currentTimeDisplay.contentEl().lastChild){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=this._formatTime(r,t,this.displayMilliseconds)}this.textTracksEnabled&&this.player.tech_&&this.player.tech_.el_&&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&&this.player.controlBar.durationDisplay.contentEl()&&this.player.controlBar.durationDisplay.contentEl().lastChild&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=this._formatTime(e,e,this.displayMilliseconds))}},{key:"onWaveReady",value:function(){var e=this;this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(r.default.WAVE_READY),this.backend===w&&(this.setCurrentTime(),this.setDuration(),void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.show()),this.player.loadingSpinner.contentEl()&&this.player.loadingSpinner.hide(),!0===this.player.options_.autoplay&&(this.setVolume(0),this.backend===w?this.play():this.player.play().catch((function(t){e.onWaveError(t)})))}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(r.default.PLAYBACK_FINISH),!0===this.player.options_.loop?this.backend===w&&(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.backend===w&&(this.pause(),this.player.trigger(r.default.ENDED),this.surfer.once(r.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(r.default.PAUSE)}))))}},{key:"onWaveProgress",value:function(e){this.setCurrentTime()}},{key:"onWaveSeek",value:function(){this.setCurrentTime()}},{key:"onWaveError",value:function(e){e.name&&"AbortError"===e.name||"DOMException"===e.name&&e.message.startsWith("The operation was aborted")?this.player.trigger(r.default.ABORT,e):(this.player.trigger(r.default.ERROR,e),this.log(e,"error"))}},{key:"onPlayToggle",value:function(){void 0!==this.player.controlBar.playToggle&&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,t=this.player.setInterval((function(){var r,i;if(e.player.isFullscreen()||(r=e.originalWidth,i=e.originalHeight),e.waveReady){if(e.liveMode&&!e.surfer.microphone.active)return;e.redrawWaveform(r,i)}e.player.clearInterval(t)}),100)}},{key:"onResizeChange",value:function(){void 0!==this.surfer&&this.redrawWaveform()}},{key:"redrawWaveform",value:function(e,t){if(!this.isDestroyed()){if(this.player.el_){var r=this.player.el_.getBoundingClientRect();void 0===e&&(e=r.width),void 0===t&&(t=r.height)}this.surfer.drawer.destroy(),this.surfer.params.width=e,this.surfer.params.height=t-this.player.controlBar.height(),this.surfer.createDrawer(),this.surfer.drawer.wrapper.className=k,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,i.default)(e,t,this.debug)}},{key:"setFormatTime",value:function(e){this._formatTime=e,h.default.setFormatTime(this._formatTime)}}])&&f(t.prototype,a),o&&f(t,o),d}(b);e.Wavesurfer=T,T.VERSION="3.6.0",h.default.Wavesurfer=T,void 0===h.default.getPlugin(E)&&h.default.registerPlugin(E,T),h.default.use("*",(function(e){return l.default.player=e,l.default}))})(),o})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("video.js"),require("wavesurfer.js")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["video.js","wavesurfer.js"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("video.js"),require("wavesurfer.js")):e.VideojsWavesurfer=t(e.videojs,e.WaveSurfer)}(self,(function(e,t){return(()=>{var r={21:function(e,t,r){var i;!function(t){"use strict";function a(e,t){t=t||2;var r,i=Number(e)<0,a=e.toString();return i&&(a=a.slice(1)),r=t-a.length+1,(i?"-":"")+(a=new Array(r).join("0").concat(a))}void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}(this)},997:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={debug:!1,displayMilliseconds:!0};t.default=r,e.exports=t.default},537:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};r.READY="ready",r.ERROR="error",r.VOLUMECHANGE="volumechange",r.FULLSCREENCHANGE="fullscreenchange",r.TIMEUPDATE="timeupdate",r.ENDED="ended",r.PAUSE="pause",r.FINISH="finish",r.SEEK="seek",r.REDRAW="redraw",r.AUDIOPROCESS="audioprocess",r.DEVICE_READY="deviceReady",r.DEVICE_ERROR="deviceError",r.AUDIO_OUTPUT_READY="audioOutputReady",r.WAVE_READY="waveReady",r.PLAYBACK_FINISH="playbackFinish",r.ABORT="abort",r.RESIZE="resize",Object.freeze(r);var i=r;t.default=i,e.exports=t.default},200:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={setSource:function(e,t){if(this.player.usingPlugin("wavesurfer")){var r=this.player.wavesurfer().surfer.params.backend,i=e.src,a=e.peaks;switch(r){case"WebAudio":this.player.wavesurfer().load(i);break;default:t(null,e);var o=this.player.tech_.el();void 0===a?this.player.wavesurfer().load(o):this.player.wavesurfer().load(o,a)}}else t(null,e)}};t.default=r,e.exports=t.default},518:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(r(21)),a=o(r(455));function o(e){return e&&e.__esModule?e:{default:e}}var s=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=e<0?0:e,(isNaN(e)||e===1/0)&&(e=0);var o=(0,a.default)(1e3*e),s=o;void 0!==t&&(s=(0,a.default)(1e3*t));var n=(0,i.default)(o.hours),l=(0,i.default)(o.minutes),u=(0,i.default)(o.seconds),h=(0,i.default)(o.milliseconds,3);if(o.days>0||s.days>0){var c=(0,i.default)(o.days);return"".concat(c,":").concat(n,":").concat(l,":").concat(u)}return o.hours>0||s.hours>0?"".concat(n,":").concat(l,":").concat(u):r?"".concat(l,":").concat(u,":").concat(h):"".concat(l,":").concat(u)};t.default=s,e.exports=t.default},456:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,a=(i=r(390))&&i.__esModule?i:{default:i};var o=function(e,t,r){!0===r&&("error"===t?a.default.log.error(e):"warn"===t?a.default.log.warn(e):a.default.log(e))};t.default=o,e.exports=t.default},908:(e,t,r)=>{var i;i="undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},e.exports=i},455:e=>{"use strict";e.exports=e=>{if("number"!=typeof e)throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(1e3*e)%1e3,nanoseconds:t(1e6*e)%1e3}}},390:t=>{"use strict";t.exports=e},410:e=>{"use strict";e.exports=t}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return r[e].call(o.exports,o,o.exports,a),o.exports}a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o={};return(()=>{"use strict";var e=o;function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Wavesurfer=void 0;var r=c(a(537)),i=c(a(456)),s=c(a(518)),n=c(a(997)),l=c(a(200)),u=(c(a(908)),c(a(390))),h=c(a(410));function c(e){return e&&e.__esModule?e:{default:e}}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(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 r,i=g(e);if(t){var a=g(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return y(this,r)}}function y(e,r){return!r||"object"!==t(r)&&"function"!=typeof r?v(e):r}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var m=u.default.getPlugin("plugin"),b="wavesurfer",E="vjs-wavedisplay",k="WebAudio",w="MediaElement",T=function(e){!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&&f(e,t)}(c,e);var t,a,o,l=p(c);function c(e,t){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),i=l.call(this,e,t),e.addClass("vjs-wavesurfer"),t=u.default.mergeOptions(n.default,t),i.waveReady=!1,i.waveFinished=!1,i.liveMode=!1,i.backend=null,i.debug="true"===t.debug.toString(),i.textTracksEnabled=i.player.options_.tracks.length>0,i.displayMilliseconds=t.displayMilliseconds,t.formatTime&&"function"==typeof t.formatTime?i.setFormatTime(t.formatTime):i.setFormatTime((function(e,t){return(0,s.default)(e,t,i.displayMilliseconds)})),i.player.one(r.default.READY,i.initialize.bind(v(i))),i}return t=c,(a=[{key:"initialize",value:function(){var e=this;void 0!==this.player.bigPlayButton&&this.player.bigPlayButton.hide();var t=this.parseOptions(this.player.options_.plugins.wavesurfer);!0===this.player.options_.controls&&(this.player.controlBar.show(),this.player.controlBar.el_.style.display="flex",this.backend===k&&void 0!==this.player.controlBar.progressControl&&this.player.controlBar.progressControl.hide(),void 0!==this.player.controlBar.pictureInPictureToggle&&this.player.controlBar.pictureInPictureToggle.hide(),["currentTimeDisplay","timeDivider","durationDisplay"].forEach((function(t){void 0!==(t=e.player.controlBar[t])&&(t.el_.style.display="block",t.show())})),void 0!==this.player.controlBar.remainingTimeDisplay&&this.player.controlBar.remainingTimeDisplay.hide(),this.backend===k&&void 0!==this.player.controlBar.playToggle&&(this.player.controlBar.playToggle.on(["tap","click"],this.onPlayToggle.bind(this)),this.player.controlBar.playToggle.hide())),this.surfer=h.default.create(t),this.surfer.on(r.default.ERROR,this.onWaveError.bind(this)),this.surfer.on(r.default.FINISH,this.onWaveFinish.bind(this)),this.backend=this.surfer.params.backend,this.log("Using wavesurfer.js "+this.backend+" backend."),"microphone"in this.player.wavesurfer().surfer.getActivePlugins()&&(this.liveMode=!0,this.waveReady=!0,this.log("wavesurfer.js microphone plugin enabled."),this.player.controlBar.playToggle.show(),this.surfer.microphone.on(r.default.DEVICE_ERROR,this.onWaveError.bind(this))),this.surferReady=this.onWaveReady.bind(this),this.backend===k&&(this.surferProgress=this.onWaveProgress.bind(this),this.surferSeek=this.onWaveSeek.bind(this),this.player.muted()&&this.setVolume(0)),this.liveMode||this.setupPlaybackEvents(!0),this.player.on(r.default.VOLUMECHANGE,this.onVolumeChange.bind(this)),this.player.on(r.default.FULLSCREENCHANGE,this.onScreenChange.bind(this)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=E)}},{key:"parseOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.player.el_.getBoundingClientRect();this.originalWidth=this.player.options_.width||t.width,this.originalHeight=this.player.options_.height||t.height;var r=this.player.controlBar.height();if(!0===this.player.options_.controls&&0===r&&(r=30),void 0===e.container&&(e.container=this.player.el_),void 0===e.waveformHeight){var i=t.height;e.height=i-r}else e.height=e.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),"backend"in e?this.backend=e.backend:e.backend=this.backend=w,e}},{key:"setupPlaybackEvents",value:function(e){!1===e?(this.surfer.un(r.default.READY,this.surferReady),this.backend===k&&(this.surfer.un(r.default.AUDIOPROCESS,this.surferProgress),this.surfer.un(r.default.SEEK,this.surferSeek))):!0===e&&(this.surfer.on(r.default.READY,this.surferReady),this.backend===k&&(this.surfer.on(r.default.AUDIOPROCESS,this.surferProgress),this.surfer.on(r.default.SEEK,this.surferSeek)))}},{key:"load",value:function(e,t){e instanceof Blob||e instanceof File?(this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e)):void 0!==t?this.loadPeaks(e,t):("string"==typeof e?this.log("Loading URL: "+e):this.log("Loading element: "+e),this.surfer.load(e))}},{key:"loadPeaks",value:function(e,t){var i=this;if(Array.isArray(t))this.log("Loading URL with array of peaks: "+e),this.surfer.load(e,t);else{var a={url:t,responseType:"json"};void 0!==this.player.options_.plugins.wavesurfer.xhr&&(a.xhr=this.player.options_.plugins.wavesurfer.xhr);var o=h.default.util.fetchFile(a);o.once("success",(function(a){i.log("Loaded Peak Data URL: "+t),a&&a.data?i.surfer.load(e,a.data):(i.player.trigger(r.default.ERROR,"Could not load peaks data from "+t),i.log(err,"error"))})),o.once("error",(function(e){i.player.trigger(r.default.ERROR,"Unable to retrieve peak data from "+t+". Status code: "+o.response.status)}))}}},{key:"play",value:function(){void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.handlePlay(),this.liveMode?this.surfer.microphone.active?this.surfer.microphone.paused?(this.log("Resume microphone"),this.surfer.microphone.play()):this.pause():(this.log("Start microphone"),this.surfer.microphone.start()):(this.log("Start playback"),this.player.play(),this.surfer.play())}},{key:"pause",value:function(){void 0!==this.player.controlBar.playToggle&&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.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,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"blob";return this.surfer.exportImage(e,t,r)}},{key:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then((function(e){t.player.trigger(r.default.AUDIO_OUTPUT_READY)})).catch((function(e){t.player.trigger(r.default.ERROR,e),t.log(e,"error")}))}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){if(void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t,this.player.controlBar.currentTimeDisplay&&this.player.controlBar.currentTimeDisplay.contentEl()&&this.player.controlBar.currentTimeDisplay.contentEl().lastChild){var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=this._formatTime(r,t,this.displayMilliseconds)}this.textTracksEnabled&&this.player.tech_&&this.player.tech_.el_&&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&&this.player.controlBar.durationDisplay.contentEl()&&this.player.controlBar.durationDisplay.contentEl().lastChild&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=this._formatTime(e,e,this.displayMilliseconds))}},{key:"onWaveReady",value:function(){var e=this;this.waveReady=!0,this.waveFinished=!1,this.liveMode=!1,this.log("Waveform is ready"),this.player.trigger(r.default.WAVE_READY),this.backend===k&&(this.setCurrentTime(),this.setDuration(),void 0!==this.player.controlBar.playToggle&&this.player.controlBar.playToggle.contentEl()&&this.player.controlBar.playToggle.show()),this.player.loadingSpinner.contentEl()&&this.player.loadingSpinner.hide(),!0===this.player.options_.autoplay&&(this.setVolume(0),this.backend===k?this.play():this.player.play().catch((function(t){e.onWaveError(t)})))}},{key:"onWaveFinish",value:function(){var e=this;this.log("Finished playback"),this.player.trigger(r.default.PLAYBACK_FINISH),!0===this.player.options_.loop?this.backend===k&&(this.surfer.stop(),this.play()):(this.waveFinished=!0,this.backend===k&&(this.pause(),this.player.trigger(r.default.ENDED),this.surfer.once(r.default.SEEK,(function(){void 0!==e.player.controlBar.playToggle&&e.player.controlBar.playToggle.removeClass("vjs-ended"),e.player.trigger(r.default.PAUSE)}))))}},{key:"onWaveProgress",value:function(e){this.setCurrentTime()}},{key:"onWaveSeek",value:function(){this.setCurrentTime()}},{key:"onWaveError",value:function(e){e.name&&"AbortError"===e.name||"DOMException"===e.name&&e.message.startsWith("The operation was aborted")?this.player.trigger(r.default.ABORT,e):(this.player.trigger(r.default.ERROR,e),this.log(e,"error"))}},{key:"onPlayToggle",value:function(){void 0!==this.player.controlBar.playToggle&&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,t=this.player.setInterval((function(){var r,i;if(e.player.isFullscreen()||(r=e.originalWidth,i=e.originalHeight),e.waveReady){if(e.liveMode&&!e.surfer.microphone.active)return;e.redrawWaveform(r,i)}e.player.clearInterval(t)}),100)}},{key:"redrawWaveform",value:function(e,t){if(!this.isDestroyed()){if(this.player.el_){var r=this.player.el_.getBoundingClientRect();void 0===e&&(e=r.width),void 0===t&&(t=r.height)}this.surfer.drawer.destroy(),this.surfer.params.width=e,this.surfer.params.height=t-this.player.controlBar.height(),this.surfer.createDrawer(),this.surfer.drawer.wrapper.className=E,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}}},{key:"log",value:function(e,t){(0,i.default)(e,t,this.debug)}},{key:"setFormatTime",value:function(e){this._formatTime=e,u.default.setFormatTime(this._formatTime)}}])&&d(t.prototype,a),o&&d(t,o),c}(m);e.Wavesurfer=T,T.VERSION="3.7.0",u.default.Wavesurfer=T,void 0===u.default.getPlugin(b)&&u.default.registerPlugin(b,T),u.default.use("*",(function(e){return l.default.player=e,l.default}))})(),o})()}));
{
"name": "videojs-wavesurfer",
"version": "3.6.0",
"version": "3.7.0",
"description": "video.js plugin that adds a navigable waveform for audio and video files.",

@@ -58,5 +58,6 @@ "author": "Collab",

"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/register": "^7.13.8",
"@chiragrupani/karma-chromium-edge-launcher": "^2.1.0",
"@jsdevtools/host-environment": "^2.1.2",

@@ -69,12 +70,12 @@ "@jsdevtools/karma-host-environment": "^3.0.3",

"browserslist": "^4.16.3",
"css-loader": "^5.1.1",
"css-minimizer-webpack-plugin": "^1.2.0",
"css-loader": "^5.1.3",
"css-minimizer-webpack-plugin": "^1.3.0",
"date-fns": "^2.19.0",
"docsify-cli": "^4.4.2",
"docsify-cli": "^4.4.3",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
"eslint": "^7.21.0",
"eslint": "^7.22.0",
"htmlhint": "^0.14.2",
"in-publish": "^2.0.1",
"jasmine-core": "^3.6.0",
"jasmine-core": "^3.7.1",
"karma": "^5.2.3",

@@ -97,3 +98,3 @@ "karma-chrome-launcher": "^3.1.0",

"style-loader": "^2.0.0",
"webpack": "^5.24.3",
"webpack": "^5.27.1",
"webpack-cli": "^4.5.0",

@@ -103,4 +104,4 @@ "webpack-dev-server": "^4.0.0-beta.0",

"webpack-remove-empty-scripts": "^0.7.1",
"webrtc-adapter": "^7.7.0"
"webrtc-adapter": "^7.7.1"
}
}

@@ -182,6 +182,2 @@ /**

this.surfer.drawer.wrapper.className = wavesurferClassName;
// listen for window resize events
this.responsiveWave = WaveSurfer.util.debounce(
this.onResizeChange.bind(this), 150);
window.addEventListener(Event.RESIZE, this.responsiveWave);
}

@@ -775,14 +771,2 @@ }

/**
* Fired when the video.js player is resized.
*
* @private
*/
onResizeChange() {
if (this.surfer !== undefined) {
// redraw waveform
this.redrawWaveform();
}
}
/**
* Redraw waveform.

@@ -789,0 +773,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc