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.6.4 to 2.7.0

7

CHANGES.md
videojs-wavesurfer changelog
============================
2.7.0 - 2019/02/08
------------------
- Fix hiding `playToggle` control
- Fix ES export syntax for `Wavesurfer`
2.6.4 - 2019/02/04

@@ -5,0 +12,0 @@ ------------------

100

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

@@ -354,2 +354,7 @@ * @copyright 2014-2019 Collab

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Wavesurfer = void 0;
var _log2 = _interopRequireDefault(__webpack_require__(/*! ./utils/log */ "./src/js/utils/log.js"));

@@ -453,2 +458,4 @@

value: function initialize() {
var _this2 = this;
// hide big play button

@@ -468,10 +475,15 @@ this.player.bigPlayButton.hide(); // the native controls don't work for this UI so disable

this.player.controlBar.show();
this.player.controlBar.el_.style.display = 'flex'; // progress control isn't used by this plugin
this.player.controlBar.el_.style.display = 'flex'; // progress control (if present) isn't used by this plugin
this.player.controlBar.progressControl.hide(); // make sure time displays are visible
if (this.player.controlBar.progressControl !== undefined) {
this.player.controlBar.progressControl.hide();
} // make sure time displays are visible
var uiElements = [this.player.controlBar.currentTimeDisplay, this.player.controlBar.timeDivider, this.player.controlBar.durationDisplay];
var uiElements = ['currentTimeDisplay', 'timeDivider', 'durationDisplay'];
uiElements.forEach(function (element) {
// ignore and show when essential elements have been disabled
// by user
element = _this2.player.controlBar[element];
if (element !== undefined) {

@@ -485,10 +497,12 @@ element.el_.style.display = 'block';

this.player.controlBar.remainingTimeDisplay.hide();
} // handle play toggle interaction
}
if (this.player.controlBar.playToggle !== undefined) {
// handle play toggle interaction
this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this)); // disable play button until waveform is ready
// (except when in live mode)
this.player.controlBar.playToggle.on(['tap', 'click'], this.onPlayToggle.bind(this)); // disable play button until waveform is ready
// (except when in live mode)
if (!this.liveMode) {
this.player.controlBar.playToggle.hide();
if (!this.liveMode) {
this.player.controlBar.playToggle.hide();
}
}

@@ -537,7 +551,10 @@ } // wavesurfer.js setup

if (this.textTracksEnabled) {
// disable timeupdates
this.player.controlBar.currentTimeDisplay.off(this.player, 'timeupdate', this.player.controlBar.currentTimeDisplay.throttledUpdateContent); // sets up an interval function to track current time
if (this.player.controlBar.currentTimeDisplay !== undefined) {
// disable timeupdates
this.player.controlBar.currentTimeDisplay.off(this.player, 'timeupdate', this.player.controlBar.currentTimeDisplay.throttledUpdateContent);
} // sets up an interval function to track current time
// and trigger timeupdate every 250 milliseconds.
// needed for text tracks
this.player.tech_.trackCurrentTime();

@@ -665,3 +682,3 @@ } // kick things off

value: function load(url, peaks) {
var _this2 = this;
var _this3 = this;

@@ -692,12 +709,12 @@ if (url instanceof Blob || url instanceof File) {

ajax.on('success', function (data, e) {
_this2.log('Loaded Peak Data URL: ' + peaks);
_this3.log('Loaded Peak Data URL: ' + peaks);
_this2.surfer.load(url, data.data);
_this3.surfer.load(url, data.data);
});
ajax.on('error', function (e) {
_this2.log('Unable to retrieve peak data from ' + peaks + '. Status code: ' + e.target.status, 'warn');
_this3.log('Unable to retrieve peak data from ' + peaks + '. Status code: ' + e.target.status, 'warn');
_this2.log('Loading URL: ' + url);
_this3.log('Loading URL: ' + url);
_this2.surfer.load(url);
_this3.surfer.load(url);
});

@@ -720,3 +737,3 @@ }

// show pause button
if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.handlePlay();

@@ -757,3 +774,3 @@ }

// show play button
if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.handlePause();

@@ -865,3 +882,3 @@ }

value: function setAudioOutput(deviceId) {
var _this3 = this;
var _this4 = this;

@@ -871,8 +888,8 @@ if (deviceId) {

// notify listeners
_this3.player.trigger('audioOutputReady');
_this4.player.trigger('audioOutputReady');
}).catch(function (err) {
// notify listeners
_this3.player.trigger('error', err);
_this4.player.trigger('error', err);
_this3.log(err, 'error');
_this4.log(err, 'error');
});

@@ -983,3 +1000,3 @@ }

if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.show();

@@ -1008,3 +1025,3 @@ } // hide loading spinner

value: function onWaveFinish() {
var _this4 = this;
var _this5 = this;

@@ -1030,5 +1047,7 @@ this.log('Finished playback'); // notify listeners

this.surfer.once('seek', function () {
_this4.player.controlBar.playToggle.removeClass('vjs-ended');
if (_this5.player.controlBar.playToggle !== undefined) {
_this5.player.controlBar.playToggle.removeClass('vjs-ended');
}
_this4.player.trigger('pause');
_this5.player.trigger('pause');
});

@@ -1082,3 +1101,3 @@ }

// workaround for video.js 6.3.1 and newer
if (this.player.controlBar.playToggle.hasClass('vjs-ended')) {
if (this.player.controlBar.playToggle !== undefined && this.player.controlBar.playToggle.hasClass('vjs-ended')) {
this.player.controlBar.playToggle.removeClass('vjs-ended');

@@ -1119,3 +1138,3 @@ }

value: function onScreenChange() {
var _this5 = this;
var _this6 = this;

@@ -1125,3 +1144,3 @@ // execute with tiny delay so the player element completes

var fullscreenDelay = this.player.setInterval(function () {
var isFullscreen = _this5.player.isFullscreen();
var isFullscreen = _this6.player.isFullscreen();

@@ -1132,8 +1151,8 @@ var newWidth, newHeight;

// restore original dimensions
newWidth = _this5.originalWidth;
newHeight = _this5.originalHeight;
newWidth = _this6.originalWidth;
newHeight = _this6.originalHeight;
}
if (_this5.waveReady) {
if (_this5.liveMode && !_this5.surfer.microphone.active) {
if (_this6.waveReady) {
if (_this6.liveMode && !_this6.surfer.microphone.active) {
// we're in live mode but the microphone hasn't been

@@ -1145,7 +1164,7 @@ // started yet

_this5.redrawWaveform(newWidth, newHeight);
_this6.redrawWaveform(newWidth, newHeight);
} // stop fullscreenDelay interval
_this5.player.clearInterval(fullscreenDelay);
_this6.player.clearInterval(fullscreenDelay);
}, 100);

@@ -1226,3 +1245,4 @@ }

Wavesurfer.VERSION = "2.6.4"; // register plugin once
exports.Wavesurfer = Wavesurfer;
Wavesurfer.VERSION = "2.7.0"; // register plugin once

@@ -1235,6 +1255,2 @@ _video.default.Wavesurfer = Wavesurfer;

module.exports = {
Wavesurfer: Wavesurfer
};
/***/ }),

@@ -1241,0 +1257,0 @@

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

@@ -8,3 +8,3 @@ * @copyright 2014-2019 Collab

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

@@ -91,4 +91,4 @@ "author": "Collab",

"tui-jsdoc-template": "^1.2.2",
"webpack": "^4.29.1",
"webpack-cli": "^3.2.1",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.1.14",

@@ -95,0 +95,0 @@ "webpack-merge": "^4.2.1",

@@ -89,14 +89,13 @@ /**

// progress control isn't used by this plugin
this.player.controlBar.progressControl.hide();
// progress control (if present) isn't used by this plugin
if (this.player.controlBar.progressControl !== undefined) {
this.player.controlBar.progressControl.hide();
}
// make sure time displays are visible
let uiElements = [
this.player.controlBar.currentTimeDisplay,
this.player.controlBar.timeDivider,
this.player.controlBar.durationDisplay
];
let uiElements = ['currentTimeDisplay', 'timeDivider', 'durationDisplay'];
uiElements.forEach((element) => {
// ignore and show when essential elements have been disabled
// by user
element = this.player.controlBar[element];
if (element !== undefined) {

@@ -111,10 +110,12 @@ element.el_.style.display = 'block';

// handle play toggle interaction
this.player.controlBar.playToggle.on(['tap', 'click'],
this.onPlayToggle.bind(this));
if (this.player.controlBar.playToggle !== undefined) {
// handle play toggle interaction
this.player.controlBar.playToggle.on(['tap', 'click'],
this.onPlayToggle.bind(this));
// disable play button until waveform is ready
// (except when in live mode)
if (!this.liveMode) {
this.player.controlBar.playToggle.hide();
// disable play button until waveform is ready
// (except when in live mode)
if (!this.liveMode) {
this.player.controlBar.playToggle.hide();
}
}

@@ -163,5 +164,7 @@ }

if (this.textTracksEnabled) {
// disable timeupdates
this.player.controlBar.currentTimeDisplay.off(this.player, 'timeupdate',
this.player.controlBar.currentTimeDisplay.throttledUpdateContent);
if (this.player.controlBar.currentTimeDisplay !== undefined) {
// disable timeupdates
this.player.controlBar.currentTimeDisplay.off(this.player, 'timeupdate',
this.player.controlBar.currentTimeDisplay.throttledUpdateContent);
}

@@ -334,3 +337,4 @@ // sets up an interval function to track current time

// show pause button
if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined &&
this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.handlePlay();

@@ -372,3 +376,4 @@ }

// show play button
if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined &&
this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.handlePause();

@@ -583,3 +588,4 @@ }

// enable and show play button
if (this.player.controlBar.playToggle.contentEl()) {
if (this.player.controlBar.playToggle !== undefined &&
this.player.controlBar.playToggle.contentEl()) {
this.player.controlBar.playToggle.show();

@@ -630,3 +636,5 @@ }

this.surfer.once('seek', () => {
this.player.controlBar.playToggle.removeClass('vjs-ended');
if (this.player.controlBar.playToggle !== undefined) {
this.player.controlBar.playToggle.removeClass('vjs-ended');
}
this.player.trigger('pause');

@@ -674,3 +682,4 @@ });

// workaround for video.js 6.3.1 and newer
if (this.player.controlBar.playToggle.hasClass('vjs-ended')) {
if (this.player.controlBar.playToggle !== undefined &&
this.player.controlBar.playToggle.hasClass('vjs-ended')) {
this.player.controlBar.playToggle.removeClass('vjs-ended');

@@ -804,4 +813,2 @@ }

module.exports = {
Wavesurfer
};
export {Wavesurfer};

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 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