Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
update 2.8 fc7444c Dec 31, 2018
1 contributor

Users who have contributed to this file

1 lines (1 sloc) 197 KB
{"version":3,"sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/./node_modules/debounce/index.js","webpack://WaveSurfer/./src/drawer.js","webpack://WaveSurfer/./src/drawer.multicanvas.js","webpack://WaveSurfer/./src/mediaelement.js","webpack://WaveSurfer/./src/peakcache.js","webpack://WaveSurfer/./src/util/ajax.js","webpack://WaveSurfer/./src/util/extend.js","webpack://WaveSurfer/./src/util/frame.js","webpack://WaveSurfer/./src/util/get-id.js","webpack://WaveSurfer/./src/util/index.js","webpack://WaveSurfer/./src/util/max.js","webpack://WaveSurfer/./src/util/min.js","webpack://WaveSurfer/./src/util/observer.js","webpack://WaveSurfer/./src/util/prevent-click.js","webpack://WaveSurfer/./src/util/request-animation-frame.js","webpack://WaveSurfer/./src/util/style.js","webpack://WaveSurfer/./src/wavesurfer.js","webpack://WaveSurfer/./src/webaudio.js"],"names":["Drawer","container","params","width","height","pixelRatio","lastPos","wrapper","el","styles","util","style","appendChild","document","createElement","display","position","userSelect","webkitUserSelect","fillParent","scrollParent","overflowX","hideScrollbar","overflowY","setupWrapperEvents","e","noPrevent","preventDefault","clientX","targetTouches","bbox","getBoundingClientRect","nominalWidth","parentWidth","getWidth","progress","left","scrollLeft","scrollWidth","addEventListener","scrollbarHeight","offsetHeight","clientHeight","clientY","bottom","interact","fireEvent","handleEvent","peaks","length","start","end","setWidth","clearWave","barWidth","drawBars","drawWave","percent","recenterOnPosition","immediate","half","clientWidth","maxScroll","target","offset","rate","Math","max","min","x","round","updateSize","minPxDelta","pos","autoCenter","newPos","updateProgress","unAll","parentNode","removeChild","channelIndex","Observer","MultiCanvas","maxCanvasWidth","maxCanvasElementWidth","hasProgressCanvas","waveColor","progressColor","halfPixel","canvases","progressWave","createWrapper","createElements","zIndex","top","overflow","boxSizing","borderRightStyle","pointerEvents","addCanvas","updateCursor","borderRightWidth","cursorWidth","borderRightColor","cursorColor","totalWidth","requiredCanvases","ceil","removeCanvas","forEach","entry","i","canvasWidth","updateDimensions","clearWaveForEntry","leftOffset","wave","waveCtx","getContext","progressCtx","push","lastEntry","pop","parentElement","elementWidth","canvas","offsetLeft","clearRect","prepareDraw","absmax","hasMinVals","offsetY","halfH","undefined","peakIndexScale","bar","gap","barGap","step","scale","first","last","peak","floor","h","fillRect","reflectedPeaks","len","drawLine","setFillStyles","drawLineToContext","ctx","canvasStart","canvasEnd","j","beginPath","moveTo","lineTo","closePath","fill","y","startCanvas","endCanvas","intersection","x1","y1","x2","y2","fillRectToContext","fn","frame","Array","channels","splitChannels","setHeight","channelPeaks","barHeight","normalize","some","call","val","fillStyle","type","quality","images","map","toDataURL","MediaElement","media","currentTime","duration","paused","playbackRate","play","pause","volume","mediaType","toLowerCase","elementPosition","buffer","onPlayEnd","setPlaybackRate","audioRate","createTimer","onAudioProcess","isPaused","getCurrentTime","requestAnimationFrame","window","webkitRequestAnimationFrame","on","url","preload","controls","mediaControls","autoplay","src","prevMedia","querySelector","_load","elt","load","setVolume","explicitDuration","Infinity","seekable","getDuration","value","clearPlayEnd","seekTo","promise","setPlayEnd","_onPlayEnd","time","un","deviceId","setSinkId","Promise","reject","Error","removeMediaElementOnDestroy","WebAudio","PeakCache","clearPeakCache","peakCacheRanges","peakCacheLength","uncachedRanges","filter","item","arr","concat","sort","a","b","uncachedRangePairs","peakCacheRangePairs","ajax","options","instance","xhr","XMLHttpRequest","fired100","open","method","responseType","requestHeaders","header","setRequestHeader","key","withCredentials","lengthComputable","loaded","total","status","response","send","extend","dest","sources","source","Object","keys","func","args","getId","random","toString","substring","values","largest","smallest","Number","handlers","event","name","callback","splice","handler","apply","setTimeout","preventClickHandler","stopPropagation","body","removeEventListener","preventClick","mozRequestAnimationFrame","oRequestAnimationFrame","msRequestAnimationFrame","element","bind","prop","PluginClass","ws","WaveSurfer","wavesurfer","init","defaultParams","audioContext","audioScriptProcessor","backend","dragSelection","forceDecode","loopSelection","mediaContainer","minPxPerSec","partialRender","devicePixelRatio","screen","deviceXDPI","logicalXDPI","plugins","renderer","responsive","skipLength","backends","savedVolume","isMuted","tmpEvents","currentAjax","arraybuffer","drawer","peakCache","Backend","initialisedPluginList","isDestroyed","isReady","prevWidth","_onResize","debounce","registerPlugins","createDrawer","createBackend","createPeakCache","plugin","addPlugin","deferInit","initPlugin","staticProps","pluginStaticProp","Instance","observerPrototypeKeys","getOwnPropertyNames","prototype","destroyPlugin","destroy","drawBuffer","getPlayedPercents","supportsWebAudio","seconds","skip","seekAndCenter","recenter","isFinite","console","error","oldScrollParent","newVolume","getVolume","getPlaybackRate","setMute","mute","filters","color","getScrollX","newRanges","addRangeToPeakCache","getPeaks","drawPeaks","pxPerSec","decodeArrayBuffer","data","loadDecodedBuffer","blob","reader","FileReader","onProgress","loadArrayBuffer","result","readAsArrayBuffer","empty","preloadIgnoreReasons","indexOf","activeReasons","reason","warn","join","loadBuffer","loadMediaElement","action","once","getArrayBuffer","setPeaks","urlOrElt","loadElt","err","statusText","percentComplete","accuracy","noWindow","json","JSON","stringify","encodeURIComponent","format","getImage","abort","stop","disconnectSource","cancelAjax","clearTmpEvents","destroyAllPlugins","VERSION","__VERSION__","PLAYING","PAUSED","FINISHED","AudioContext","webkitAudioContext","WaveSurferAudioContext","sampleRate","WaveSurferOfflineAudioContext","OfflineAudioContext","webkitOfflineAudioContext","offlineAudioContext","stateBehaviors","addOnAudioProcess","startPosition","getPlayedTime","removeOnAudioProcess","ac","getAudioContext","lastPlay","scheduledPause","states","create","analyser","gainNode","mergedPeaks","offlineAc","scriptNode","splitPeaks","state","createVolumeNode","createScriptNode","createAnalyserNode","setState","setLength","disconnect","connect","setFilters","disconnectFilters","reduce","prev","curr","createScriptProcessor","scriptBufferSize","createJavaScriptNode","destination","onaudioprocess","createAnalyser","createGain","createGainNode","audio","Audio","createMediaStreamDestination","srcObject","stream","gain","setValueAtTime","errback","getOfflineAudioContext","decodeAudioData","numberOfChannels","c","newBuffer","createBuffer","sampleSize","sampleStep","chan","getChannelData","closeAudioContext","close","createSource","createBufferSource","noteGrainOn","noteOff","adjustedTime","resume"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;ACrEA;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;IAKqBA,M;;;;;AACjB;;;;AAIA,kBAAYC,SAAZ,EAAuBC,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,CAAiB,CAAjB,CAAf;AAEA,WAAKuC,QAAL,CAAc/B,MAAd;AAEA,WAAKpY,SAAL,CAAe,OAAf;AACH;AAED;;;;;;;;;qCAMiB;AACb,aAAO,KAAK+Z,KAAL,CAAW/P,cAAX,CAA0B3B,IAA1B,CAA+B,IAA/B,CAAP;AACH;AAED;;;;;;;;sCAKkB;AACd,aAAO,KAAKa,YAAZ;AACH;AAED;;;;;;;;oCAKgBmC,K,EAAO;AACnBA,WAAK,GAAGA,KAAK,IAAI,CAAjB;;AACA,UAAI,KAAKtB,QAAL,EAAJ,EAAqB;AACjB,aAAKb,YAAL,GAAoBmC,KAApB;AACH,OAFD,MAEO;AACH,aAAKjC,KAAL;AACA,aAAKF,YAAL,GAAoBmC,KAApB;AACA,aAAKlC,IAAL;AACH;AACJ;;;;EApqBiCvL,IAAI,CAACuE,Q;;;AAAtBgK,Q,CAEV0O,gB,GAAmB,G","file":"wavesurfer.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/wavesurfer.js\");\n","/**\n * Returns a function, that, as long as it continues to be invoked, will not\n * be triggered. The function will be called after it stops being called for\n * N milliseconds. If `immediate` is passed, trigger the function on the\n * leading edge, instead of the trailing. The function also has a property 'clear' \n * that is a function which will clear the timer to prevent previously scheduled executions. \n *\n * @source underscore.js\n * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/\n * @param {Function} function to wrap\n * @param {Number} timeout in ms (`100`)\n * @param {Boolean} whether to execute at the beginning (`false`)\n * @api public\n */\nfunction debounce(func, wait, immediate){\n var timeout, args, context, timestamp, result;\n if (null == wait) wait = 100;\n\n function later() {\n var last = Date.now() - timestamp;\n\n if (last < wait && last >= 0) {\n timeout = setTimeout(later, wait - last);\n } else {\n timeout = null;\n if (!immediate) {\n result = func.apply(context, args);\n context = args = null;\n }\n }\n };\n\n var debounced = function(){\n context = this;\n args = arguments;\n timestamp = Date.now();\n var callNow = immediate && !timeout;\n if (!timeout) timeout = setTimeout(later, wait);\n if (callNow) {\n result = func.apply(context, args);\n context = args = null;\n }\n\n return result;\n };\n\n debounced.clear = function() {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n };\n \n debounced.flush = function() {\n if (timeout) {\n result = func.apply(context, args);\n context = args = null;\n \n clearTimeout(timeout);\n timeout = null;\n }\n };\n\n return debounced;\n};\n\n// Adds compatibility for ES modules\ndebounce.debounce = debounce;\n\nmodule.exports = debounce;\n","import * as util from './util';\n\n/**\n * Parent class for renderers\n *\n * @extends {Observer}\n */\nexport default class Drawer extends util.Observer {\n /**\n * @param {HTMLElement} container The container node of the wavesurfer instance\n * @param {WavesurferParams} params The wavesurfer initialisation options\n */\n constructor(container, params) {\n super();\n /** @private */\n this.container = container;\n /**\n * @type {WavesurferParams}\n * @private\n */\n this.params = params;\n /**\n * The width of the renderer\n * @type {number}\n */\n this.width = 0;\n /**\n * The height of the renderer\n * @type {number}\n */\n this.height = params.height * this.params.pixelRatio;\n /** @private */\n this.lastPos = 0;\n /**\n * The `<wave>` element which is added to the container\n * @type {HTMLElement}\n */\n this.wrapper = null;\n }\n\n /**\n * Alias of `util.style`\n *\n * @param {HTMLElement} el The element that the styles will be applied to\n * @param {Object} styles The map of propName: attribute, both are used as-is\n * @return {HTMLElement} el\n */\n style(el, styles) {\n return util.style(el, styles);\n }\n\n /**\n * Create the wrapper `<wave>` element, style it and set up the events for\n * interaction\n */\n createWrapper() {\n this.wrapper = this.container.appendChild(\n document.createElement('wave')\n );\n\n this.style(this.wrapper, {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n webkitUserSelect: 'none',\n height: this.params.height + 'px'\n });\n\n if (this.params.fillParent || this.params.scrollParent) {\n this.style(this.wrapper, {\n width: '100%',\n overflowX: this.params.hideScrollbar ? 'hidden' : 'auto',\n overflowY: 'hidden'\n });\n }\n\n this.setupWrapperEvents();\n }\n\n /**\n * Handle click event\n *\n * @param {Event} e Click event\n * @param {?boolean} noPrevent Set to true to not call `e.preventDefault()`\n * @return {number} Playback position from 0 to 1\n */\n handleEvent(e, noPrevent) {\n !noPrevent && e.preventDefault();\n\n const clientX = e.targetTouches\n ? e.targetTouches[0].clientX\n : e.clientX;\n const bbox = this.wrapper.getBoundingClientRect();\n\n const nominalWidth = this.width;\n const parentWidth = this.getWidth();\n\n let progress;\n\n if (!this.params.fillParent && nominalWidth < parentWidth) {\n progress =\n (clientX - bbox.left) *\n (this.params.pixelRatio / nominalWidth) || 0;\n\n if (progress > 1) {\n progress = 1;\n }\n } else {\n progress =\n (clientX - bbox.left + this.wrapper.scrollLeft) /\n this.wrapper.scrollWidth || 0;\n }\n\n return progress;\n }\n\n /**\n * @private\n */\n setupWrapperEvents() {\n this.wrapper.addEventListener('click', e => {\n const scrollbarHeight =\n this.wrapper.offsetHeight - this.wrapper.clientHeight;\n if (scrollbarHeight != 0) {\n // scrollbar is visible. Check if click was on it\n const bbox = this.wrapper.getBoundingClientRect();\n if (e.clientY >= bbox.bottom - scrollbarHeight) {\n // ignore mousedown as it was on the scrollbar\n return;\n }\n }\n\n if (this.params.interact) {\n this.fireEvent('click', e, this.handleEvent(e));\n }\n });\n\n this.wrapper.addEventListener('scroll', e =>\n this.fireEvent('scroll', e)\n );\n }\n\n /**\n * Draw peaks on the canvas\n *\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} length The width of the area that should be drawn\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that should be\n * rendered\n */\n drawPeaks(peaks, length, start, end) {\n if (!this.setWidth(length)) {\n this.clearWave();\n }\n\n this.params.barWidth\n ? this.drawBars(peaks, 0, start, end)\n : this.drawWave(peaks, 0, start, end);\n }\n\n /**\n * Scroll to the beginning\n */\n resetScroll() {\n if (this.wrapper !== null) {\n this.wrapper.scrollLeft = 0;\n }\n }\n\n /**\n * Recenter the view-port at a certain percent of the waveform\n *\n * @param {number} percent Value from 0 to 1 on the waveform\n */\n recenter(percent) {\n const position = this.wrapper.scrollWidth * percent;\n this.recenterOnPosition(position, true);\n }\n\n /**\n * Recenter the view-port on a position, either scroll there immediately or\n * in steps of 5 pixels\n *\n * @param {number} position X-offset in pixels\n * @param {boolean} immediate Set to true to immediately scroll somewhere\n */\n recenterOnPosition(position, immediate) {\n const scrollLeft = this.wrapper.scrollLeft;\n const half = ~~(this.wrapper.clientWidth / 2);\n const maxScroll = this.wrapper.scrollWidth - this.wrapper.clientWidth;\n let target = position - half;\n let offset = target - scrollLeft;\n\n if (maxScroll == 0) {\n // no need to continue if scrollbar is not there\n return;\n }\n\n // if the cursor is currently visible...\n if (!immediate && -half <= offset && offset < half) {\n // we'll limit the \"re-center\" rate.\n const rate = 5;\n offset = Math.max(-rate, Math.min(rate, offset));\n target = scrollLeft + offset;\n }\n\n // limit target to valid range (0 to maxScroll)\n target = Math.max(0, Math.min(maxScroll, target));\n // no use attempting to scroll if we're not moving\n if (target != scrollLeft) {\n this.wrapper.scrollLeft = target;\n }\n }\n\n /**\n * Get the current scroll position in pixels\n *\n * @return {number}\n */\n getScrollX() {\n const pixelRatio = this.params.pixelRatio;\n let x = Math.round(this.wrapper.scrollLeft * pixelRatio);\n\n // In cases of elastic scroll (safari with mouse wheel) you can\n // scroll beyond the limits of the container\n // Calculate and floor the scrollable extent to make sure an out\n // of bounds value is not returned\n // Ticket #1312\n if (this.params.scrollParent) {\n const maxScroll = ~~(\n this.wrapper.scrollWidth * pixelRatio -\n this.getWidth()\n );\n x = Math.min(maxScroll, Math.max(0, x));\n }\n\n return x;\n }\n\n /**\n * Get the width of the container\n *\n * @return {number}\n */\n getWidth() {\n return Math.round(this.container.clientWidth * this.params.pixelRatio);\n }\n\n /**\n * Set the width of the container\n *\n * @param {number} width\n */\n setWidth(width) {\n if (this.width == width) {\n return false;\n }\n\n this.width = width;\n\n if (this.params.fillParent || this.params.scrollParent) {\n this.style(this.wrapper, {\n width: ''\n });\n } else {\n this.style(this.wrapper, {\n width: ~~(this.width / this.params.pixelRatio) + 'px'\n });\n }\n\n this.updateSize();\n return true;\n }\n\n /**\n * Set the height of the container\n *\n * @param {number} height\n */\n setHeight(height) {\n if (height == this.height) {\n return false;\n }\n this.height = height;\n\n this.style(this.wrapper, {\n height: ~~(this.height / this.params.pixelRatio) + 'px'\n });\n\n this.updateSize();\n return true;\n }\n\n /**\n * Called by wavesurfer when progress should be rendered\n *\n * @param {number} progress From 0 to 1\n */\n progress(progress) {\n const minPxDelta = 1 / this.params.pixelRatio;\n const pos = Math.round(progress * this.width) * minPxDelta;\n\n if (pos < this.lastPos || pos - this.lastPos >= minPxDelta) {\n this.lastPos = pos;\n\n if (this.params.scrollParent && this.params.autoCenter) {\n const newPos = ~~(this.wrapper.scrollWidth * progress);\n this.recenterOnPosition(newPos);\n }\n\n this.updateProgress(pos);\n }\n }\n\n /**\n * This is called when wavesurfer is destroyed\n */\n destroy() {\n this.unAll();\n if (this.wrapper) {\n if (this.wrapper.parentNode == this.container) {\n this.container.removeChild(this.wrapper);\n }\n this.wrapper = null;\n }\n }\n\n /* Renderer-specific methods */\n\n /**\n * Called after cursor related params have changed.\n *\n * @abstract\n */\n updateCursor() {}\n\n /**\n * Called when the size of the container changes so the renderer can adjust\n *\n * @abstract\n */\n updateSize() {}\n\n /**\n * Draw a waveform with bars\n *\n * @abstract\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} channelIndex The index of the current channel. Normally\n * should be 0\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that should be\n * rendered\n */\n drawBars(peaks, channelIndex, start, end) {}\n\n /**\n * Draw a waveform\n *\n * @abstract\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} channelIndex The index of the current channel. Normally\n * should be 0\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that should be\n * rendered\n */\n drawWave(peaks, channelIndex, start, end) {}\n\n /**\n * Clear the waveform\n *\n * @abstract\n */\n clearWave() {}\n\n /**\n * Render the new progress\n *\n * @abstract\n * @param {number} position X-Offset of progress position in pixels\n */\n updateProgress(position) {}\n}\n","import Drawer from './drawer';\nimport * as util from './util';\n\n/**\n * @typedef {Object} CanvasEntry\n * @private\n * @property {HTMLElement} wave The wave node\n * @property {CanvasRenderingContext2D} waveCtx The canvas rendering context\n * @property {?HTMLElement} progress The progress wave node\n * @property {?CanvasRenderingContext2D} progressCtx The progress wave canvas\n * rendering context\n * @property {?number} start Start of the area the canvas should render, between 0 and 1\n * @property {?number} end End of the area the canvas should render, between 0 and 1\n */\n\n/**\n * MultiCanvas renderer for wavesurfer. Is currently the default and sole built\n * in renderer.\n */\nexport default class MultiCanvas extends Drawer {\n /**\n * @param {HTMLElement} container The container node of the wavesurfer instance\n * @param {WavesurferParams} params The wavesurfer initialisation options\n */\n constructor(container, params) {\n super(container, params);\n /**\n * @type {number}\n * @private\n */\n this.maxCanvasWidth = params.maxCanvasWidth;\n /**\n * @private\n * @type {number}\n */\n this.maxCanvasElementWidth = Math.round(\n params.maxCanvasWidth / params.pixelRatio\n );\n\n /**\n * Whether or not the progress wave is rendered. If the `waveColor`\n * and `progressColor` are the same color it is not.\n * @type {boolean}\n */\n this.hasProgressCanvas = params.waveColor != params.progressColor;\n /**\n * @private\n * @type {number}\n */\n this.halfPixel = 0.5 / params.pixelRatio;\n /**\n * @private\n * @type {Array}\n */\n this.canvases = [];\n /** @private */\n this.progressWave = null;\n }\n\n /**\n * Initialize the drawer\n */\n init() {\n this.createWrapper();\n this.createElements();\n }\n\n /**\n * Create the canvas elements and style them\n *\n * @private\n */\n createElements() {\n this.progressWave = this.wrapper.appendChild(\n this.style(document.createElement('wave'), {\n position: 'absolute',\n zIndex: 3,\n left: 0,\n top: 0,\n bottom: 0,\n overflow: 'hidden',\n width: '0',\n display: 'none',\n boxSizing: 'border-box',\n borderRightStyle: 'solid',\n pointerEvents: 'none'\n })\n );\n\n this.addCanvas();\n this.updateCursor();\n }\n\n /**\n * Update cursor style from params.\n */\n updateCursor() {\n this.style(this.progressWave, {\n borderRightWidth: this.params.cursorWidth + 'px',\n borderRightColor: this.params.cursorColor\n });\n }\n\n /**\n * Adjust to the updated size by adding or removing canvases\n */\n updateSize() {\n const totalWidth = Math.round(this.width / this.params.pixelRatio);\n const requiredCanvases = Math.ceil(\n totalWidth / this.maxCanvasElementWidth\n );\n\n while (this.canvases.length < requiredCanvases) {\n this.addCanvas();\n }\n\n while (this.canvases.length > requiredCanvases) {\n this.removeCanvas();\n }\n\n this.canvases.forEach((entry, i) => {\n // Add some overlap to prevent vertical white stripes, keep the\n // width even for simplicity\n let canvasWidth =\n this.maxCanvasWidth + 2 * Math.ceil(this.params.pixelRatio / 2);\n\n if (i == this.canvases.length - 1) {\n canvasWidth =\n this.width -\n this.maxCanvasWidth * (this.canvases.length - 1);\n }\n\n this.updateDimensions(entry, canvasWidth, this.height);\n this.clearWaveForEntry(entry);\n });\n }\n\n /**\n * Add a canvas to the canvas list\n *\n * @private\n */\n addCanvas() {\n const entry = {};\n const leftOffset = this.maxCanvasElementWidth * this.canvases.length;\n\n entry.wave = this.wrapper.appendChild(\n this.style(document.createElement('canvas'), {\n position: 'absolute',\n zIndex: 2,\n left: leftOffset + 'px',\n top: 0,\n bottom: 0,\n height: '100%',\n pointerEvents: 'none'\n })\n );\n entry.waveCtx = entry.wave.getContext('2d');\n\n if (this.hasProgressCanvas) {\n entry.progress = this.progressWave.appendChild(\n this.style(document.createElement('canvas'), {\n position: 'absolute',\n left: leftOffset + 'px',\n top: 0,\n bottom: 0,\n height: '100%'\n })\n );\n entry.progressCtx = entry.progress.getContext('2d');\n }\n\n this.canvases.push(entry);\n }\n\n /**\n * Pop one canvas from the list\n *\n * @private\n */\n removeCanvas() {\n const lastEntry = this.canvases.pop();\n lastEntry.wave.parentElement.removeChild(lastEntry.wave);\n if (this.hasProgressCanvas) {\n lastEntry.progress.parentElement.removeChild(lastEntry.progress);\n }\n }\n\n /**\n * Update the dimensions of a canvas element\n *\n * @private\n * @param {CanvasEntry} entry\n * @param {number} width The new width of the element\n * @param {number} height The new height of the element\n */\n updateDimensions(entry, width, height) {\n const elementWidth = Math.round(width / this.params.pixelRatio);\n const totalWidth = Math.round(this.width / this.params.pixelRatio);\n\n // Where the canvas starts and ends in the waveform, represented as a\n // decimal between 0 and 1.\n entry.start = entry.waveCtx.canvas.offsetLeft / totalWidth || 0;\n entry.end = entry.start + elementWidth / totalWidth;\n\n entry.waveCtx.canvas.width = width;\n entry.waveCtx.canvas.height = height;\n this.style(entry.waveCtx.canvas, { width: elementWidth + 'px' });\n\n this.style(this.progressWave, { display: 'block' });\n\n if (this.hasProgressCanvas) {\n entry.progressCtx.canvas.width = width;\n entry.progressCtx.canvas.height = height;\n this.style(entry.progressCtx.canvas, {\n width: elementWidth + 'px'\n });\n }\n }\n\n /**\n * Clear the whole waveform\n */\n clearWave() {\n this.canvases.forEach(entry => this.clearWaveForEntry(entry));\n }\n\n /**\n * Clear one canvas\n *\n * @private\n * @param {CanvasEntry} entry\n */\n clearWaveForEntry(entry) {\n entry.waveCtx.clearRect(\n 0,\n 0,\n entry.waveCtx.canvas.width,\n entry.waveCtx.canvas.height\n );\n if (this.hasProgressCanvas) {\n entry.progressCtx.clearRect(\n 0,\n 0,\n entry.progressCtx.canvas.width,\n entry.progressCtx.canvas.height\n );\n }\n }\n\n /**\n * Draw a waveform with bars\n *\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} channelIndex The index of the current channel. Normally\n * should be 0. Must be an integer.\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that should be\n * rendered\n */\n drawBars(peaks, channelIndex, start, end) {\n return this.prepareDraw(\n peaks,\n channelIndex,\n start,\n end,\n ({ absmax, hasMinVals, height, offsetY, halfH, peaks }) => {\n // if drawBars was called within ws.empty we don't pass a start and\n // don't want anything to happen\n if (start === undefined) {\n return;\n }\n // Skip every other value if there are negatives.\n const peakIndexScale = hasMinVals ? 2 : 1;\n const length = peaks.length / peakIndexScale;\n const bar = this.params.barWidth * this.params.pixelRatio;\n const gap =\n this.params.barGap === null\n ? Math.max(this.params.pixelRatio, ~~(bar / 2))\n : Math.max(\n this.params.pixelRatio,\n this.params.barGap * this.params.pixelRatio\n );\n const step = bar + gap;\n\n const scale = length / this.width;\n const first = start;\n const last = end;\n let i;\n\n for (i = first; i < last; i += step) {\n const peak =\n peaks[Math.floor(i * scale * peakIndexScale)] || 0;\n const h = Math.round((peak / absmax) * halfH);\n this.fillRect(\n i + this.halfPixel,\n halfH - h + offsetY,\n bar + this.halfPixel,\n h * 2\n );\n }\n }\n );\n }\n\n /**\n * Draw a waveform\n *\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} channelIndex The index of the current channel. Normally\n * should be 0\n * @param {number?} start The x-offset of the beginning of the area that\n * should be rendered (If this isn't set only a flat line is rendered)\n * @param {number?} end The x-offset of the end of the area that should be\n * rendered\n */\n drawWave(peaks, channelIndex, start, end) {\n return this.prepareDraw(\n peaks,\n channelIndex,\n start,\n end,\n ({ absmax, hasMinVals, height, offsetY, halfH, peaks }) => {\n if (!hasMinVals) {\n const reflectedPeaks = [];\n const len = peaks.length;\n let i;\n for (i = 0; i < len; i++) {\n reflectedPeaks[2 * i] = peaks[i];\n reflectedPeaks[2 * i + 1] = -peaks[i];\n }\n peaks = reflectedPeaks;\n }\n\n // if drawWave was called within ws.empty we don't pass a start and\n // end and simply want a flat line\n if (start !== undefined) {\n this.drawLine(peaks, absmax, halfH, offsetY, start, end);\n }\n\n // Always draw a median line\n this.fillRect(\n 0,\n halfH + offsetY - this.halfPixel,\n this.width,\n this.halfPixel\n );\n }\n );\n }\n\n /**\n * Tell the canvas entries to render their portion of the waveform\n *\n * @private\n * @param {number[]} peaks Peak data\n * @param {number} absmax Maximum peak value (absolute)\n * @param {number} halfH Half the height of the waveform\n * @param {number} offsetY Offset to the top\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that\n * should be rendered\n */\n drawLine(peaks, absmax, halfH, offsetY, start, end) {\n this.canvases.forEach(entry => {\n this.setFillStyles(entry);\n this.drawLineToContext(\n entry,\n entry.waveCtx,\n peaks,\n absmax,\n halfH,\n offsetY,\n start,\n end\n );\n this.drawLineToContext(\n entry,\n entry.progressCtx,\n peaks,\n absmax,\n halfH,\n offsetY,\n start,\n end\n );\n });\n }\n\n /**\n * Render the actual waveform line on a canvas\n *\n * @private\n * @param {CanvasEntry} entry\n * @param {Canvas2DContextAttributes} ctx Essentially `entry.[wave|progress]Ctx`\n * @param {number[]} peaks\n * @param {number} absmax Maximum peak value (absolute)\n * @param {number} halfH Half the height of the waveform\n * @param {number} offsetY Offset to the top\n * @param {number} start The x-offset of the beginning of the area that\n * should be rendered\n * @param {number} end The x-offset of the end of the area that\n * should be rendered\n */\n drawLineToContext(entry, ctx, peaks, absmax, halfH, offsetY, start, end) {\n if (!ctx) {\n return;\n }\n\n const length = peaks.length / 2;\n const scale =\n this.params.fillParent && this.width != length\n ? this.width / length\n : 1;\n\n const first = Math.round(length * entry.start);\n // Use one more peak value to make sure we join peaks at ends -- unless,\n // of course, this is the last canvas.\n const last = Math.round(length * entry.end) + 1;\n if (first > end || last < start) {\n return;\n }\n const canvasStart = Math.min(first, start);\n const canvasEnd = Math.max(last, end);\n let i;\n let j;\n\n ctx.beginPath();\n ctx.moveTo(\n (canvasStart - first) * scale + this.halfPixel,\n halfH + offsetY\n );\n\n for (i = canvasStart; i < canvasEnd; i++) {\n const peak = peaks[2 * i] || 0;\n const h = Math.round((peak / absmax) * halfH);\n ctx.lineTo(\n (i - first) * scale + this.halfPixel,\n halfH - h + offsetY\n );\n }\n\n // Draw the bottom edge going backwards, to make a single\n // closed hull to fill.\n for (j = canvasEnd - 1; j >= canvasStart; j--) {\n const peak = peaks[2 * j + 1] || 0;\n const h = Math.round((peak / absmax) * halfH);\n ctx.lineTo(\n (j - first) * scale + this.halfPixel,\n halfH - h + offsetY\n );\n }\n\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Draw a rectangle on the waveform\n *\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n */\n fillRect(x, y, width, height) {\n const startCanvas = Math.floor(x / this.maxCanvasWidth);\n const endCanvas = Math.min(\n Math.ceil((x + width) / this.maxCanvasWidth) + 1,\n this.canvases.length\n );\n let i;\n for (i = startCanvas; i < endCanvas; i++) {\n const entry = this.canvases[i];\n const leftOffset = i * this.maxCanvasWidth;\n\n const intersection = {\n x1: Math.max(x, i * this.maxCanvasWidth),\n y1: y,\n x2: Math.min(\n x + width,\n i * this.maxCanvasWidth + entry.waveCtx.canvas.width\n ),\n y2: y + height\n };\n\n if (intersection.x1 < intersection.x2) {\n this.setFillStyles(entry);\n\n this.fillRectToContext(\n entry.waveCtx,\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n\n this.fillRectToContext(\n entry.progressCtx,\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n }\n }\n }\n\n /**\n * Performs preparation tasks and calculations which are shared by drawBars and drawWave\n *\n * @private\n * @param {number[]|number[][]} peaks Can also be an array of arrays for split channel\n * rendering\n * @param {number} channelIndex The index of the current channel. Normally\n * should be 0\n * @param {number?} start The x-offset of the beginning of the area that\n * should be rendered (If this isn't set only a flat line is rendered)\n * @param {number?} end The x-offset of the end of the area that should be\n * rendered\n * @param {function} fn The render function to call\n */\n prepareDraw(peaks, channelIndex, start, end, fn) {\n return util.frame(() => {\n // Split channels and call this function with the channelIndex set\n if (peaks[0] instanceof Array) {\n const channels = peaks;\n if (this.params.splitChannels) {\n this.setHeight(\n channels.length *\n this.params.height *\n this.params.pixelRatio\n );\n return channels.forEach((channelPeaks, i) =>\n this.prepareDraw(channelPeaks, i, start, end, fn)\n );\n }\n peaks = channels[0];\n }\n // calculate maximum modulation value, either from the barHeight\n // parameter or if normalize=true from the largest value in the peak\n // set\n let absmax = 1 / this.params.barHeight;\n if (this.params.normalize) {\n const max = util.max(peaks);\n const min = util.min(peaks);\n absmax = -min > max ? -min : max;\n }\n\n // Bar wave draws the bottom only as a reflection of the top,\n // so we don't need negative values\n const hasMinVals = [].some.call(peaks, val => val < 0);\n const height = this.params.height * this.params.pixelRatio;\n const offsetY = height * channelIndex || 0;\n const halfH = height / 2;\n\n return fn({\n absmax: absmax,\n hasMinVals: hasMinVals,\n height: height,\n offsetY: offsetY,\n halfH: halfH,\n peaks: peaks\n });\n })();\n }\n\n /**\n * Draw the actual rectangle on a canvas\n *\n * @private\n * @param {Canvas2DContextAttributes} ctx\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n */\n fillRectToContext(ctx, x, y, width, height) {\n if (!ctx) {\n return;\n }\n ctx.fillRect(x, y, width, height);\n }\n\n /**\n * Set the fill styles for a certain entry (wave and progress)\n *\n * @private\n * @param {CanvasEntry} entry\n */\n setFillStyles(entry) {\n entry.waveCtx.fillStyle = this.params.waveColor;\n if (this.hasProgressCanvas) {\n entry.progressCtx.fillStyle = this.params.progressColor;\n }\n }\n\n /**\n * Return image data of the waveform\n *\n * @param {string} type='image/png' An optional value of a format type.\n * @param {number} quality=0.92 An optional value between 0 and 1.\n * @return {string|string[]} images A data URL or an array of data URLs\n */\n getImage(type, quality) {\n const images = this.canvases.map(entry =>\n entry.wave.toDataURL(type, quality)\n );\n return images.length > 1 ? images : images[0];\n }\n\n /**\n * Render the new progress\n *\n * @param {number} position X-Offset of progress position in pixels\n */\n updateProgress(position) {\n this.style(this.progressWave, { width: position + 'px' });\n }\n}\n","import WebAudio from './webaudio';\nimport * as util from './util';\n\n/**\n * MediaElement backend\n */\nexport default class MediaElement extends WebAudio {\n /**\n * Construct the backend\n *\n * @param {WavesurferParams} params\n */\n constructor(params) {\n super(params);\n /** @private */\n this.params = params;\n\n // Dummy media to catch errors\n /** @private */\n this.media = {\n currentTime: 0,\n duration: 0,\n paused: true,\n playbackRate: 1,\n play() {},\n pause() {},\n volume: 0\n };\n\n /** @private */\n this.mediaType = params.mediaType.toLowerCase();\n /** @private */\n this.elementPosition = params.elementPosition;\n /** @private */\n this.peaks = null;\n /** @private */\n this.playbackRate = 1;\n /** @private */\n this.volume = 1;\n /** @private */\n this.buffer = null;\n /** @private */\n this.onPlayEnd = null;\n }\n\n /**\n * Initialise the backend, called in `wavesurfer.createBackend()`\n */\n init() {\n this.setPlaybackRate(this.params.audioRate);\n this.createTimer();\n }\n\n /**\n * Create a timer to provide a more precise `audioprocess` event.\n *\n * @private\n */\n createTimer() {\n const onAudioProcess = () => {\n if (this.isPaused()) {\n return;\n }\n this.fireEvent('audioprocess', this.getCurrentTime());\n\n // Call again in the next frame\n const requestAnimationFrame =\n window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame;\n requestAnimationFrame(onAudioProcess);\n };\n\n this.on('play', onAudioProcess);\n\n // Update the progress one more time to prevent it from being stuck in\n // case of lower framerates\n this.on('pause', () => {\n this.fireEvent('audioprocess', this.getCurrentTime());\n });\n }\n\n /**\n * Create media element with url as its source,\n * and append to container element.\n *\n * @param {string} url Path to media file\n * @param {HTMLElement} container HTML element\n * @param {number[]|number[][]} peaks Array of peak data\n * @param {string} preload HTML 5 preload attribute value\n */\n load(url, container, peaks, preload) {\n const media = document.createElement(this.mediaType);\n media.controls = this.params.mediaControls;\n media.autoplay = this.params.autoplay || false;\n media.preload = preload == null ? 'auto' : preload;\n media.src = url;\n media.style.width = '100%';\n\n const prevMedia = container.querySelector(this.mediaType);\n if (prevMedia) {\n container.removeChild(prevMedia);\n }\n container.appendChild(media);\n\n this._load(media, peaks);\n }\n\n /**\n * Load existing media element.\n *\n * @param {HTMLMediaElement} elt HTML5 Audio or Video element\n * @param {number[]|number[][]} peaks Array of peak data\n */\n loadElt(elt, peaks) {\n elt.controls = this.params.mediaControls;\n elt.autoplay = this.params.autoplay || false;\n\n this._load(elt, peaks);\n }\n\n /**\n * Private method called by both load (from url)\n * and loadElt (existing media element).\n *\n * @param {HTMLMediaElement} media HTML5 Audio or Video element\n * @param {number[]|number[][]} peaks Array of peak data\n * @private\n */\n _load(media, peaks) {\n // load must be called manually on iOS, otherwise peaks won't draw\n // until a user interaction triggers load --> 'ready' event\n if (typeof media.load == 'function') {\n // Resets the media element and restarts the media resource. Any\n // pending events are discarded. How much media data is fetched is\n // still affected by the preload attribute.\n media.load();\n }\n\n media.addEventListener('error', () => {\n this.fireEvent('error', 'Error loading media element');\n });\n\n media.addEventListener('canplay', () => {\n this.fireEvent('canplay');\n });\n\n media.addEventListener('ended', () => {\n this.fireEvent('finish');\n });\n\n // Listen to and relay play and pause events to enable\n // playback control from the external media element\n media.addEventListener('play', () => {\n this.fireEvent('play');\n });\n\n media.addEventListener('pause', () => {\n this.fireEvent('pause');\n });\n\n this.media = media;\n this.peaks = peaks;\n this.onPlayEnd = null;\n this.buffer = null;\n this.setPlaybackRate(this.playbackRate);\n this.setVolume(this.volume);\n }\n\n /**\n * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`\n *\n * @return {boolean}\n */\n isPaused() {\n return !this.media || this.media.paused;\n }\n\n /**\n * Used by `wavesurfer.getDuration()`\n *\n * @return {number}\n */\n getDuration() {\n if (this.explicitDuration) {\n return this.explicitDuration;\n }\n let duration = (this.buffer || this.media).duration;\n if (duration >= Infinity) {\n // streaming audio\n duration = this.media.seekable.end(0);\n }\n return duration;\n }\n\n /**\n * Returns the current time in seconds relative to the audio-clip's\n * duration.\n *\n * @return {number}\n */\n getCurrentTime() {\n return this.media && this.media.currentTime;\n }\n\n /**\n * Get the position from 0 to 1\n *\n * @return {number}\n */\n getPlayedPercents() {\n return this.getCurrentTime() / this.getDuration() || 0;\n }\n\n /**\n * Get the audio source playback rate.\n *\n * @return {number}\n */\n getPlaybackRate() {\n return this.playbackRate || this.media.playbackRate;\n }\n\n /**\n * Set the audio source playback rate.\n *\n * @param {number} value\n */\n setPlaybackRate(value) {\n this.playbackRate = value || 1;\n this.media.playbackRate = this.playbackRate;\n }\n\n /**\n * Used by `wavesurfer.seekTo()`\n *\n * @param {number} start Position to start at in seconds\n */\n seekTo(start) {\n if (start != null) {\n this.media.currentTime = start;\n }\n this.clearPlayEnd();\n }\n\n /**\n * Plays the loaded audio region.\n *\n * @param {number} start Start offset in seconds, relative to the beginning\n * of a clip.\n * @param {number} end When to stop, relative to the beginning of a clip.\n * @emits MediaElement#play\n * @return {Promise}\n */\n play(start, end) {\n this.seekTo(start);\n const promise = this.media.play();\n end && this.setPlayEnd(end);\n\n return promise;\n }\n\n /**\n * Pauses the loaded audio.\n *\n * @emits MediaElement#pause\n * @return {Promise}\n */\n pause() {\n let promise;\n\n if (this.media) {\n promise = this.media.pause();\n }\n this.clearPlayEnd();\n\n return promise;\n }\n\n /** @private */\n setPlayEnd(end) {\n this._onPlayEnd = time => {\n if (time >= end) {\n this.pause();\n this.seekTo(end);\n }\n };\n this.on('audioprocess', this._onPlayEnd);\n }\n\n /** @private */\n clearPlayEnd() {\n if (this._onPlayEnd) {\n this.un('audioprocess', this._onPlayEnd);\n this._onPlayEnd = null;\n }\n }\n\n /**\n * Compute the max and min value of the waveform when broken into\n * <length> subranges.\n *\n * @param {number} length How many subranges to break the waveform into.\n * @param {number} first First sample in the required range.\n * @param {number} last Last sample in the required range.\n * @return {number[]|number[][]} Array of 2*<length> peaks or array of\n * arrays of peaks consisting of (max, min) values for each subrange.\n */\n getPeaks(length, first, last) {\n if (this.buffer) {\n return super.getPeaks(length, first, last);\n }\n return this.peaks || [];\n }\n\n /**\n * Set the sink id for the media player\n *\n * @param {string} deviceId String value representing audio device id.\n */\n setSinkId(deviceId) {\n if (deviceId) {\n if (!this.media.setSinkId) {\n return Promise.reject(\n new Error('setSinkId is not supported in your browser')\n );\n }\n return this.media.setSinkId(deviceId);\n }\n\n return Promise.reject(new Error('Invalid deviceId: ' + deviceId));\n }\n\n /**\n * Get the current volume\n *\n * @return {number} value A floating point value between 0 and 1.\n */\n getVolume() {\n return this.volume || this.media.volume;\n }\n\n /**\n * Set the audio volume\n *\n * @param {number} value A floating point value between 0 and 1.\n */\n setVolume(value) {\n this.volume = value;\n this.media.volume = this.volume;\n }\n\n /**\n * This is called when wavesurfer is destroyed\n *\n */\n destroy() {\n this.pause();\n this.unAll();\n\n if (\n this.params.removeMediaElementOnDestroy &&\n this.media &&\n this.media.parentNode\n ) {\n this.media.parentNode.removeChild(this.media);\n }\n\n this.media = null;\n }\n}\n","/**\n * Caches the decoded peaks data to improve rendering speed for large audio\n *\n * Is used if the option parameter `partialRender` is set to `true`\n */\nexport default class PeakCache {\n /**\n * Instantiate cache\n */\n constructor() {\n this.clearPeakCache();\n }\n\n /**\n * Empty the cache\n */\n clearPeakCache() {\n /**\n * Flat array with entries that are always in pairs to mark the\n * beginning and end of each subrange. This is a convenience so we can\n * iterate over the pairs for easy set difference operations.\n * @private\n */\n this.peakCacheRanges = [];\n /**\n * Length of the entire cachable region, used for resetting the cache\n * when this changes (zoom events, for instance).\n * @private\n */\n this.peakCacheLength = -1;\n }\n\n /**\n * Add a range of peaks to the cache\n *\n * @param {number} length The length of the range\n * @param {number} start The x offset of the start of the range\n * @param {number} end The x offset of the end of the range\n * @return {number[][]}\n */\n addRangeToPeakCache(length, start, end) {\n if (length != this.peakCacheLength) {\n this.clearPeakCache();\n this.peakCacheLength = length;\n }\n\n // Return ranges that weren't in the cache before the call.\n let uncachedRanges = [];\n let i = 0;\n // Skip ranges before the current start.\n while (\n i < this.peakCacheRanges.length &&\n this.peakCacheRanges[i] < start\n ) {\n i++;\n }\n // If |i| is even, |start| falls after an existing range. Otherwise,\n // |start| falls between an existing range, and the uncached region\n // starts when we encounter the next node in |peakCacheRanges| or\n // |end|, whichever comes first.\n if (i % 2 == 0) {\n uncachedRanges.push(start);\n }\n while (\n i < this.peakCacheRanges.length &&\n this.peakCacheRanges[i] <= end\n ) {\n uncachedRanges.push(this.peakCacheRanges[i]);\n i++;\n }\n // If |i| is even, |end| is after all existing ranges.\n if (i % 2 == 0) {\n uncachedRanges.push(end);\n }\n\n // Filter out the 0-length ranges.\n uncachedRanges = uncachedRanges.filter((item, pos, arr) => {\n if (pos == 0) {\n return item != arr[pos + 1];\n } else if (pos == arr.length - 1) {\n return item != arr[pos - 1];\n }\n return item != arr[pos - 1] && item != arr[pos + 1];\n });\n\n // Merge the two ranges together, uncachedRanges will either contain\n // wholly new points, or duplicates of points in peakCacheRanges. If\n // duplicates are detected, remove both and extend the range.\n this.peakCacheRanges = this.peakCacheRanges.concat(uncachedRanges);\n this.peakCacheRanges = this.peakCacheRanges\n .sort((a, b) => a - b)\n .filter((item, pos, arr) => {\n if (pos == 0) {\n return item != arr[pos + 1];\n } else if (pos == arr.length - 1) {\n return item != arr[pos - 1];\n }\n return item != arr[pos - 1] && item != arr[pos + 1];\n });\n\n // Push the uncached ranges into an array of arrays for ease of\n // iteration in the functions that call this.\n const uncachedRangePairs = [];\n for (i = 0; i < uncachedRanges.length; i += 2) {\n uncachedRangePairs.push([uncachedRanges[i], uncachedRanges[i + 1]]);\n }\n\n return uncachedRangePairs;\n }\n\n /**\n * For testing\n *\n * @return {number[][]}\n */\n getCacheRanges() {\n const peakCacheRangePairs = [];\n let i;\n for (i = 0; i < this.peakCacheRanges.length; i += 2) {\n peakCacheRangePairs.push([\n this.peakCacheRanges[i],\n this.peakCacheRanges[i + 1]\n ]);\n }\n return peakCacheRangePairs;\n }\n}\n","import Observer from './observer';\n\n/**\n * Perform an ajax request\n *\n * @param {Options} options Description\n *\n * @returns {Object} Observer instance\n */\nexport default function ajax(options) {\n const instance = new Observer();\n const xhr = new XMLHttpRequest();\n let fired100 = false;\n xhr.open(options.method || 'GET', options.url, true);\n xhr.responseType = options.responseType || 'json';\n\n if (options.xhr) {\n if (options.xhr.requestHeaders) {\n // add custom request headers\n options.xhr.requestHeaders.forEach(header => {\n xhr.setRequestHeader(header.key, header.value);\n });\n }\n if (options.xhr.withCredentials) {\n // use credentials\n xhr.withCredentials = true;\n }\n }\n\n xhr.addEventListener('progress', e => {\n instance.fireEvent('progress', e);\n if (e.lengthComputable && e.loaded == e.total) {\n fired100 = true;\n }\n });\n xhr.addEventListener('load', e => {\n if (!fired100) {\n instance.fireEvent('progress', e);\n }\n instance.fireEvent('load', e);\n if (200 == xhr.status || 206 == xhr.status) {\n instance.fireEvent('success', xhr.response, e);\n } else {\n instance.fireEvent('error', e);\n }\n });\n xhr.addEventListener('error', e => instance.fireEvent('error', e));\n xhr.send();\n instance.xhr = xhr;\n return instance;\n}\n","/**\n * Extend an object shallowly with others\n *\n * @param {Object} dest The target object\n * @param {Object[]} sources The objects to use for extending\n *\n * @return {Object} Merged object\n */\nexport default function extend(dest, ...sources) {\n sources.forEach(source => {\n Object.keys(source).forEach(key => {\n dest[key] = source[key];\n });\n });\n return dest;\n}\n","import reqAnimationFrame from './request-animation-frame';\n\n/**\n * Create a function which will be called at the next requestAnimationFrame\n * cycle\n *\n * @param {function} func The function to call\n *\n * @return {func} The function wrapped within a requestAnimationFrame\n */\nexport default function frame(func) {\n return (...args) => reqAnimationFrame(() => func(...args));\n}\n","/**\n * Get a random prefixed ID\n *\n * @returns {String} Random ID\n */\nexport default function getId() {\n return (\n 'wavesurfer_' +\n Math.random()\n .toString(32)\n .substring(2)\n );\n}\n","export { default as ajax } from './ajax';\nexport { default as getId } from './get-id';\nexport { default as max } from './max';\nexport { default as min } from './min';\nexport { default as Observer } from './observer';\nexport { default as extend } from './extend';\nexport { default as style } from './style';\nexport { default as requestAnimationFrame } from './request-animation-frame';\nexport { default as frame } from './frame';\nexport { default as debounce } from 'debounce';\nexport { default as preventClick } from './prevent-click';\n","/**\n * Get the largest value\n *\n * @param {Array} values Array of numbers\n * @returns {Number} Largest number found\n */\nexport default function max(values) {\n let largest = -Infinity;\n Object.keys(values).forEach(i => {\n if (values[i] > largest) {\n largest = values[i];\n }\n });\n return largest;\n}\n","/**\n * Get the smallest value\n *\n * @param {Array} values Array of numbers\n * @returns {Number} Smallest number found\n */\nexport default function min(values) {\n let smallest = Number(Infinity);\n Object.keys(values).forEach(i => {\n if (values[i] < smallest) {\n smallest = values[i];\n }\n });\n return smallest;\n}\n","/**\n * @typedef {Object} ListenerDescriptor\n * @property {string} name The name of the event\n * @property {function} callback The callback\n * @property {function} un The function to call to remove the listener\n */\n\n/**\n * Observer class\n */\nexport default class Observer {\n /**\n * Instantiate Observer\n */\n constructor() {\n /**\n * @private\n * @todo Initialise the handlers here already and remove the conditional\n * assignment in `on()`\n */\n this.handlers = null;\n }\n /**\n * Attach a handler function for an event.\n *\n * @param {string} event Name of the event to listen to\n * @param {function} fn The callback to trigger when the event is fired\n * @return {ListenerDescriptor}\n */\n on(event, fn) {\n if (!this.handlers) {\n this.handlers = {};\n }\n\n let handlers = this.handlers[event];\n if (!handlers) {\n handlers = this.handlers[event] = [];\n }\n handlers.push(fn);\n\n // Return an event descriptor\n return {\n name: event,\n callback: fn,\n un: (e, fn) => this.un(e, fn)\n };\n }\n\n /**\n * Remove an event handler.\n *\n * @param {string} event Name of the event the listener that should be\n * removed listens to\n * @param {function} fn The callback that should be removed\n */\n un(event, fn) {\n if (!this.handlers) {\n return;\n }\n\n const handlers = this.handlers[event];\n let i;\n if (handlers) {\n if (fn) {\n for (i = handlers.length - 1; i >= 0; i--) {\n if (handlers[i] == fn) {\n handlers.splice(i, 1);\n }\n }\n } else {\n handlers.length = 0;\n }\n }\n }\n\n /**\n * Remove all event handlers.\n */\n unAll() {\n this.handlers = null;\n }\n\n /**\n * Attach a handler to an event. The handler is executed at most once per\n * event type.\n *\n * @param {string} event The event to listen to\n * @param {function} handler The callback that is only to be called once\n * @return {ListenerDescriptor}\n */\n once(event, handler) {\n const fn = (...args) => {\n /* eslint-disable no-invalid-this */\n handler.apply(this, args);\n /* eslint-enable no-invalid-this */\n setTimeout(() => {\n this.un(event, fn);\n }, 0);\n };\n return this.on(event, fn);\n }\n\n /**\n * Manually fire an event\n *\n * @param {string} event The event to fire manually\n * @param {...any} args The arguments with which to call the listeners\n */\n fireEvent(event, ...args) {\n if (!this.handlers) {\n return;\n }\n const handlers = this.handlers[event];\n handlers &&\n handlers.forEach(fn => {\n fn(...args);\n });\n }\n}\n","function preventClickHandler(e) {\n e.stopPropagation();\n document.body.removeEventListener('click', preventClickHandler, true);\n}\n\nexport default function preventClick(values) {\n document.body.addEventListener('click', preventClickHandler, true);\n}\n","/**\n * Returns the requestAnimationFrame function for the browser, or a shim with\n * setTimeout if none is found\n *\n * @return {function}\n */\nexport default (\n window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.oRequestAnimationFrame ||\n window.msRequestAnimationFrame ||\n ((callback, element) => setTimeout(callback, 1000 / 60))\n).bind(window);\n","/**\n * Apply a map of styles to an element\n *\n * @param {HTMLElement} el The element that the styles will be applied to\n * @param {Object} styles The map of propName: attribute, both are used as-is\n *\n * @return {HTMLElement} el\n */\nexport default function style(el, styles) {\n Object.keys(styles).forEach(prop => {\n if (el.style[prop] !== styles[prop]) {\n el.style[prop] = styles[prop];\n }\n });\n return el;\n}\n","import * as util from './util';\nimport MultiCanvas from './drawer.multicanvas';\nimport WebAudio from './webaudio';\nimport MediaElement from './mediaelement';\nimport PeakCache from './peakcache';\n\n/*\n * This work is licensed under a BSD-3-Clause License.\n */\n\n/** @external {HTMLElement} https://developer.mozilla.org/en/docs/Web/API/HTMLElement */\n/** @external {OfflineAudioContext} https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext */\n/** @external {File} https://developer.mozilla.org/en-US/docs/Web/API/File */\n/** @external {Blob} https://developer.mozilla.org/en-US/docs/Web/API/Blob */\n/** @external {CanvasRenderingContext2D} https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D */\n/** @external {MediaStreamConstraints} https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints */\n/** @external {AudioNode} https://developer.mozilla.org/de/docs/Web/API/AudioNode */\n\n/**\n * @typedef {Object} WavesurferParams\n * @property {AudioContext} audioContext=null Use your own previously\n * initialized AudioContext or leave blank.\n * @property {number} audioRate=1 Speed at which to play audio. Lower number is\n * slower.\n * @property {ScriptProcessorNode} audioScriptProcessor=null Use your own previously\n * initialized ScriptProcessorNode or leave blank.\n * @property {boolean} autoCenter=true If a scrollbar is present, center the\n * waveform around the progress\n * @property {string} backend='WebAudio' `'WebAudio'|'MediaElement'` In most cases\n * you don't have to set this manually. MediaElement is a fallback for\n * unsupported browsers.\n * @property {number} barHeight=1 The height of the wave\n * @property {number} barGap=null The optional spacing between bars of the wave,\n * if not provided will be calculated in legacy format.\n * @property {boolean} closeAudioContext=false Close and nullify all audio\n * contexts when the destroy method is called.\n * @property {!string|HTMLElement} container CSS selector or HTML element where\n * the waveform should be drawn. This is the only required parameter.\n * @property {string} cursorColor='#333' The fill color of the cursor indicating\n * the playhead position.\n * @property {number} cursorWidth=1 Measured in pixels.\n * @property {boolean} fillParent=true Whether to fill the entire container or\n * draw only according to `minPxPerSec`.\n * @property {boolean} forceDecode=false Force decoding of audio using web audio\n * when zooming to get a more detailed waveform.\n * @property {number} height=128 The height of the waveform. Measured in\n * pixels.\n * @property {boolean} hideScrollbar=false Whether to hide the horizontal\n * scrollbar when one would normally be shown.\n * @property {boolean} interact=true Whether the mouse interaction will be\n * enabled at initialization. You can switch this parameter at any time later\n * on.\n * @property {boolean} loopSelection=true (Use with regions plugin) Enable\n * looping of selected regions\n * @property {number} maxCanvasWidth=4000 Maximum width of a single canvas in\n * pixels, excluding a small overlap (2 * `pixelRatio`, rounded up to the next\n * even integer). If the waveform is longer than this value, additional canvases\n * will be used to render the waveform, which is useful for very large waveforms\n * that may be too wide for browsers to draw on a single canvas.\n * @property {boolean} mediaControls=false (Use with backend `MediaElement`)\n * this enables the native controls for the media element\n * @property {string} mediaType='audio' (Use with backend `MediaElement`)\n * `'audio'|'video'`\n * @property {number} minPxPerSec=20 Minimum number of pixels per second of\n * audio.\n * @property {boolean} normalize=false If true, normalize by the maximum peak\n * instead of 1.0.\n * @property {boolean} partialRender=false Use the PeakCache to improve\n * rendering speed of large waveforms\n * @property {number} pixelRatio=window.devicePixelRatio The pixel ratio used to\n * calculate display\n * @property {PluginDefinition[]} plugins=[] An array of plugin definitions to\n * register during instantiation, they will be directly initialised unless they\n * are added with the `deferInit` property set to true.\n * @property {string} progressColor='#555' The fill color of the part of the\n * waveform behind the cursor.\n * @property {boolean} removeMediaElementOnDestroy=true Set to false to keep the\n * media element in the DOM when the player is destroyed. This is useful when\n * reusing an existing media element via the `loadMediaElement` method.\n * @property {Object} renderer=MultiCanvas Can be used to inject a custom\n * renderer.\n * @property {boolean|number} responsive=false If set to `true` resize the\n * waveform, when the window is resized. This is debounced with a `100ms`\n * timeout by default. If this parameter is a number it represents that timeout.\n * @property {boolean} scrollParent=false Whether to scroll the container with a\n * lengthy waveform. Otherwise the waveform is shrunk to the container width\n * (see fillParent).\n * @property {number} skipLength=2 Number of seconds to skip with the\n * skipForward() and skipBackward() methods.\n * @property {boolean} splitChannels=false Render with separate waveforms for\n * the channels of the audio\n * @property {string} waveColor='#999' The fill color of the waveform after the\n * cursor.\n * @property {object} xhr={} XHR options.\n */\n\n/**\n * @typedef {Object} PluginDefinition\n * @desc The Object used to describe a plugin\n * @example wavesurfer.addPlugin(pluginDefinition);\n * @property {string} name The name of the plugin, the plugin instance will be\n * added as a property to the wavesurfer instance under this name\n * @property {?Object} staticProps The properties that should be added to the\n * wavesurfer instance as static properties\n * @property {?boolean} deferInit Don't initialise plugin\n * automatically\n * @property {Object} params={} The plugin parameters, they are the first parameter\n * passed to the plugin class constructor function\n * @property {PluginClass} instance The plugin instance factory, is called with\n * the dependency specified in extends. Returns the plugin class.\n */\n\n/**\n * @interface PluginClass\n *\n * @desc This is the interface which is implemented by all plugin classes. Note\n * that this only turns into an observer after being passed through\n * `wavesurfer.addPlugin`.\n *\n * @extends {Observer}\n */\nclass PluginClass {\n /**\n * Plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {Object} params={} The plugin params (specific to the plugin)\n * @return {PluginDefinition} an object representing the plugin\n */\n create(params) {}\n /**\n * Construct the plugin\n *\n * @param {Object} params={} The plugin params (specific to the plugin)\n * @param {Object} ws The wavesurfer instance\n */\n constructor(params, ws) {}\n /**\n * Initialise the plugin\n *\n * Start doing something. This is called by\n * `wavesurfer.initPlugin(pluginName)`\n */\n init() {}\n /**\n * Destroy the plugin instance\n *\n * Stop doing something. This is called by\n * `wavesurfer.destroyPlugin(pluginName)`\n */\n destroy() {}\n}\n\n/**\n * WaveSurfer core library class\n *\n * @extends {Observer}\n * @example\n * const params = {\n * container: '#waveform',\n * waveColor: 'violet',\n * progressColor: 'purple'\n * };\n *\n * // initialise like this\n * const wavesurfer = WaveSurfer.create(params);\n *\n * // or like this ...\n * const wavesurfer = new WaveSurfer(params);\n * wavesurfer.init();\n *\n * // load audio file\n * wavesurfer.load('example/media/demo.wav');\n */\nexport default class WaveSurfer extends util.Observer {\n /** @private */\n defaultParams = {\n audioContext: null,\n audioScriptProcessor: null,\n audioRate: 1,\n autoCenter: true,\n backend: 'WebAudio',\n barHeight: 1,\n barGap: null,\n container: null,\n cursorColor: '#333',\n cursorWidth: 1,\n dragSelection: true,\n fillParent: true,\n forceDecode: false,\n height: 128,\n hideScrollbar: false,\n interact: true,\n loopSelection: true,\n maxCanvasWidth: 4000,\n mediaContainer: null,\n mediaControls: false,\n mediaType: 'audio',\n minPxPerSec: 20,\n normalize: false,\n partialRender: false,\n pixelRatio:\n window.devicePixelRatio || screen.deviceXDPI / screen.logicalXDPI,\n plugins: [],\n progressColor: '#555',\n removeMediaElementOnDestroy: true,\n renderer: MultiCanvas,\n responsive: false,\n scrollParent: false,\n skipLength: 2,\n splitChannels: false,\n waveColor: '#999',\n xhr: {}\n };\n\n /** @private */\n backends = {\n MediaElement,\n WebAudio\n };\n\n /**\n * Instantiate this class, call its `init` function and returns it\n *\n * @param {WavesurferParams} params\n * @return {Object} WaveSurfer instance\n * @example const wavesurfer = WaveSurfer.create(params);\n */\n static create(params) {\n const wavesurfer = new WaveSurfer(params);\n return wavesurfer.init();\n }\n\n /**\n * The library version number is available as a static property of the\n * WaveSurfer class\n *\n * @type {String}\n * @example\n * console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);\n */\n static VERSION = __VERSION__;\n\n /**\n * Functions in the `util` property are available as a prototype property to\n * all instances\n *\n * @type {Object}\n * @example\n * const wavesurfer = WaveSurfer.create(params);\n * wavesurfer.util.style(myElement, { background: 'blue' });\n */\n util = util;\n\n /**\n * Functions in the `util` property are available as a static property of the\n * WaveSurfer class\n *\n * @type {Object}\n * @example\n * WaveSurfer.util.style(myElement, { background: 'blue' });\n */\n static util = util;\n\n /**\n * Initialise wavesurfer instance\n *\n * @param {WavesurferParams} params Instantiation options for wavesurfer\n * @example\n * const wavesurfer = new WaveSurfer(params);\n * @returns {this}\n */\n constructor(params) {\n super();\n /**\n * Extract relevant parameters (or defaults)\n * @private\n */\n this.params = util.extend({}, this.defaultParams, params);\n\n /** @private */\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(this.params.container)\n : this.params.container;\n\n if (!this.container) {\n throw new Error('Container element not found');\n }\n\n if (this.params.mediaContainer == null) {\n /** @private */\n this.mediaContainer = this.container;\n } else if (typeof this.params.mediaContainer == 'string') {\n /** @private */\n this.mediaContainer = document.querySelector(\n this.params.mediaContainer\n );\n } else {\n /** @private */\n this.mediaContainer = this.params.mediaContainer;\n }\n\n if (!this.mediaContainer) {\n throw new Error('Media Container element not found');\n }\n\n if (this.params.maxCanvasWidth <= 1) {\n throw new Error('maxCanvasWidth must be greater than 1');\n } else if (this.params.maxCanvasWidth % 2 == 1) {\n throw new Error('maxCanvasWidth must be an even number');\n }\n\n /**\n * @private Used to save the current volume when muting so we can\n * restore once unmuted\n * @type {number}\n */\n this.savedVolume = 0;\n\n /**\n * @private The current muted state\n * @type {boolean}\n */\n this.isMuted = false;\n\n /**\n * @private Will hold a list of event descriptors that need to be\n * canceled on subsequent loads of audio\n * @type {Object[]}\n */\n this.tmpEvents = [];\n\n /**\n * @private Holds any running audio downloads\n * @type {Observer}\n */\n this.currentAjax = null;\n /** @private */\n this.arraybuffer = null;\n /** @private */\n this.drawer = null;\n /** @private */\n this.backend = null;\n /** @private */\n this.peakCache = null;\n\n // cache constructor objects\n if (typeof this.params.renderer !== 'function') {\n throw new Error('Renderer parameter is invalid');\n }\n /**\n * @private The uninitialised Drawer class\n */\n this.Drawer = this.params.renderer;\n /**\n * @private The uninitialised Backend class\n */\n this.Backend = this.backends[this.params.backend];\n\n /**\n * @private map of plugin names that are currently initialised\n */\n this.initialisedPluginList = {};\n /** @private */\n this.isDestroyed = false;\n /** @private */\n this.isReady = false;\n\n // responsive debounced event listener. If this.params.responsive is not\n // set, this is never called. Use 100ms or this.params.responsive as\n // timeout for the debounce function.\n let prevWidth = 0;\n this._onResize = util.debounce(\n () => {\n if (\n prevWidth != this.drawer.wrapper.clientWidth &&\n !this.params.scrollParent\n ) {\n prevWidth = this.drawer.wrapper.clientWidth;\n this.drawer.fireEvent('redraw');\n }\n },\n typeof this.params.responsive === 'number'\n ? this.params.responsive\n : 100\n );\n\n return this;\n }\n\n /**\n * Initialise the wave\n *\n * @example\n * var wavesurfer = new WaveSurfer(params);\n * wavesurfer.init();\n * @return {this}\n */\n init() {\n this.registerPlugins(this.params.plugins);\n this.createDrawer();\n this.createBackend();\n this.createPeakCache();\n return this;\n }\n\n /**\n * Add and initialise array of plugins (if `plugin.deferInit` is falsey),\n * this function is called in the init function of wavesurfer\n *\n * @param {PluginDefinition[]} plugins An array of plugin definitions\n * @emits {WaveSurfer#plugins-registered} Called with the array of plugin definitions\n * @return {this}\n */\n registerPlugins(plugins) {\n // first instantiate all the plugins\n plugins.forEach(plugin => this.addPlugin(plugin));\n\n // now run the init functions\n plugins.forEach(plugin => {\n // call init function of the plugin if deferInit is falsey\n // in that case you would manually use initPlugins()\n if (!plugin.deferInit) {\n this.initPlugin(plugin.name);\n }\n });\n this.fireEvent('plugins-registered', plugins);\n return this;\n }\n\n /**\n * Add a plugin object to wavesurfer\n *\n * @param {PluginDefinition} plugin A plugin definition\n * @emits {WaveSurfer#plugin-added} Called with the name of the plugin that was added\n * @example wavesurfer.addPlugin(WaveSurfer.minimap());\n * @return {this}\n */\n addPlugin(plugin) {\n if (!plugin.name) {\n throw new Error('Plugin does not have a name!');\n }\n if (!plugin.instance) {\n throw new Error(\n `Plugin ${plugin.name} does not have an instance property!`\n );\n }\n\n // staticProps properties are applied to wavesurfer instance\n if (plugin.staticProps) {\n Object.keys(plugin.staticProps).forEach(pluginStaticProp => {\n /**\n * Properties defined in a plugin definition's `staticProps` property are added as\n * staticProps properties of the WaveSurfer instance\n */\n this[pluginStaticProp] = plugin.staticProps[pluginStaticProp];\n });\n }\n\n const Instance = plugin.instance;\n\n // turn the plugin instance into an observer\n const observerPrototypeKeys = Object.getOwnPropertyNames(\n util.Observer.prototype\n );\n observerPrototypeKeys.forEach(key => {\n Instance.prototype[key] = util.Observer.prototype[key];\n });\n\n /**\n * Instantiated plugin classes are added as a property of the wavesurfer\n * instance\n * @type {Object}\n */\n this[plugin.name] = new Instance(plugin.params || {}, this);\n this.fireEvent('plugin-added', plugin.name);\n return this;\n }\n\n /**\n * Initialise a plugin\n *\n * @param {string} name A plugin name\n * @emits WaveSurfer#plugin-initialised\n * @example wavesurfer.initPlugin('minimap');\n * @return {this}\n */\n initPlugin(name) {\n if (!this[name]) {\n throw new Error(`Plugin ${name} has not been added yet!`);\n }\n if (this.initialisedPluginList[name]) {\n // destroy any already initialised plugins\n this.destroyPlugin(name);\n }\n this[name].init();\n this.initialisedPluginList[name] = true;\n this.fireEvent('plugin-initialised', name);\n return this;\n }\n\n /**\n * Destroy a plugin\n *\n * @param {string} name A plugin name\n * @emits WaveSurfer#plugin-destroyed\n * @example wavesurfer.destroyPlugin('minimap');\n * @returns {this}\n */\n destroyPlugin(name) {\n if (!this[name]) {\n throw new Error(\n `Plugin ${name} has not been added yet and cannot be destroyed!`\n );\n }\n if (!this.initialisedPluginList[name]) {\n throw new Error(\n `Plugin ${name} is not active and cannot be destroyed!`\n );\n }\n if (typeof this[name].destroy !== 'function') {\n throw new Error(`Plugin ${name} does not have a destroy function!`);\n }\n\n this[name].destroy();\n delete this.initialisedPluginList[name];\n this.fireEvent('plugin-destroyed', name);\n return this;\n }\n\n /**\n * Destroy all initialised plugins. Convenience function to use when\n * wavesurfer is removed\n *\n * @private\n */\n destroyAllPlugins() {\n Object.keys(this.initialisedPluginList).forEach(name =>\n this.destroyPlugin(name)\n );\n }\n\n /**\n * Create the drawer and draw the waveform\n *\n * @private\n * @emits WaveSurfer#drawer-created\n */\n createDrawer() {\n this.drawer = new this.Drawer(this.container, this.params);\n this.drawer.init();\n this.fireEvent('drawer-created', this.drawer);\n\n if (this.params.responsive !== false) {\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n }\n\n this.drawer.on('redraw', () => {\n this.drawBuffer();\n this.drawer.progress(this.backend.getPlayedPercents());\n });\n\n // Click-to-seek\n this.drawer.on('click', (e, progress) => {\n setTimeout(() => this.seekTo(progress), 0);\n });\n\n // Relay the scroll event from the drawer\n this.drawer.on('scroll', e => {\n if (this.params.partialRender) {\n this.drawBuffer();\n }\n this.fireEvent('scroll', e);\n });\n }\n\n /**\n * Create the backend\n *\n * @private\n * @emits WaveSurfer#backend-created\n */\n createBackend() {\n if (this.backend) {\n this.backend.destroy();\n }\n\n // Back compat\n if (this.params.backend == 'AudioElement') {\n this.params.backend = 'MediaElement';\n }\n\n if (\n this.params.backend == 'WebAudio' &&\n !this.Backend.prototype.supportsWebAudio.call(null)\n ) {\n this.params.backend = 'MediaElement';\n }\n\n this.backend = new this.Backend(this.params);\n this.backend.init();\n this.fireEvent('backend-created', this.backend);\n\n this.backend.on('finish', () => {\n this.drawer.progress(this.backend.getPlayedPercents());\n this.fireEvent('finish');\n });\n this.backend.on('play', () => this.fireEvent('play'));\n this.backend.on('pause', () => this.fireEvent('pause'));\n\n this.backend.on('audioprocess', time => {\n this.drawer.progress(this.backend.getPlayedPercents());\n this.fireEvent('audioprocess', time);\n });\n }\n\n /**\n * Create the peak cache\n *\n * @private\n */\n createPeakCache() {\n if (this.params.partialRender) {\n this.peakCache = new PeakCache();\n }\n }\n\n /**\n * Get the duration of the audio clip\n *\n * @example const duration = wavesurfer.getDuration();\n * @return {number} Duration in seconds\n */\n getDuration() {\n return this.backend.getDuration();\n }\n\n /**\n * Get the current playback position\n *\n * @example const currentTime = wavesurfer.getCurrentTime();\n * @return {number} Playback position in seconds\n */\n getCurrentTime() {\n return this.backend.getCurrentTime();\n }\n\n /**\n * Set the current play time in seconds.\n *\n * @param {number} seconds A positive number in seconds. E.g. 10 means 10\n * seconds, 60 means 1 minute\n */\n setCurrentTime(seconds) {\n if (seconds >= this.getDuration()) {\n this.seekTo(1);\n } else {\n this.seekTo(seconds / this.getDuration());\n }\n }\n\n /**\n * Starts playback from the current position. Optional start and end\n * measured in seconds can be used to set the range of audio to play.\n *\n * @param {?number} start Position to start at\n * @param {?number} end Position to end at\n * @emits WaveSurfer#interaction\n * @return {Promise}\n * @example\n * // play from second 1 to 5\n * wavesurfer.play(1, 5);\n */\n play(start, end) {\n this.fireEvent('interaction', () => this.play(start, end));\n return this.backend.play(start, end);\n }\n\n /**\n * Stops playback\n *\n * @example wavesurfer.pause();\n * @return {Promise}\n */\n pause() {\n if (!this.backend.isPaused()) {\n return this.backend.pause();\n }\n }\n\n /**\n * Toggle playback\n *\n * @example wavesurfer.playPause();\n * @return {Promise}\n */\n playPause() {\n return this.backend.isPaused() ? this.play() : this.pause();\n }\n\n /**\n * Get the current playback state\n *\n * @example const isPlaying = wavesurfer.isPlaying();\n * @return {boolean} False if paused, true if playing\n */\n isPlaying() {\n return !this.backend.isPaused();\n }\n\n /**\n * Skip backward\n *\n * @param {?number} seconds Amount to skip back, if not specified `skipLength`\n * is used\n * @example wavesurfer.skipBackward();\n */\n skipBackward(seconds) {\n this.skip(-seconds || -this.params.skipLength);\n }\n\n /**\n * Skip forward\n *\n * @param {?number} seconds Amount to skip back, if not specified `skipLength`\n * is used\n * @example wavesurfer.skipForward();\n */\n skipForward(seconds) {\n this.skip(seconds || this.params.skipLength);\n }\n\n /**\n * Skip a number of seconds from the current position (use a negative value\n * to go backwards).\n *\n * @param {number} offset Amount to skip back or forwards\n * @example\n * // go back 2 seconds\n * wavesurfer.skip(-2);\n */\n skip(offset) {\n const duration = this.getDuration() || 1;\n let position = this.getCurrentTime() || 0;\n position = Math.max(0, Math.min(duration, position + (offset || 0)));\n this.seekAndCenter(position / duration);\n }\n\n /**\n * Seeks to a position and centers the view\n *\n * @param {number} progress Between 0 (=beginning) and 1 (=end)\n * @example\n * // seek and go to the middle of the audio\n * wavesurfer.seekTo(0.5);\n */\n seekAndCenter(progress) {\n this.seekTo(progress);\n this.drawer.recenter(progress);\n }\n\n /**\n * Seeks to a position\n *\n * @param {number} progress Between 0 (=beginning) and 1 (=end)\n * @emits WaveSurfer#interaction\n * @emits WaveSurfer#seek\n * @example\n * // seek to the middle of the audio\n * wavesurfer.seekTo(0.5);\n */\n seekTo(progress) {\n // return an error if progress is not a number between 0 and 1\n if (\n typeof progress !== 'number' ||\n !isFinite(progress) ||\n progress < 0 ||\n progress > 1\n ) {\n return console.error(\n 'Error calling wavesurfer.seekTo, parameter must be a number between 0 and 1!'\n );\n }\n this.fireEvent('interaction', () => this.seekTo(progress));\n\n const paused = this.backend.isPaused();\n // avoid draw wrong position while playing backward seeking\n if (!paused) {\n this.backend.pause();\n }\n // avoid small scrolls while paused seeking\n const oldScrollParent = this.params.scrollParent;\n this.params.scrollParent = false;\n this.backend.seekTo(progress * this.getDuration());\n this.drawer.progress(progress);\n\n if (!paused) {\n this.backend.play();\n }\n this.params.scrollParent = oldScrollParent;\n this.fireEvent('seek', progress);\n }\n\n /**\n * Stops and goes to the beginning.\n *\n * @example wavesurfer.stop();\n */\n stop() {\n this.pause();\n this.seekTo(0);\n this.drawer.progress(0);\n }\n\n /**\n * Set the playback volume.\n *\n * @param {string} deviceId String value representing underlying output device\n */\n setSinkId(deviceId) {\n return this.backend.setSinkId(deviceId);\n }\n\n /**\n * Set the playback volume.\n *\n * @param {number} newVolume A value between 0 and 1, 0 being no\n * volume and 1 being full volume.\n * @emits WaveSurfer#volume\n */\n setVolume(newVolume) {\n this.backend.setVolume(newVolume);\n this.fireEvent('volume', newVolume);\n }\n\n /**\n * Get the playback volume.\n *\n * @return {number} A value between 0 and 1, 0 being no\n * volume and 1 being full volume.\n */\n getVolume() {\n return this.backend.getVolume();\n }\n\n /**\n * Set the playback rate.\n *\n * @param {number} rate A positive number. E.g. 0.5 means half the normal\n * speed, 2 means double speed and so on.\n * @example wavesurfer.setPlaybackRate(2);\n */\n setPlaybackRate(rate) {\n this.backend.setPlaybackRate(rate);\n }\n\n /**\n * Get the playback rate.\n *\n * @return {number}\n */\n getPlaybackRate() {\n return this.backend.getPlaybackRate();\n }\n\n /**\n * Toggle the volume on and off. If not currently muted it will save the\n * current volume value and turn the volume off. If currently muted then it\n * will restore the volume to the saved value, and then rest the saved\n * value.\n *\n * @example wavesurfer.toggleMute();\n */\n toggleMute() {\n this.setMute(!this.isMuted);\n }\n\n /**\n * Enable or disable muted audio\n *\n * @param {boolean} mute\n * @emits WaveSurfer#volume\n * @emits WaveSurfer#mute\n * @example\n * // unmute\n * wavesurfer.setMute(false);\n */\n setMute(mute) {\n // ignore all muting requests if the audio is already in that state\n if (mute === this.isMuted) {\n this.fireEvent('mute', this.isMuted);\n return;\n }\n\n if (mute) {\n // If currently not muted then save current volume,\n // turn off the volume and update the mute properties\n this.savedVolume = this.backend.getVolume();\n this.backend.setVolume(0);\n this.isMuted = true;\n this.fireEvent('volume', 0);\n } else {\n // If currently muted then restore to the saved volume\n // and update the mute properties\n this.backend.setVolume(this.savedVolume);\n this.isMuted = false;\n this.fireEvent('volume', this.savedVolume);\n }\n this.fireEvent('mute', this.isMuted);\n }\n\n /**\n * Get the current mute status.\n *\n * @example const isMuted = wavesurfer.getMute();\n * @return {boolean}\n */\n getMute() {\n return this.isMuted;\n }\n\n /**\n * Get the current ready status.\n *\n * @example const isReady = wavesurfer.isReady();\n * @return {boolean}\n */\n isReady() {\n return this.isReady;\n }\n\n /**\n * Get the list of current set filters as an array.\n *\n * Filters must be set with setFilters method first\n *\n * @return {array}\n */\n getFilters() {\n return this.backend.filters || [];\n }\n\n /**\n * Toggles `scrollParent` and redraws\n *\n * @example wavesurfer.toggleScroll();\n */\n toggleScroll() {\n this.params.scrollParent = !this.params.scrollParent;\n this.drawBuffer();\n }\n\n /**\n * Toggle mouse interaction\n *\n * @example wavesurfer.toggleInteraction();\n */\n toggleInteraction() {\n this.params.interact = !this.params.interact;\n }\n\n /**\n * Get the fill color of the waveform after the cursor.\n *\n * @return {string} A CSS color string.\n */\n getWaveColor() {\n return this.params.waveColor;\n }\n\n /**\n * Set the fill color of the waveform after the cursor.\n *\n * @param {string} color A CSS color string.\n * @example wavesurfer.setWaveColor('#ddd');\n */\n setWaveColor(color) {\n this.params.waveColor = color;\n this.drawBuffer();\n }\n\n /**\n * Get the fill color of the waveform behind the cursor.\n *\n * @return {string} A CSS color string.\n */\n getProgressColor() {\n return this.params.progressColor;\n }\n\n /**\n * Set the fill color of the waveform behind the cursor.\n *\n * @param {string} color A CSS color string.\n * @example wavesurfer.setProgressColor('#400');\n */\n setProgressColor(color) {\n this.params.progressColor = color;\n this.drawBuffer();\n }\n\n /**\n * Get the fill color of the cursor indicating the playhead\n * position.\n *\n * @return {string} A CSS color string.\n */\n getCursorColor() {\n return this.params.cursorColor;\n }\n\n /**\n * Set the fill color of the cursor indicating the playhead\n * position.\n *\n * @param {string} color A CSS color string.\n * @example wavesurfer.setCursorColor('#222');\n */\n setCursorColor(color) {\n this.params.cursorColor = color;\n this.drawer.updateCursor();\n }\n\n /**\n * Get the height of the waveform.\n *\n * @return {number} Height measured in pixels.\n */\n getHeight() {\n return this.params.height;\n }\n\n /**\n * Set the height of the waveform.\n *\n * @param {number} height Height measured in pixels.\n * @example wavesurfer.setHeight(200);\n */\n setHeight(height) {\n this.params.height = height;\n this.drawer.setHeight(height * this.params.pixelRatio);\n this.drawBuffer();\n }\n\n /**\n * Get the correct peaks for current wave view-port and render wave\n *\n * @private\n * @emits WaveSurfer#redraw\n */\n drawBuffer() {\n const nominalWidth = Math.round(\n this.getDuration() *\n this.params.minPxPerSec *\n this.params.pixelRatio\n );\n const parentWidth = this.drawer.getWidth();\n let width = nominalWidth;\n let start = this.drawer.getScrollX();\n let end = Math.max(start + parentWidth, width);\n // Fill container\n if (\n this.params.fillParent &&\n (!this.params.scrollParent || nominalWidth < parentWidth)\n ) {\n width = parentWidth;\n start = 0;\n end = width;\n }\n\n let peaks;\n if (this.params.partialRender) {\n const newRanges = this.peakCache.addRangeToPeakCache(\n width,\n start,\n end\n );\n let i;\n for (i = 0; i < newRanges.length; i++) {\n peaks = this.backend.getPeaks(\n width,\n newRanges[i][0],\n newRanges[i][1]\n );\n this.drawer.drawPeaks(\n peaks,\n width,\n newRanges[i][0],\n newRanges[i][1]\n );\n }\n } else {\n peaks = this.backend.getPeaks(width, start, end);\n this.drawer.drawPeaks(peaks, width, start, end);\n }\n this.fireEvent('redraw', peaks, width);\n }\n\n /**\n * Horizontally zooms the waveform in and out. It also changes the parameter\n * `minPxPerSec` and enables the `scrollParent` option. Calling the function\n * with a falsey parameter will reset the zoom state.\n *\n * @param {?number} pxPerSec Number of horizontal pixels per second of\n * audio, if none is set the waveform returns to unzoomed state\n * @emits WaveSurfer#zoom\n * @example wavesurfer.zoom(20);\n */\n zoom(pxPerSec) {\n if (!pxPerSec) {\n this.params.minPxPerSec = this.defaultParams.minPxPerSec;\n this.params.scrollParent = false;\n } else {\n this.params.minPxPerSec = pxPerSec;\n this.params.scrollParent = true;\n }\n\n this.drawBuffer();\n this.drawer.progress(this.backend.getPlayedPercents());\n\n this.drawer.recenter(this.getCurrentTime() / this.getDuration());\n this.fireEvent('zoom', pxPerSec);\n }\n\n /**\n * Decode buffer and load\n *\n * @private\n * @param {ArrayBuffer} arraybuffer\n */\n loadArrayBuffer(arraybuffer) {\n this.decodeArrayBuffer(arraybuffer, data => {\n if (!this.isDestroyed) {\n this.loadDecodedBuffer(data);\n }\n });\n }\n\n /**\n * Directly load an externally decoded AudioBuffer\n *\n * @private\n * @param {AudioBuffer} buffer\n * @emits WaveSurfer#ready\n */\n loadDecodedBuffer(buffer) {\n this.backend.load(buffer);\n this.drawBuffer();\n this.fireEvent('ready');\n this.isReady = true;\n }\n\n /**\n * Loads audio data from a Blob or File object\n *\n * @param {Blob|File} blob Audio data\n * @example\n */\n loadBlob(blob) {\n // Create file reader\n const reader = new FileReader();\n reader.addEventListener('progress', e => this.onProgress(e));\n reader.addEventListener('load', e =>\n this.loadArrayBuffer(e.target.result)\n );\n reader.addEventListener('error', () =>\n this.fireEvent('error', 'Error reading file')\n );\n reader.readAsArrayBuffer(blob);\n this.empty();\n }\n\n /**\n * Loads audio and re-renders the waveform.\n *\n * @param {string|HTMLMediaElement} url The url of the audio file or the\n * audio element with the audio\n * @param {?number[]|number[][]} peaks Wavesurfer does not have to decode\n * the audio to render the waveform if this is specified\n * @param {?string} preload (Use with backend `MediaElement`)\n * `'none'|'metadata'|'auto'` Preload attribute for the media element\n * @param {?number} duration The duration of the audio. This is used to\n * render the peaks data in the correct size for the audio duration (as\n * befits the current minPxPerSec and zoom value) without having to decode\n * the audio.\n * @example\n * // using ajax or media element to load (depending on backend)\n * wavesurfer.load('http://example.com/demo.wav');\n *\n * // setting preload attribute with media element backend and supplying\n * peaks wavesurfer.load(\n * 'http://example.com/demo.wav',\n * [0.0218, 0.0183, 0.0165, 0.0198, 0.2137, 0.2888],\n * true,\n * );\n */\n load(url, peaks, preload, duration) {\n this.empty();\n\n if (preload) {\n // check whether the preload attribute will be usable and if not log\n // a warning listing the reasons why not and nullify the variable\n const preloadIgnoreReasons = {\n \"Preload is not 'auto', 'none' or 'metadata'\":\n ['auto', 'metadata', 'none'].indexOf(preload) === -1,\n 'Peaks are not provided': !peaks,\n 'Backend is not of type MediaElement':\n this.params.backend !== 'MediaElement',\n 'Url is not of type string': typeof url !== 'string'\n };\n const activeReasons = Object.keys(preloadIgnoreReasons).filter(\n reason => preloadIgnoreReasons[reason]\n );\n if (activeReasons.length) {\n console.warn(\n 'Preload parameter of wavesurfer.load will be ignored because:\\n\\t- ' +\n activeReasons.join('\\n\\t- ')\n );\n // stop invalid values from being used\n preload = null;\n }\n }\n\n switch (this.params.backend) {\n case 'WebAudio':\n return this.loadBuffer(url, peaks, duration);\n case 'MediaElement':\n return this.loadMediaElement(url, peaks, preload, duration);\n }\n }\n\n /**\n * Loads audio using Web Audio buffer backend.\n *\n * @private\n * @param {string} url\n * @param {?number[]|number[][]} peaks\n * @param {?number} duration\n */\n loadBuffer(url, peaks, duration) {\n const load = action => {\n if (action) {\n this.tmpEvents.push(this.once('ready', action));\n }\n return this.getArrayBuffer(url, data => this.loadArrayBuffer(data));\n };\n\n if (peaks) {\n this.backend.setPeaks(peaks, duration);\n this.drawBuffer();\n this.tmpEvents.push(this.once('interaction', load));\n } else {\n return load();\n }\n }\n\n /**\n * Either create a media element, or load an existing media element.\n *\n * @private\n * @param {string|HTMLMediaElement} urlOrElt Either a path to a media file, or an\n * existing HTML5 Audio/Video Element\n * @param {number[]|number[][]} peaks Array of peaks. Required to bypass web audio\n * dependency\n * @param {?boolean} preload Set to true if the preload attribute of the\n * audio element should be enabled\n * @param {?number} duration\n */\n loadMediaElement(urlOrElt, peaks, preload, duration) {\n let url = urlOrElt;\n\n if (typeof urlOrElt === 'string') {\n this.backend.load(url, this.mediaContainer, peaks, preload);\n } else {\n const elt = urlOrElt;\n this.backend.loadElt(elt, peaks);\n\n // If peaks are not provided,\n // url = element.src so we can get peaks with web audio\n url = elt.src;\n }\n\n this.tmpEvents.push(\n this.backend.once('canplay', () => {\n this.drawBuffer();\n this.fireEvent('ready');\n this.isReady = true;\n }),\n this.backend.once('error', err => this.fireEvent('error', err))\n );\n\n // If no pre-decoded peaks provided or pre-decoded peaks are\n // provided with forceDecode flag, attempt to download the\n // audio file and decode it with Web Audio.\n if (peaks) {\n this.backend.setPeaks(peaks, duration);\n }\n\n if (\n (!peaks || this.params.forceDecode) &&\n this.backend.supportsWebAudio()\n ) {\n this.getArrayBuffer(url, arraybuffer => {\n this.decodeArrayBuffer(arraybuffer, buffer => {\n this.backend.buffer = buffer;\n this.backend.setPeaks(null);\n this.drawBuffer();\n this.fireEvent('waveform-ready');\n });\n });\n }\n }\n\n /**\n * Decode an array buffer and pass data to a callback\n *\n * @private\n * @param {Object} arraybuffer\n * @param {function} callback\n */\n decodeArrayBuffer(arraybuffer, callback) {\n this.arraybuffer = arraybuffer;\n\n this.backend.decodeArrayBuffer(\n arraybuffer,\n data => {\n // Only use the decoded data if we haven't been destroyed or\n // another decode started in the meantime\n if (!this.isDestroyed && this.arraybuffer == arraybuffer) {\n callback(data);\n this.arraybuffer = null;\n }\n },\n () => this.fireEvent('error', 'Error decoding audiobuffer')\n );\n }\n\n /**\n * Load an array buffer by ajax and pass to a callback\n *\n * @param {string} url\n * @param {function} callback\n * @private\n */\n getArrayBuffer(url, callback) {\n const ajax = util.ajax({\n url: url,\n responseType: 'arraybuffer',\n xhr: this.params.xhr\n });\n\n this.currentAjax = ajax;\n\n this.tmpEvents.push(\n ajax.on('progress', e => {\n this.onProgress(e);\n }),\n ajax.on('success', (data, e) => {\n callback(data);\n this.currentAjax = null;\n }),\n ajax.on('error', e => {\n this.fireEvent('error', 'XHR error: ' + e.target.statusText);\n this.currentAjax = null;\n })\n );\n\n return ajax;\n }\n\n /**\n * Called while the audio file is loading\n *\n * @private\n * @param {Event} e\n * @emits WaveSurfer#loading\n */\n onProgress(e) {\n let percentComplete;\n if (e.lengthComputable) {\n percentComplete = e.loaded / e.total;\n } else {\n // Approximate progress with an asymptotic\n // function, and assume downloads in the 1-3 MB range.\n percentComplete = e.loaded / (e.loaded + 1000000);\n }\n this.fireEvent('loading', Math.round(percentComplete * 100), e.target);\n }\n\n /**\n * Exports PCM data into a JSON array and opens in a new window.\n *\n * @param {number} length=1024 The scale in which to export the peaks. (Integer)\n * @param {number} accuracy=10000 (Integer)\n * @param {?boolean} noWindow Set to true to disable opening a new\n * window with the JSON\n * @param {number} start\n * @todo Update exportPCM to work with new getPeaks signature\n * @return {string} JSON of peaks\n */\n exportPCM(length, accuracy, noWindow, start) {\n length = length || 1024;\n start = start || 0;\n accuracy = accuracy || 10000;\n noWindow = noWindow || false;\n const peaks = this.backend.getPeaks(length, start);\n const arr = [].map.call(\n peaks,\n val => Math.round(val * accuracy) / accuracy\n );\n const json = JSON.stringify(arr);\n if (!noWindow) {\n window.open(\n 'data:application/json;charset=utf-8,' +\n encodeURIComponent(json)\n );\n }\n return json;\n }\n\n /**\n * Save waveform image as data URI.\n *\n * The default format is `image/png`. Other supported types are\n * `image/jpeg` and `image/webp`.\n *\n * @param {string} format='image/png'\n * @param {number} quality=1\n * @return {string} data URI of image\n */\n exportImage(format, quality) {\n if (!format) {\n format = 'image/png';\n }\n if (!quality) {\n quality = 1;\n }\n\n return this.drawer.getImage(format, quality);\n }\n\n /**\n * Cancel any ajax request currently in progress\n */\n cancelAjax() {\n if (this.currentAjax) {\n this.currentAjax.xhr.abort();\n this.currentAjax = null;\n }\n }\n\n /**\n * @private\n */\n clearTmpEvents() {\n this.tmpEvents.forEach(e => e.un());\n }\n\n /**\n * Display empty waveform.\n */\n empty() {\n if (!this.backend.isPaused()) {\n this.stop();\n this.backend.disconnectSource();\n }\n this.isReady = false;\n this.cancelAjax();\n this.clearTmpEvents();\n this.drawer.progress(0);\n this.drawer.setWidth(0);\n this.drawer.drawPeaks({ length: this.drawer.getWidth() }, 0);\n }\n\n /**\n * Remove events, elements and disconnect WebAudio nodes.\n *\n * @emits WaveSurfer#destroy\n */\n destroy() {\n this.destroyAllPlugins();\n this.fireEvent('destroy');\n this.cancelAjax();\n this.clearTmpEvents();\n this.unAll();\n if (this.params.responsive !== false) {\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener(\n 'orientationchange',\n this._onResize,\n true\n );\n }\n this.backend.destroy();\n this.drawer.destroy();\n this.isDestroyed = true;\n this.isReady = false;\n this.arraybuffer = null;\n }\n}\n","import * as util from './util';\n\n// using constants to prevent someone writing the string wrong\nconst PLAYING = 'playing';\nconst PAUSED = 'paused';\nconst FINISHED = 'finished';\n\n/**\n * WebAudio backend\n *\n * @extends {Observer}\n */\nexport default class WebAudio extends util.Observer {\n /** @private */\n static scriptBufferSize = 256;\n /** @private */\n audioContext = null;\n /** @private */\n offlineAudioContext = null;\n /** @private */\n stateBehaviors = {\n [PLAYING]: {\n init() {\n this.addOnAudioProcess();\n },\n getPlayedPercents() {\n const duration = this.getDuration();\n return this.getCurrentTime() / duration || 0;\n },\n getCurrentTime() {\n return this.startPosition + this.getPlayedTime();\n }\n },\n [PAUSED]: {\n init() {\n this.removeOnAudioProcess();\n },\n getPlayedPercents() {\n const duration = this.getDuration();\n return this.getCurrentTime() / duration || 0;\n },\n getCurrentTime() {\n return this.startPosition;\n }\n },\n [FINISHED]: {\n init() {\n this.removeOnAudioProcess();\n this.fireEvent('finish');\n },\n getPlayedPercents() {\n return 1;\n },\n getCurrentTime() {\n return this.getDuration();\n }\n }\n };\n\n /**\n * Does the browser support this backend\n *\n * @return {boolean}\n */\n supportsWebAudio() {\n return !!(window.AudioContext || window.webkitAudioContext);\n }\n\n /**\n * Get the audio context used by this backend or create one\n *\n * @return {AudioContext}\n */\n getAudioContext() {\n if (!window.WaveSurferAudioContext) {\n window.WaveSurferAudioContext = new (window.AudioContext ||\n window.webkitAudioContext)();\n }\n return window.WaveSurferAudioContext;\n }\n\n /**\n * Get the offline audio context used by this backend or create one\n *\n * @param {number} sampleRate\n * @return {OfflineAudioContext}\n */\n getOfflineAudioContext(sampleRate) {\n if (!window.WaveSurferOfflineAudioContext) {\n window.WaveSurferOfflineAudioContext = new (window.OfflineAudioContext ||\n window.webkitOfflineAudioContext)(1, 2, sampleRate);\n }\n return window.WaveSurferOfflineAudioContext;\n }\n\n /**\n * Construct the backend\n *\n * @param {WavesurferParams} params\n */\n constructor(params) {\n super();\n /** @private */\n this.params = params;\n /** @private */\n this.ac = params.audioContext || this.getAudioContext();\n /**@private */\n this.lastPlay = this.ac.currentTime;\n /** @private */\n this.startPosition = 0;\n /** @private */\n this.scheduledPause = null;\n /** @private */\n this.states = {\n [PLAYING]: Object.create(this.stateBehaviors[PLAYING]),\n [PAUSED]: Object.create(this.stateBehaviors[PAUSED]),\n [FINISHED]: Object.create(this.stateBehaviors[FINISHED])\n };\n /** @private */\n this.analyser = null;\n /** @private */\n this.buffer = null;\n /** @private */\n this.filters = [];\n /** @private */\n this.gainNode = null;\n /** @private */\n this.mergedPeaks = null;\n /** @private */\n this.offlineAc = null;\n /** @private */\n this.peaks = null;\n /** @private */\n this.playbackRate = 1;\n /** @private */\n this.analyser = null;\n /** @private */\n this.scriptNode = null;\n /** @private */\n this.source = null;\n /** @private */\n this.splitPeaks = [];\n /** @private */\n this.state = null;\n /** @private */\n this.explicitDuration = null;\n }\n\n /**\n * Initialise the backend, called in `wavesurfer.createBackend()`\n */\n init() {\n this.createVolumeNode();\n this.createScriptNode();\n this.createAnalyserNode();\n\n this.setState(PAUSED);\n this.setPlaybackRate(this.params.audioRate);\n this.setLength(0);\n }\n\n /** @private */\n disconnectFilters() {\n if (this.filters) {\n this.filters.forEach(filter => {\n filter && filter.disconnect();\n });\n this.filters = null;\n // Reconnect direct path\n this.analyser.connect(this.gainNode);\n }\n }\n\n /** @private */\n setState(state) {\n if (this.state !== this.states[state]) {\n this.state = this.states[state];\n this.state.init.call(this);\n }\n }\n\n /**\n * Unpacked `setFilters()`\n *\n * @param {...AudioNode} filters\n */\n setFilter(...filters) {\n this.setFilters(filters);\n }\n\n /**\n * Insert custom Web Audio nodes into the graph\n *\n * @param {AudioNode[]} filters Packed filters array\n * @example\n * const lowpass = wavesurfer.backend.ac.createBiquadFilter();\n * wavesurfer.backend.setFilter(lowpass);\n */\n setFilters(filters) {\n // Remove existing filters\n this.disconnectFilters();\n\n // Insert filters if filter array not empty\n if (filters && filters.length) {\n this.filters = filters;\n\n // Disconnect direct path before inserting filters\n this.analyser.disconnect();\n\n // Connect each filter in turn\n filters\n .reduce((prev, curr) => {\n prev.connect(curr);\n return curr;\n }, this.analyser)\n .connect(this.gainNode);\n }\n }\n\n /** @private */\n createScriptNode() {\n if (this.params.audioScriptProcessor) {\n this.scriptNode = this.params.audioScriptProcessor;\n } else {\n if (this.ac.createScriptProcessor) {\n this.scriptNode = this.ac.createScriptProcessor(\n WebAudio.scriptBufferSize\n );\n } else {\n this.scriptNode = this.ac.createJavaScriptNode(\n WebAudio.scriptBufferSize\n );\n }\n }\n this.scriptNode.connect(this.ac.destination);\n }\n\n /** @private */\n addOnAudioProcess() {\n this.scriptNode.onaudioprocess = () => {\n const time = this.getCurrentTime();\n\n if (time >= this.getDuration()) {\n this.setState(FINISHED);\n this.fireEvent('pause');\n } else if (time >= this.scheduledPause) {\n this.pause();\n } else if (this.state === this.states[PLAYING]) {\n this.fireEvent('audioprocess', time);\n }\n };\n }\n\n /** @private */\n removeOnAudioProcess() {\n this.scriptNode.onaudioprocess = null;\n }\n\n /** @private */\n createAnalyserNode() {\n this.analyser = this.ac.createAnalyser();\n this.analyser.connect(this.gainNode);\n }\n\n /**\n * Create the gain node needed to control the playback volume.\n *\n * @private\n */\n createVolumeNode() {\n // Create gain node using the AudioContext\n if (this.ac.createGain) {\n this.gainNode = this.ac.createGain();\n } else {\n this.gainNode = this.ac.createGainNode();\n }\n // Add the gain node to the graph\n this.gainNode.connect(this.ac.destination);\n }\n\n /**\n * Set the sink id for the media player\n *\n * @param {string} deviceId String value representing audio device id.\n */\n setSinkId(deviceId) {\n if (deviceId) {\n /**\n * The webaudio API doesn't currently support setting the device\n * output. Here we create an HTMLAudioElement, connect the\n * webaudio stream to that element and setSinkId there.\n */\n let audio = new window.Audio();\n if (!audio.setSinkId) {\n return Promise.reject(\n new Error('setSinkId is not supported in your browser')\n );\n }\n audio.autoplay = true;\n var dest = this.ac.createMediaStreamDestination();\n this.gainNode.disconnect();\n this.gainNode.connect(dest);\n audio.srcObject = dest.stream;\n\n return audio.setSinkId(deviceId);\n } else {\n return Promise.reject(new Error('Invalid deviceId: ' + deviceId));\n }\n }\n\n /**\n * Set the audio volume\n *\n * @param {number} value A floating point value between 0 and 1.\n */\n setVolume(value) {\n this.gainNode.gain.setValueAtTime(value, this.ac.currentTime);\n }\n\n /**\n * Get the current volume\n *\n * @return {number} value A floating point value between 0 and 1.\n */\n getVolume() {\n return this.gainNode.gain.value;\n }\n\n /** @private */\n decodeArrayBuffer(arraybuffer, callback, errback) {\n if (!this.offlineAc) {\n this.offlineAc = this.getOfflineAudioContext(\n this.ac && this.ac.sampleRate ? this.ac.sampleRate : 44100\n );\n }\n this.offlineAc.decodeAudioData(\n arraybuffer,\n data => callback(data),\n errback\n );\n }\n\n /**\n * Set pre-decoded peaks\n *\n * @param {number[]|number[][]} peaks\n * @param {?number} duration\n */\n setPeaks(peaks, duration) {\n this.explicitDuration = duration;\n this.peaks = peaks;\n }\n\n /**\n * Set the rendered length (different from the length of the audio).\n *\n * @param {number} length\n */\n setLength(length) {\n // No resize, we can preserve the cached peaks.\n if (this.mergedPeaks && length == 2 * this.mergedPeaks.length - 1 + 2) {\n return;\n }\n\n this.splitPeaks = [];\n this.mergedPeaks = [];\n // Set the last element of the sparse array so the peak arrays are\n // appropriately sized for other calculations.\n const channels = this.buffer ? this.buffer.numberOfChannels : 1;\n let c;\n for (c = 0; c < channels; c++) {\n this.splitPeaks[c] = [];\n this.splitPeaks[c][2 * (length - 1)] = 0;\n this.splitPeaks[c][2 * (length - 1) + 1] = 0;\n }\n this.mergedPeaks[2 * (length - 1)] = 0;\n this.mergedPeaks[2 * (length - 1) + 1] = 0;\n }\n\n /**\n * Compute the max and min value of the waveform when broken into <length> subranges.\n *\n * @param {number} length How many subranges to break the waveform into.\n * @param {number} first First sample in the required range.\n * @param {number} last Last sample in the required range.\n * @return {number[]|number[][]} Array of 2*<length> peaks or array of arrays of\n * peaks consisting of (max, min) values for each subrange.\n */\n getPeaks(length, first, last) {\n if (this.peaks) {\n return this.peaks;\n }\n\n first = first || 0;\n last = last || length - 1;\n\n this.setLength(length);\n\n /**\n * The following snippet fixes a buffering data issue on the Safari\n * browser which returned undefined It creates the missing buffer based\n * on 1 channel, 4096 samples and the sampleRate from the current\n * webaudio context 4096 samples seemed to be the best fit for rendering\n * will review this code once a stable version of Safari TP is out\n */\n if (!this.buffer.length) {\n const newBuffer = this.createBuffer(1, 4096, this.sampleRate);\n this.buffer = newBuffer.buffer;\n }\n\n const sampleSize = this.buffer.length / length;\n const sampleStep = ~~(sampleSize / 10) || 1;\n const channels = this.buffer.numberOfChannels;\n let c;\n\n for (c = 0; c < channels; c++) {\n const peaks = this.splitPeaks[c];\n const chan = this.buffer.getChannelData(c);\n let i;\n\n for (i = first; i <= last; i++) {\n const start = ~~(i * sampleSize);\n const end = ~~(start + sampleSize);\n let min = 0;\n let max = 0;\n let j;\n\n for (j = start; j < end; j += sampleStep) {\n const value = chan[j];\n\n if (value > max) {\n max = value;\n }\n\n if (value < min) {\n min = value;\n }\n }\n\n peaks[2 * i] = max;\n peaks[2 * i + 1] = min;\n\n if (c == 0 || max > this.mergedPeaks[2 * i]) {\n this.mergedPeaks[2 * i] = max;\n }\n\n if (c == 0 || min < this.mergedPeaks[2 * i + 1]) {\n this.mergedPeaks[2 * i + 1] = min;\n }\n }\n }\n\n return this.params.splitChannels ? this.splitPeaks : this.mergedPeaks;\n }\n\n /**\n * Get the position from 0 to 1\n *\n * @return {number}\n */\n getPlayedPercents() {\n return this.state.getPlayedPercents.call(this);\n }\n\n /** @private */\n disconnectSource() {\n if (this.source) {\n this.source.disconnect();\n }\n }\n\n /**\n * This is called when wavesurfer is destroyed\n */\n destroy() {\n if (!this.isPaused()) {\n this.pause();\n }\n this.unAll();\n this.buffer = null;\n this.disconnectFilters();\n this.disconnectSource();\n this.gainNode.disconnect();\n this.scriptNode.disconnect();\n this.analyser.disconnect();\n\n // close the audioContext if closeAudioContext option is set to true\n if (this.params.closeAudioContext) {\n // check if browser supports AudioContext.close()\n if (\n typeof this.ac.close === 'function' &&\n this.ac.state != 'closed'\n ) {\n this.ac.close();\n }\n // clear the reference to the audiocontext\n this.ac = null;\n // clear the actual audiocontext, either passed as param or the\n // global singleton\n if (!this.params.audioContext) {\n window.WaveSurferAudioContext = null;\n } else {\n this.params.audioContext = null;\n }\n // clear the offlineAudioContext\n window.WaveSurferOfflineAudioContext = null;\n }\n }\n\n /**\n * Loaded a decoded audio buffer\n *\n * @param {Object} buffer\n */\n load(buffer) {\n this.startPosition = 0;\n this.lastPlay = this.ac.currentTime;\n this.buffer = buffer;\n this.createSource();\n }\n\n /** @private */\n createSource() {\n this.disconnectSource();\n this.source = this.ac.createBufferSource();\n\n // adjust for old browsers\n this.source.start = this.source.start || this.source.noteGrainOn;\n this.source.stop = this.source.stop || this.source.noteOff;\n\n this.source.playbackRate.setValueAtTime(\n this.playbackRate,\n this.ac.currentTime\n );\n this.source.buffer = this.buffer;\n this.source.connect(this.analyser);\n }\n\n /**\n * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`\n *\n * @return {boolean}\n */\n isPaused() {\n return this.state !== this.states[PLAYING];\n }\n\n /**\n * Used by `wavesurfer.getDuration()`\n *\n * @return {number}\n */\n getDuration() {\n if (!this.buffer) {\n if (this.explicitDuration) {\n return this.explicitDuration;\n }\n return 0;\n }\n return this.buffer.duration;\n }\n\n /**\n * Used by `wavesurfer.seekTo()`\n *\n * @param {number} start Position to start at in seconds\n * @param {number} end Position to end at in seconds\n * @return {{start: number, end: number}}\n */\n seekTo(start, end) {\n if (!this.buffer) {\n return;\n }\n\n this.scheduledPause = null;\n\n if (start == null) {\n start = this.getCurrentTime();\n if (start >= this.getDuration()) {\n start = 0;\n }\n }\n if (end == null) {\n end = this.getDuration();\n }\n\n this.startPosition = start;\n this.lastPlay = this.ac.currentTime;\n\n if (this.state === this.states[FINISHED]) {\n this.setState(PAUSED);\n }\n\n return {\n start: start,\n end: end\n };\n }\n\n /**\n * Get the playback position in seconds\n *\n * @return {number}\n */\n getPlayedTime() {\n return (this.ac.currentTime - this.lastPlay) * this.playbackRate;\n }\n\n /**\n * Plays the loaded audio region.\n *\n * @param {number} start Start offset in seconds, relative to the beginning\n * of a clip.\n * @param {number} end When to stop relative to the beginning of a clip.\n */\n play(start, end) {\n if (!this.buffer) {\n return;\n }\n\n // need to re-create source on each playback\n this.createSource();\n\n const adjustedTime = this.seekTo(start, end);\n\n start = adjustedTime.start;\n end = adjustedTime.end;\n\n this.scheduledPause = end;\n\n this.source.start(0, start, end - start);\n\n if (this.ac.state == 'suspended') {\n this.ac.resume && this.ac.resume();\n }\n\n this.setState(PLAYING);\n\n this.fireEvent('play');\n }\n\n /**\n * Pauses the loaded audio.\n */\n pause() {\n this.scheduledPause = null;\n\n this.startPosition += this.getPlayedTime();\n this.source && this.source.stop(0);\n\n this.setState(PAUSED);\n\n this.fireEvent('pause');\n }\n\n /**\n * Returns the current time in seconds relative to the audio-clip's\n * duration.\n *\n * @return {number}\n */\n getCurrentTime() {\n return this.state.getCurrentTime.call(this);\n }\n\n /**\n * Returns the current playback rate. (0=no playback, 1=normal playback)\n *\n * @return {number}\n */\n getPlaybackRate() {\n return this.playbackRate;\n }\n\n /**\n * Set the audio source playback rate.\n *\n * @param {number} value\n */\n setPlaybackRate(value) {\n value = value || 1;\n if (this.isPaused()) {\n this.playbackRate = value;\n } else {\n this.pause();\n this.playbackRate = value;\n this.play();\n }\n }\n}\n"],"sourceRoot":""}
You can’t perform that action at this time.