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 2.2.0 to 2.2.1

6

CHANGES.md
videojs-wavesurfer changelog
============================
2.2.1 - 2018/02/20
------------------
- Fix tech for compatibility with video.js 6.7.x (#49 by @mfairchild365)
2.2.0 - 2018/01/23

@@ -5,0 +11,0 @@ ------------------

4

dist/videojs.wavesurfer.min.js
/**
* videojs-wavesurfer
* @version 2.2.0
* @version 2.2.1
* @see https://github.com/collab-project/videojs-wavesurfer

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

*/
!function e(t,r,i){function o(s,n){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!n&&l)return l(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return o(r||e)},h,h.exports,e,t,r,i)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);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";Object.defineProperty(r,"__esModule",{value:!0});var i=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}}(),o=function e(t,r,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,i)}if("value"in o)return o.value;var s=o.get;return void 0!==s?s.call(i):void 0};function a(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=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 i=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return i.activePlayer=videojs(e.playerId),i.waveready=!1,i.activePlayer.on("waveReady",function(){i.waveready=!0}),i.playerIsUsingWavesurfer()?(i.activePlayer.activeWavesurferPlugin.on("timeupdate",function(){i.trigger("timeupdate")}),i):a(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,s),i(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():o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"play",this).call(this)}},{key:"pause",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.pause():o(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:o(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:o(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:o(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),o(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),a=Math.floor(e/3600),s=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(a=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",(a=a>0||n>0?a+":":"")+(o=((a||s>=10)&&o<10?"0"+o:o)+":")+(i=i<10?"0"+i: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";var i=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}}(),o=p(e(4)),a=p(e(3)),s=p(e(1)),n=p(e(2)),l=p(e(5)),u=p("undefined"!=typeof window?window.videojs:void 0!==r?r.videojs:null),h=p("undefined"!=typeof window?window.WaveSurfer:void 0!==r?r.WaveSurfer:null);function p(e){return e&&e.__esModule?e:{default:e}}function f(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 c=u.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=f(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));if(r=u.default.mergeOptions(s.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===h.default.microphone)return i.onWaveError("Could not find wavesurfer.js microphone plugin!"),f(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),i(t,[{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=h.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=h.default.util.debounce(this.onResizeChange.bind(this),150),l.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=[h.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=h.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(){(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.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:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then(function(e){t.player.trigger("audioOutputReady")}).catch(function(e){t.player.trigger("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){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,a.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,a.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,o.default)(e,t,this.debug)}}]),t}();d.VERSION="2.2.0",u.default.Wavesurfer=d,u.default.registerPlugin("wavesurfer",d),u.default.registerTech("Html5",n.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(s,n){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!n&&l)return l(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return o(r||e)},h,h.exports,e,t,r,i)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);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";Object.defineProperty(r,"__esModule",{value:!0});var i=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}}(),o=function e(t,r,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,i)}if("value"in o)return o.value;var s=o.get;return void 0!==s?s.call(i):void 0};var a=videojs.getTech("Html5"),s=function(e){function t(e,r){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e.nativeTextTracks=!1,function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}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),i(t,[{key:"setActivePlayer",value:function(e){var t=this;this.activePlayer=e,this.waveready=!1,this.activePlayer.on("waveReady",function(){t.waveready=!0}),this.playerIsUsingWavesurfer()&&this.activePlayer.activeWavesurferPlugin.on("timeupdate",function(){t.trigger("timeupdate")})}},{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():o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"play",this).call(this)}},{key:"pause",value:function(){return this.playerIsUsingWavesurfer()?this.activePlayer.activeWavesurferPlugin.pause():o(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:o(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:o(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:o(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),o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setPlaybackRate",this).call(this,e)}}]),t}();s.isSupported=function(){return!0},r.default=s},{}],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),a=Math.floor(e/3600),s=Math.floor(t/60%60),n=Math.floor(t/3600),l=Math.floor(1e3*(e-i));return(isNaN(e)||e===1/0)&&(a=o=i=l="-"),t>0&&t<r?(l<100&&(l=l<10?"00"+l:"0"+l),l=":"+l):l="",(a=a>0||n>0?a+":":"")+(o=((a||s>=10)&&o<10?"0"+o:o)+":")+(i=i<10?"0"+i: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";var i=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}}(),o=p(e(4)),a=p(e(3)),s=p(e(1)),n=p(e(2)),l=p(e(5)),u=p("undefined"!=typeof window?window.videojs:void 0!==r?r.videojs:null),h=p("undefined"!=typeof window?window.WaveSurfer:void 0!==r?r.WaveSurfer:null);function p(e){return e&&e.__esModule?e:{default:e}}function f(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 c=u.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=f(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));if(r=u.default.mergeOptions(s.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===h.default.microphone)return i.onWaveError("Could not find wavesurfer.js microphone plugin!"),f(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),i(t,[{key:"initialize",value:function(){(this.player.tech_.setActivePlayer(this.player),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=h.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=h.default.util.debounce(this.onResizeChange.bind(this),150),l.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=[h.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=h.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(){(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.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:"setAudioOutput",value:function(e){var t=this;e&&this.surfer.setSinkId(e).then(function(e){t.player.trigger("audioOutputReady")}).catch(function(e){t.player.trigger("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){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,a.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,a.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,o.default)(e,t,this.debug)}}]),t}();d.VERSION="2.2.1",u.default.Wavesurfer=d,u.default.registerPlugin("wavesurfer",d),u.default.registerTech("Html5",n.default),t.exports={Wavesurfer:d}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[6]);

@@ -43,35 +43,39 @@ 'use strict';

// we need the player instance so that we can access the current
// wavesurfer plugin attached to that player
var _this = _possibleConstructorReturn(this, (WavesurferTech.__proto__ || Object.getPrototypeOf(WavesurferTech)).call(this, options, ready));
return _possibleConstructorReturn(this, (WavesurferTech.__proto__ || Object.getPrototypeOf(WavesurferTech)).call(this, options, ready));
}
_this.activePlayer = videojs(options.playerId);
_this.waveready = false;
_createClass(WavesurferTech, [{
key: 'setActivePlayer',
value: function setActivePlayer(player) {
var _this2 = this;
// track when wavesurfer is fully initialized (ready)
_this.activePlayer.on('waveReady', function () {
_this.waveready = true;
});
// we need the player instance so that we can access the current
// wavesurfer plugin attached to that player
this.activePlayer = player;
this.waveready = false;
if (!_this.playerIsUsingWavesurfer()) {
// the plugin hasn't been initialized for this player, so it
// likely doesn't need our html5 tech modifications
return _possibleConstructorReturn(_this);
}
// track when wavesurfer is fully initialized (ready)
this.activePlayer.on('waveReady', function () {
_this2.waveready = true;
});
// proxy timeupdate events so that the tech emits them too. This will
// allow the rest of videoJS to work (including text tracks)
_this.activePlayer.activeWavesurferPlugin.on('timeupdate', function () {
_this.trigger('timeupdate');
});
return _this;
}
if (!this.playerIsUsingWavesurfer()) {
// the plugin hasn't been initialized for this player, so it
// likely doesn't need our html5 tech modifications
return;
}
/**
* Determine whether or not the player is trying use the wavesurfer plugin
* @returns {boolean}
*/
// proxy timeupdate events so that the tech emits them too. This will
// allow the rest of videoJS to work (including text tracks)
this.activePlayer.activeWavesurferPlugin.on('timeupdate', function () {
_this2.trigger('timeupdate');
});
}
/**
* Determine whether or not the player is trying use the wavesurfer plugin
* @returns {boolean}
*/
_createClass(WavesurferTech, [{
}, {
key: 'playerIsUsingWavesurfer',

@@ -78,0 +82,0 @@ value: function playerIsUsingWavesurfer() {

@@ -115,2 +115,3 @@ 'use strict';

value: function initialize() {
this.player.tech_.setActivePlayer(this.player);
this.player.bigPlayButton.hide();

@@ -117,0 +118,0 @@

{
"name": "videojs-wavesurfer",
"version": "2.2.0",
"version": "2.2.1",
"description": "video.js plugin that adds a navigable waveform for audio and video files.",

@@ -97,3 +97,3 @@ "author": "Collab",

"babelify": "^8.0.0",
"browserify": "^15.2.0",
"browserify": "16",
"browserify-banner": "^1.0.6",

@@ -103,3 +103,3 @@ "browserify-shim": "^3.8.14",

"clean-css-cli": "^4.1.10",
"connect": "^3.6.5",
"connect": "^3.6.6",
"copy-dir": "^0.3.0",

@@ -115,3 +115,3 @@ "del": "^3.0.0",

"node-sass": "^4.6.1",
"nodemon": "^1.14.11",
"nodemon": "^1.15.1",
"npm-run-all": "^4.1.2",

@@ -121,9 +121,9 @@ "portscanner": "^2.1.1",

"replace": "^0.3.0",
"serve-static": "^1.13.1",
"serve-static": "^1.13.2",
"shelljs": "^0.8.1",
"uglify-js": "^3.3.8",
"webpack": "^3.10.0",
"webrtc-adapter": "^6.1.0",
"uglify-js": "3",
"webpack": "3",
"webrtc-adapter": "^6.1.1",
"zip-dir": "^1.0.2"
}
}

@@ -24,6 +24,8 @@ /**

super(options, ready);
}
setActivePlayer(player) {
// we need the player instance so that we can access the current
// wavesurfer plugin attached to that player
this.activePlayer = videojs(options.playerId);
this.activePlayer = player;
this.waveready = false;

@@ -30,0 +32,0 @@

@@ -77,2 +77,3 @@ /**

initialize() {
this.player.tech_.setActivePlayer(this.player);
this.player.bigPlayButton.hide();

@@ -79,0 +80,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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