videojs-wavesurfer
Advanced tools
Comparing version 2.3.2 to 2.4.0
videojs-wavesurfer changelog | ||
============================ | ||
2.4.0 - 2018/05/15 | ||
------------------ | ||
- Add plugin style `vjs-wavesurfer` and prefix all custom plugin styles with | ||
this selector. This should prevent clashes with regular video.js players | ||
loaded on the same page. If you were using the old `videojs-wavesurfer` CSS | ||
class, rename any references to `vjs-wavesurfer` | ||
- Compile SCSS into CSS using webpack | ||
2.3.2 - 2018/05/07 | ||
@@ -5,0 +15,0 @@ ------------------ |
/*! | ||
* videojs-wavesurfer | ||
* @version 2.3.2 | ||
* @version 2.4.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -10,10 +10,10 @@ * @copyright 2014-2018 Collab | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("videojs"), require("WaveSurfer")); | ||
module.exports = factory(require("WaveSurfer"), require("videojs")); | ||
else if(typeof define === 'function' && define.amd) | ||
define("VideojsWavesurfer", ["videojs", "WaveSurfer"], factory); | ||
define("VideojsWavesurfer", ["WaveSurfer", "videojs"], factory); | ||
else if(typeof exports === 'object') | ||
exports["VideojsWavesurfer"] = factory(require("videojs"), require("WaveSurfer")); | ||
exports["VideojsWavesurfer"] = factory(require("WaveSurfer"), require("videojs")); | ||
else | ||
root["VideojsWavesurfer"] = factory(root["videojs"], root["WaveSurfer"]); | ||
})(window, function(__WEBPACK_EXTERNAL_MODULE_video_js__, __WEBPACK_EXTERNAL_MODULE_wavesurfer_js__) { | ||
root["VideojsWavesurfer"] = factory(root["WaveSurfer"], root["videojs"]); | ||
})(window, function(__WEBPACK_EXTERNAL_MODULE_wavesurfer_js__, __WEBPACK_EXTERNAL_MODULE_video_js__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -87,3 +87,3 @@ /******/ // The module cache | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = "./src/js/videojs.wavesurfer.js"); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
@@ -149,2 +149,13 @@ /************************************************************************/ | ||
/***/ "./src/css/videojs.wavesurfer.scss": | ||
/*!*****************************************!*\ | ||
!*** ./src/css/videojs.wavesurfer.scss ***! | ||
\*****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// extracted by mini-css-extract-plugin | ||
/***/ }), | ||
/***/ "./src/js/defaults.js": | ||
@@ -563,2 +574,6 @@ /*!****************************!*\ | ||
var _window = __webpack_require__(/*! global/window */ "./node_modules/global/window.js"); | ||
var _window2 = _interopRequireDefault(_window); | ||
var _tech = __webpack_require__(/*! ./tech */ "./src/js/tech.js"); | ||
@@ -568,6 +583,2 @@ | ||
var _window = __webpack_require__(/*! global/window */ "./node_modules/global/window.js"); | ||
var _window2 = _interopRequireDefault(_window); | ||
var _video = __webpack_require__(/*! video.js */ "video.js"); | ||
@@ -617,5 +628,8 @@ | ||
// parse options | ||
// add plugin style | ||
var _this = _possibleConstructorReturn(this, (Wavesurfer.__proto__ || Object.getPrototypeOf(Wavesurfer)).call(this, player, options)); | ||
player.addClass('vjs-wavesurfer'); | ||
// parse options | ||
options = _video2.default.mergeOptions(_defaults2.default, options); | ||
@@ -632,8 +646,2 @@ _this.waveReady = false; | ||
// check that wavesurfer is initialized in options, and add class to | ||
// activate videojs-wavesurfer specific styles | ||
if (_this.player.options_.plugins.wavesurfer !== undefined) { | ||
_this.player.addClass('videojs-wavesurfer'); | ||
} | ||
// microphone plugin | ||
@@ -1432,3 +1440,3 @@ if (options.src === 'live') { | ||
Wavesurfer.VERSION = "2.3.2"; | ||
Wavesurfer.VERSION = "2.4.0"; | ||
@@ -1452,2 +1460,15 @@ // register plugin once | ||
/***/ 0: | ||
/*!******************************************************************************!*\ | ||
!*** multi ./src/js/videojs.wavesurfer.js ./src/css/videojs.wavesurfer.scss ***! | ||
\******************************************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(/*! /home/thijs/projects/videojs-wavesurfer/src/js/videojs.wavesurfer.js */"./src/js/videojs.wavesurfer.js"); | ||
module.exports = __webpack_require__(/*! /home/thijs/projects/videojs-wavesurfer/src/css/videojs.wavesurfer.scss */"./src/css/videojs.wavesurfer.scss"); | ||
/***/ }), | ||
/***/ "video.js": | ||
@@ -1454,0 +1475,0 @@ /*!**************************!*\ |
/*! | ||
* videojs-wavesurfer | ||
* @version 2.3.2 | ||
* @version 2.4.0 | ||
* @see https://github.com/collab-project/videojs-wavesurfer | ||
@@ -8,3 +8,3 @@ * @copyright 2014-2018 Collab | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("WaveSurfer"),require("videojs")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["WaveSurfer","videojs"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("WaveSurfer"),require("videojs")):e.VideojsWavesurfer=t(e.WaveSurfer,e.videojs)}(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,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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=8)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},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(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__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 s=Object.getPrototypeOf(t);return null===s?void 0:e(s,r,i)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(i):void 0};var s=videojs.getTech("Html5"),a=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,s),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}();a.isSupported=function(){return!0},t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={debug:!1,msDisplayMax:3},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.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)+l},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t,r){!0===r&&("error"===t?videojs.log.error(e):"warn"===t?videojs.log.warn(e):videojs.log(e))},e.exports=t.default},function(e,t,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(r(7)),s=p(r(6)),a=p(r(5)),n=p(r(4)),l=p(r(3)),u=p(r(1)),h=p(r(0));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=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(a.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)),this.player.muted()&&this.setVolume(0),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className="vjs-wavedisplay",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)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=h.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.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.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){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.contentEl()&&(this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,s.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.contentEl()&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,s.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=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){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,o.default)(e,t,this.debug)}}]),t}();y.VERSION="2.3.2",u.default.Wavesurfer=y,void 0===u.default.getPlugin("wavesurfer")&&u.default.registerPlugin("wavesurfer",y),u.default.registerTech("Html5",n.default),e.exports={Wavesurfer:y}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("WaveSurfer"),require("videojs")):"function"==typeof define&&define.amd?define("VideojsWavesurfer",["WaveSurfer","videojs"],t):"object"==typeof exports?exports.VideojsWavesurfer=t(require("WaveSurfer"),require("videojs")):e.VideojsWavesurfer=t(e.WaveSurfer,e.videojs)}(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,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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=11)}([,function(e,t,r){},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t,r){"use strict";Object.defineProperty(t,"__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 s=Object.getPrototypeOf(t);return null===s?void 0:e(s,r,i)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(i):void 0};var s=videojs.getTech("Html5"),a=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,s),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}();a.isSupported=function(){return!0},t.default=a,e.exports=t.default},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},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(5))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={debug:!1,msDisplayMax:3},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.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)+l},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t,r){!0===r&&("error"===t?videojs.log.error(e):"warn"===t?videojs.log.warn(e):videojs.log(e))},e.exports=t.default},function(e,t,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(r(9)),s=p(r(8)),a=p(r(7)),n=p(r(6)),l=p(r(4)),u=p(r(3)),h=p(r(2));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=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(e.addClass("vjs-wavesurfer"),r=u.default.mergeOptions(a.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,"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)),this.player.muted()&&this.setVolume(0),!0===this.player.options_.fluid&&(this.surfer.drawer.wrapper.className="vjs-wavedisplay",this.responsiveWave=h.default.util.debounce(this.onResizeChange.bind(this),150),n.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)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=h.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.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.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){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.contentEl()&&(this.player.controlBar.currentTimeDisplay.formattedTime_=this.player.controlBar.currentTimeDisplay.contentEl().lastChild.textContent=(0,s.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.contentEl()&&(this.player.controlBar.durationDisplay.formattedTime_=this.player.controlBar.durationDisplay.contentEl().lastChild.textContent=(0,s.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=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){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,o.default)(e,t,this.debug)}}]),t}();y.VERSION="2.4.0",u.default.Wavesurfer=y,void 0===u.default.getPlugin("wavesurfer")&&u.default.registerPlugin("wavesurfer",y),u.default.registerTech("Html5",l.default),e.exports={Wavesurfer:y}},function(e,t,r){r(10),e.exports=r(1)}])}); | ||
//# sourceMappingURL=videojs.wavesurfer.min.js.map |
{ | ||
"name": "videojs-wavesurfer", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"description": "video.js plugin that adds a navigable waveform for audio and video files.", | ||
@@ -25,11 +25,5 @@ "author": "Collab", | ||
"clean": "rimraf dist docs", | ||
"build": "npm run clean && npm run build:dev && npm run build:min && npm run build:css", | ||
"build:main": "webpack --config ./build-config/webpack.dev.main.js", | ||
"build:main:min": "webpack --config ./build-config/webpack.prod.main.js", | ||
"build:dev": "npm run build:main", | ||
"build:min": "npm run build:main:min", | ||
"build:css": "npm-run-all -s build:css:sass build:css:compress build:css:banner", | ||
"build:css:sass": "node-sass --include-path src/css src/css/videojs.wavesurfer.scss dist/css/videojs.wavesurfer.css", | ||
"build:css:compress": "cleancss -o dist/css/videojs.wavesurfer.min.css dist/css/videojs.wavesurfer.css", | ||
"build:css:banner": "replace-in-file LIB_VERSION $npm_package_version dist/css/videojs.wavesurfer*.css", | ||
"build": "npm run clean && npm run lint && npm run build:dev && npm run build:min", | ||
"build:dev": "webpack --config ./build-config/webpack.dev.main.js", | ||
"build:min": "webpack --config ./build-config/webpack.prod.main.js", | ||
"docs": "npm-run-all docs:*", | ||
@@ -65,5 +59,5 @@ "docs:api": "jsdoc src/js -r -d docs/api", | ||
"babel-plugin-istanbul": "^4.1.6", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-register": "^6.26.0", | ||
"clean-css-cli": "^4.1.11", | ||
"css-loader": "^0.28.11", | ||
"htmlhint": "^0.9.13", | ||
@@ -78,2 +72,4 @@ "in-publish": "^2.0.0", | ||
"karma-coveralls": "^1.2.1", | ||
"karma-detect-browsers": "^2.3.2", | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^1.1.0", | ||
@@ -83,11 +79,15 @@ "karma-host-environment": "^1.1.3", | ||
"karma-jasmine-matchers": "^3.7.0", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-verbose-reporter": "0.0.6", | ||
"karma-webpack": "^4.0.0-beta.0", | ||
"mini-css-extract-plugin": "^0.4.0", | ||
"moment": "^2.22.1", | ||
"node-sass": "^4.9.0", | ||
"npm-run-all": "^4.1.3", | ||
"replace-in-file": "^3.4.0", | ||
"optimize-css-assets-webpack-plugin": "^4.0.1", | ||
"rimraf": "^2.6.2", | ||
"sass-loader": "^7.0.1", | ||
"style-loader": "^0.21.0", | ||
"uglifyjs-webpack-plugin": "^1.2.5", | ||
"webpack": "^4.7.0", | ||
"webpack": "^4.8.3", | ||
"webpack-cli": "^2.1.3", | ||
@@ -94,0 +94,0 @@ "webpack-dev-server": "^3.1.4", |
@@ -17,2 +17,23 @@ Video.js Wavesurfer | ||
Table of Contents | ||
----------------- | ||
- [Installation](#installation) | ||
- [Using the Plugin](#using-the-plugin) | ||
- [Plugin Options](#plugin-options) | ||
- [Examples](#examples) | ||
- [Methods](#methods) | ||
- [Other wavesurfer.js methods](#other-wavesurferjs-methods) | ||
- [Events](#events) | ||
- [Customizing controls](#customizing-controls) | ||
- [Responsive layout](#responsive-layout) | ||
- [Text Tracks](#text-tracks) | ||
- [Microphone plugin](#microphone-plugin) | ||
- [Change audio output or input device](#change-audio-output-or-input-device) | ||
- [Using with React](#using-with-react) | ||
- [More features using other plugins](#more-features-using-other-plugins) | ||
- [Development](#development) | ||
- [License](#license) | ||
- [Donate](#donate) | ||
Installation | ||
@@ -19,0 +40,0 @@ ------------ |
@@ -11,4 +11,4 @@ /** | ||
import pluginDefaultOptions from './defaults'; | ||
import window from 'global/window'; | ||
import WavesurferTech from './tech'; | ||
import window from 'global/window'; | ||
@@ -38,2 +38,5 @@ import videojs from 'video.js'; | ||
// add plugin style | ||
player.addClass('vjs-wavesurfer'); | ||
// parse options | ||
@@ -51,8 +54,2 @@ options = videojs.mergeOptions(pluginDefaultOptions, options); | ||
// check that wavesurfer is initialized in options, and add class to | ||
// activate videojs-wavesurfer specific styles | ||
if (this.player.options_.plugins.wavesurfer !== undefined) { | ||
this.player.addClass('videojs-wavesurfer'); | ||
} | ||
// microphone plugin | ||
@@ -59,0 +56,0 @@ if (options.src === 'live') { |
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
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
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
239553
19
2256
401
38