videojs-wavesurfer
Advanced tools
Comparing version 2.1.2 to 2.1.3
videojs-wavesurfer changelog | ||
============================ | ||
2.1.3 - unreleased | ||
------------------ | ||
- Bump required wavesurfer.js version to 2.0.1 | ||
2.1.2 - 2017/12/13 | ||
@@ -5,0 +11,0 @@ ------------------ |
/** | ||
* videojs-wavesurfer | ||
* @version 2.1.2 | ||
* @version 2.1.3 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -694,11 +694,10 @@ * @copyright 2014-2017 Collab | ||
ajax.on('success', function (data, e) { | ||
if (e.target.status == 200) { | ||
_this2.log('Loading URL: ' + url + '\nLoading Peak Data URL: ' + peakUrl); | ||
_this2.surfer.load(url, data.data); | ||
} else { | ||
_this2.log('Unable to retrieve peak data from ' + peakUrl + '. Status code: ' + e.target.status); | ||
_this2.log('Loading URL: ' + url); | ||
_this2.surfer.load(url); | ||
} | ||
_this2.log('Loading URL: ' + url + '\nLoading Peak Data URL: ' + peakUrl); | ||
_this2.surfer.load(url, data.data); | ||
}); | ||
ajax.on('error', function (e) { | ||
_this2.log('Unable to retrieve peak data from ' + peakUrl + '. Status code: ' + e.target.status, 'warn'); | ||
_this2.log('Loading URL: ' + url); | ||
_this2.surfer.load(url); | ||
}); | ||
} else { | ||
@@ -1179,3 +1178,3 @@ this.log('Loading URL: ' + url); | ||
Wavesurfer.VERSION = '2.1.2'; | ||
Wavesurfer.VERSION = '2.1.3'; | ||
@@ -1182,0 +1181,0 @@ // register plugin |
/** | ||
* videojs-wavesurfer | ||
* @version 2.1.2 | ||
* @version 2.1.3 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -8,2 +8,2 @@ * @copyright 2014-2017 Collab | ||
*/ | ||
!function e(t,r,i){function o(a,n){if(!r[a]){if(!t[a]){var l="function"==typeof require&&require;if(!n&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[a]={exports:{}};t[a][0].call(h.exports,function(e){var r=t[a][1][e];return o(r||e)},h,h.exports,e,t,r,i)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a<i.length;a++)o(i[a]);return o}({1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default={debug:!1,msDisplayMax:3}},{}],2:[function(e,t,r){"use strict";function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(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)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=function e(t,r,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,r,i)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(i)},a=videojs.getTech("Html5"),n=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e.nativeTextTracks=!1;var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return o.activePlayer=videojs(e.playerId),o.waveready=!1,o.activePlayer.on("waveReady",function(){o.waveready=!0}),o.playerIsUsingWavesurfer()?(o.activePlayer.activeWavesurferPlugin.on("timeupdate",function(){o.trigger("timeupdate")}),o):i(o)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a),o(t,[{key:"playerIsUsingWavesurfer",value:function(){var e=videojs.getPlugins();return"wavesurfer"in e&&!("record"in e)}},{key:"play",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.play():s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"play",this).call(this)}},{key:"pause",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.pause():s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"pause",this).call(this)}},{key:"currentTime",value:function(){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.getCurrentTime():0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"currentTime",this).call(this)}},{key:"duration",value:function(){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.getDuration():0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"duration",this).call(this)}},{key:"setCurrentTime",value:function(e){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.surfer.seekTo(e/this.activePlayer.activeWavesurferPlugin.surfer.getDuration()):0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"currentTime",this).call(this,e)}},{key:"setPlaybackRate",value:function(e){return this.playerIsUsingWavesurfer()&&this.activePlayer.activeWavesurferPlugin.surfer.setPlaybackRate(e),s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setPlaybackRate",this).call(this,e)}}]),t}();n.isSupported=function(){return!0},r.default=n},{}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,t,r){e=e<0?0:e,t=t||e;var i=Math.floor(e%60),o=Math.floor(e/60%60),s=Math.floor(e/3600),a=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(s=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",s=s>0||n>0?s+":":"",o=((s||a>=10)&&o<10?"0"+o:o)+":",i=i<10?"0"+i:i,s+o+i+l}},{}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,t,r){!0===r&&("error"===t?videojs.log.error(e):"warn"===t?videojs.log.warn(e):videojs.log(e))}},{}],5:[function(e,t,r){(function(e){var r;r="undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,r){(function(r){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var s=function(){function e(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)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=i(e(4)),n=i(e(3)),l=i(e(1)),u=i(e(2)),h=i(e(5)),f=i("undefined"!=typeof window?window.videojs:void 0!==r?r.videojs:null),p=i("undefined"!=typeof window?window.WaveSurfer:void 0!==r?r.WaveSurfer:null),c=f.default.getPlugin("plugin"),y="vjs-wavedisplay",d=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));if(r=f.default.mergeOptions(l.default,r),i.waveReady=!1,i.waveFinished=!1,i.liveMode=!1,i.debug="true"===r.debug.toString(),i.msDisplayMax=parseFloat(r.msDisplayMax),i.player.activeWavesurferPlugin=i,void 0!==i.player.options_.plugins.wavesurfer&&i.player.addClass("videojs-wavesurfer"),"live"===r.src){if(void 0===p.default.microphone)return i.onWaveError("Could not find wavesurfer.js microphone plugin!"),o(i);i.liveMode=!0,i.waveReady=!0}return i.player.one("ready",i.initialize.bind(i)),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,c),s(t,[{key:"initialize",value:function(){if(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=p.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)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=y,this.responsiveWave=p.default.util.debounce(this.onResizeChange.bind(this),150),h.default.addEventListener("resize",this.responsiveWave)),this.startPlayers()}},{key:"parseOptions",value:function(e){var 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=opts.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),!0===this.liveMode&&(e.plugins=[p.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,t){var r=this;if(e instanceof Blob||e instanceof File)this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e);else if(void 0!==t){p.default.util.ajax({url:t,responseType:"json"}).on("success",function(i,o){200==o.target.status?(r.log("Loading URL: "+e+"\nLoading Peak Data URL: "+t),r.surfer.load(e,i.data)):(r.log("Unable to retrieve peak data from "+t+". Status code: "+o.target.status),r.log("Loading URL: "+e),r.surfer.load(e))})}else this.log("Loading URL: "+e),this.surfer.load(e)}},{key:"play",value:function(){if(this.player.controlBar.playToggle.handlePlay(),this.liveMode)if(this.surfer.microphone.active){!this.surfer.microphone.paused?this.pause():(this.log("Resume microphone"),this.surfer.microphone.play())}else this.log("Start microphone"),this.surfer.microphone.start();else this.log("Start playback"),this.player.play(),this.surfer.play()}},{key:"pause",value:function(){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.liveMode&&this.surfer.microphone&&(this.surfer.microphone.destroy(),this.log("Destroyed microphone plugin")),this.surfer.destroy(),this.log("Destroyed plugin")}},{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){return this.surfer.exportImage(e,t)}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){this.trigger("timeupdate"),void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t;var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,n.default)(r,t,this.msDisplayMax)}},{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.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,n.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.show(),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,t=this.player.setInterval(function(){var r=void 0,i=void 0;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){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=y,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}},{key:"log",value:function(e,t){(0,a.default)(e,t,this.debug)}}]),t}();d.VERSION="2.1.2",f.default.Wavesurfer=d,f.default.registerPlugin("wavesurfer",d),f.default.registerTech("Html5",u.default),t.exports={Wavesurfer:d}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[6]); | ||
!function e(t,r,i){function o(a,n){if(!r[a]){if(!t[a]){var l="function"==typeof require&&require;if(!n&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[a]={exports:{}};t[a][0].call(h.exports,function(e){var r=t[a][1][e];return o(r||e)},h,h.exports,e,t,r,i)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a<i.length;a++)o(i[a]);return o}({1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default={debug:!1,msDisplayMax:3}},{}],2:[function(e,t,r){"use strict";function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(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)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=function e(t,r,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,r,i)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(i)},a=videojs.getTech("Html5"),n=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e.nativeTextTracks=!1;var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return o.activePlayer=videojs(e.playerId),o.waveready=!1,o.activePlayer.on("waveReady",function(){o.waveready=!0}),o.playerIsUsingWavesurfer()?(o.activePlayer.activeWavesurferPlugin.on("timeupdate",function(){o.trigger("timeupdate")}),o):i(o)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a),o(t,[{key:"playerIsUsingWavesurfer",value:function(){var e=videojs.getPlugins();return"wavesurfer"in e&&!("record"in e)}},{key:"play",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.play():s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"play",this).call(this)}},{key:"pause",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.pause():s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"pause",this).call(this)}},{key:"currentTime",value:function(){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.getCurrentTime():0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"currentTime",this).call(this)}},{key:"duration",value:function(){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.getDuration():0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"duration",this).call(this)}},{key:"setCurrentTime",value:function(e){return this.playerIsUsingWavesurfer()?this.waveready?this.activePlayer.activeWavesurferPlugin.surfer.seekTo(e/this.activePlayer.activeWavesurferPlugin.surfer.getDuration()):0:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"currentTime",this).call(this,e)}},{key:"setPlaybackRate",value:function(e){return this.playerIsUsingWavesurfer()&&this.activePlayer.activeWavesurferPlugin.surfer.setPlaybackRate(e),s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setPlaybackRate",this).call(this,e)}}]),t}();n.isSupported=function(){return!0},r.default=n},{}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,t,r){e=e<0?0:e,t=t||e;var i=Math.floor(e%60),o=Math.floor(e/60%60),s=Math.floor(e/3600),a=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(s=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",s=s>0||n>0?s+":":"",o=((s||a>=10)&&o<10?"0"+o:o)+":",i=i<10?"0"+i:i,s+o+i+l}},{}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default=function(e,t,r){!0===r&&("error"===t?videojs.log.error(e):"warn"===t?videojs.log.warn(e):videojs.log(e))}},{}],5:[function(e,t,r){(function(e){var r;r="undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,r){(function(r){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var s=function(){function e(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)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=i(e(4)),n=i(e(3)),l=i(e(1)),u=i(e(2)),h=i(e(5)),f=i("undefined"!=typeof window?window.videojs:void 0!==r?r.videojs:null),p=i("undefined"!=typeof window?window.WaveSurfer:void 0!==r?r.WaveSurfer:null),c=f.default.getPlugin("plugin"),y="vjs-wavedisplay",d=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));if(r=f.default.mergeOptions(l.default,r),i.waveReady=!1,i.waveFinished=!1,i.liveMode=!1,i.debug="true"===r.debug.toString(),i.msDisplayMax=parseFloat(r.msDisplayMax),i.player.activeWavesurferPlugin=i,void 0!==i.player.options_.plugins.wavesurfer&&i.player.addClass("videojs-wavesurfer"),"live"===r.src){if(void 0===p.default.microphone)return i.onWaveError("Could not find wavesurfer.js microphone plugin!"),o(i);i.liveMode=!0,i.waveReady=!0}return i.player.one("ready",i.initialize.bind(i)),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,c),s(t,[{key:"initialize",value:function(){if(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=p.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)),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className=y,this.responsiveWave=p.default.util.debounce(this.onResizeChange.bind(this),150),h.default.addEventListener("resize",this.responsiveWave)),this.startPlayers()}},{key:"parseOptions",value:function(e){var 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=opts.waveformHeight;return e.splitChannels&&!0===e.splitChannels&&(e.height/=2),!0===this.liveMode&&(e.plugins=[p.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,t){var r=this;if(e instanceof Blob||e instanceof File)this.log("Loading object: "+JSON.stringify(e)),this.surfer.loadBlob(e);else if(void 0!==t){var i=p.default.util.ajax({url:t,responseType:"json"});i.on("success",function(i,o){r.log("Loading URL: "+e+"\nLoading Peak Data URL: "+t),r.surfer.load(e,i.data)}),i.on("error",function(i){r.log("Unable to retrieve peak data from "+t+". Status code: "+i.target.status,"warn"),r.log("Loading URL: "+e),r.surfer.load(e)})}else this.log("Loading URL: "+e),this.surfer.load(e)}},{key:"play",value:function(){if(this.player.controlBar.playToggle.handlePlay(),this.liveMode)if(this.surfer.microphone.active){!this.surfer.microphone.paused?this.pause():(this.log("Resume microphone"),this.surfer.microphone.play())}else this.log("Start microphone"),this.surfer.microphone.start();else this.log("Start playback"),this.player.play(),this.surfer.play()}},{key:"pause",value:function(){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.liveMode&&this.surfer.microphone&&(this.surfer.microphone.destroy(),this.log("Destroyed microphone plugin")),this.surfer.destroy(),this.log("Destroyed plugin")}},{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){return this.surfer.exportImage(e,t)}},{key:"getCurrentTime",value:function(){var e=this.surfer.getCurrentTime();return e=isNaN(e)?0:e}},{key:"setCurrentTime",value:function(e,t){this.trigger("timeupdate"),void 0===e&&(e=this.surfer.getCurrentTime()),void 0===t&&(t=this.surfer.getDuration()),e=isNaN(e)?0:e,t=isNaN(t)?0:t;var r=Math.min(e,t);this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,n.default)(r,t,this.msDisplayMax)}},{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.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,n.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.show(),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,t=this.player.setInterval(function(){var r=void 0,i=void 0;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){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=y,this.surfer.drawBuffer(),this.surfer.drawer.progress(this.surfer.backend.getPlayedPercents())}},{key:"log",value:function(e,t){(0,a.default)(e,t,this.debug)}}]),t}();d.VERSION="2.1.3",f.default.Wavesurfer=d,f.default.registerPlugin("wavesurfer",d),f.default.registerTech("Html5",u.default),t.exports={Wavesurfer:d}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[6]); |
@@ -326,11 +326,10 @@ 'use strict'; | ||
ajax.on('success', function (data, e) { | ||
if (e.target.status == 200) { | ||
_this2.log('Loading URL: ' + url + '\nLoading Peak Data URL: ' + peakUrl); | ||
_this2.surfer.load(url, data.data); | ||
} else { | ||
_this2.log('Unable to retrieve peak data from ' + peakUrl + '. Status code: ' + e.target.status); | ||
_this2.log('Loading URL: ' + url); | ||
_this2.surfer.load(url); | ||
} | ||
_this2.log('Loading URL: ' + url + '\nLoading Peak Data URL: ' + peakUrl); | ||
_this2.surfer.load(url, data.data); | ||
}); | ||
ajax.on('error', function (e) { | ||
_this2.log('Unable to retrieve peak data from ' + peakUrl + '. Status code: ' + e.target.status, 'warn'); | ||
_this2.log('Loading URL: ' + url); | ||
_this2.surfer.load(url); | ||
}); | ||
} else { | ||
@@ -337,0 +336,0 @@ this.log('Loading URL: ' + url); |
{ | ||
"name": "videojs-wavesurfer", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "video.js plugin that adds a navigable waveform for audio and video files.", | ||
@@ -89,3 +89,3 @@ "author": "Collab", | ||
"video.js": ">=6.0.0", | ||
"wavesurfer.js": "^2.0.0-beta02" | ||
"wavesurfer.js": ">=2.0.1" | ||
}, | ||
@@ -111,6 +111,6 @@ "devDependencies": { | ||
"jsdoc": "^3.5.5", | ||
"moment": "^2.19.4", | ||
"moment": "^2.20.1", | ||
"mv": "^2.1.1", | ||
"node-sass": "^4.6.1", | ||
"nodemon": "^1.12.6", | ||
"nodemon": "^1.14.2", | ||
"npm-run-all": "^4.1.2", | ||
@@ -117,0 +117,0 @@ "portscanner": "^2.1.1", |
@@ -280,13 +280,12 @@ /** | ||
ajax.on('success', (data, e) => { | ||
if (e.target.status == 200) { | ||
this.log('Loading URL: ' + url + | ||
'\nLoading Peak Data URL: ' + peakUrl); | ||
this.surfer.load(url, data.data); | ||
} else { | ||
this.log('Unable to retrieve peak data from ' + peakUrl + | ||
'. Status code: ' + e.target.status); | ||
this.log('Loading URL: ' + url); | ||
this.surfer.load(url); | ||
} | ||
this.log('Loading URL: ' + url + | ||
'\nLoading Peak Data URL: ' + peakUrl); | ||
this.surfer.load(url, data.data); | ||
}); | ||
ajax.on('error', (e) => { | ||
this.log('Unable to retrieve peak data from ' + peakUrl + | ||
'. Status code: ' + e.target.status, 'warn'); | ||
this.log('Loading URL: ' + url); | ||
this.surfer.load(url); | ||
}); | ||
} else { | ||
@@ -293,0 +292,0 @@ this.log('Loading URL: ' + url); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
182713
3105
+ Addedwavesurfer.js@7.8.8(transitive)
- Removedwavesurfer.js@2.2.1(transitive)
Updatedwavesurfer.js@>=2.0.1