wavesurfer.js 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGES.md +11 -0
  2. package/dist/plugin/wavesurfer.cursor.js +2 -2
  3. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  4. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  5. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  6. package/dist/plugin/wavesurfer.elan.js +2 -2
  7. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  8. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  9. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  10. package/dist/plugin/wavesurfer.markers.js +2 -2
  11. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  12. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  13. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  14. package/dist/plugin/wavesurfer.mediasession.js +2 -2
  15. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  16. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  17. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  18. package/dist/plugin/wavesurfer.microphone.js +2 -2
  19. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  20. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  21. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  22. package/dist/plugin/wavesurfer.minimap.js +2 -2
  23. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  24. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  25. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  26. package/dist/plugin/wavesurfer.playhead.js +2 -2
  27. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  28. package/dist/plugin/wavesurfer.playhead.min.js +2 -2
  29. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  30. package/dist/plugin/wavesurfer.regions.js +37 -7
  31. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  32. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  33. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  34. package/dist/plugin/wavesurfer.spectrogram.js +2 -2
  35. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  36. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  37. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  38. package/dist/plugin/wavesurfer.timeline.js +14 -11
  39. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  40. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  41. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  42. package/dist/wavesurfer-html-init.js +2 -2
  43. package/dist/wavesurfer-html-init.js.map +1 -1
  44. package/dist/wavesurfer-html-init.min.js +2 -2
  45. package/dist/wavesurfer-html-init.min.js.map +1 -1
  46. package/dist/wavesurfer.js +99 -21
  47. package/dist/wavesurfer.js.map +1 -1
  48. package/dist/wavesurfer.min.js +2 -2
  49. package/dist/wavesurfer.min.js.map +1 -1
  50. package/package.json +11 -11
  51. package/src/plugin/regions/region.js +33 -5
  52. package/src/plugin/timeline/index.js +11 -9
  53. package/src/util/index.js +1 -0
  54. package/src/util/silence-mode.js +35 -0
  55. package/src/wavesurfer.js +23 -13
  56. package/src/webaudio.js +10 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/html-init.js","webpack://WaveSurfer.[name]/./node_modules/load-script/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","Init","WaveSurfer","params","Error","_params","Object","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","async","err","plugin","console","error","window","document","querySelectorAll","pluginCache","instances","initAllEls","Array","prototype","forEach","call","el","plugins","dataset","split","length","initEl","i","lib","jsonRegex","initialisedPlugins","map","attrName","options","attrNameRegex","RegExp","exec","attr","prop","test","JSON","parse","slice","toLowerCase","create","container","style","display","instance","peaks","undefined","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","stdOnEnd","script","onload","onerror","ieOnEnd","onreadystatechange","opts","head","getElementsByTagName","createElement","type","charset","attrs","setAttribute","setAttributes","text","appendChild","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAE,aAAeC,KARnF,CASGK,MAAM,WACT,O,gGCVA,I,EAAA,G,EAAA,Q,wgBAkDMC,E,WAUF,WAAYC,GAAyB,IAAbC,EAAa,uDAAJ,GAC7B,GADiC,WAC5BD,EACD,MAAM,IAAIE,MAAM,gCAOpBJ,KAAKE,WAAaA,EAMlB,IAAMG,EAAWL,KAAKG,OAASG,OAAOC,OAClC,GACA,CAGIC,SAAU,CACNC,QAAS,eACTC,eAAe,GAGnBC,WAAY,aAEZC,kBACI,oDAIJC,WAfJ,SAeeC,EAAMC,GACb,IAAMC,EAAMX,EAAQO,kBAAkBK,QAClC,SACAH,IAEJ,aAAWE,EAAK,CAAEE,OAAO,IAAS,SAACC,EAAKC,GACpC,GAAID,EAEA,OAAOE,QAAQC,MAAR,4BACkBR,EADlB,yBACuCE,IAGlDD,EAAGQ,OAAOrB,WAAWY,SAIjCX,GAMJH,KAAKW,WAC4B,iBAAtBN,EAAQM,WACTa,SAASC,iBAAiBpB,EAAQM,YAClCN,EAAQM,WAElBX,KAAK0B,YAAc,GAKnB1B,KAAK2B,UAAY,G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,EAAWI,GACtCH,EAAQzD,GAKTyD,EAAOC,QACVF,EAASC,EAAQzD,GAGnB+D,EAAKS,YAAYf,MCnCfgB,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5B,IAAjB6B,EACH,OAAOA,EAAa/F,QAGrB,IAAIC,EAAS2F,EAAyBE,GAAY,CAGjD9F,QAAS,IAOV,OAHAgG,EAAoBF,GAAU7F,EAAQA,EAAOD,QAAS6F,GAG/C5F,EAAOD,QClBW6F,CAAoB,K,MDF1CD","file":"wavesurfer-html-init.min.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\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(this, function() {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(531);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer-html-init.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAE,aAAeC,KARnF,CASGK,MAAM,WACT,O,gGCVA,I,EAAA,G,EAAA,Q,wgBAkDMC,EAAAA,WAUF,WAAYC,GAAyB,IAAbC,EAAa,uDAAJ,GAC7B,GADiC,WAC5BD,EACD,MAAM,IAAIE,MAAM,gCAOpBC,KAAKH,WAAaA,EAMlB,IAAMI,EAAWD,KAAKF,OAASI,OAAOC,OAClC,GACA,CAGIC,SAAU,CACNC,QAAS,eACTC,eAAe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,EACLA,EAAO,IAGTA,EAAOA,GAAQ,GACf9D,EAAKA,GAAM,aAEXyD,EAAOS,KAAOJ,EAAKI,MAAQ,kBAC3BT,EAAOU,QAAUL,EAAKK,SAAW,OACjCV,EAAOtD,QAAQ,UAAW2D,MAASA,EAAK3D,MACxCsD,EAAOxD,IAAMA,EAET6D,EAAKM,OAqBX,SAAuBX,EAAQW,GAC7B,IAAK,IAAIlC,KAAQkC,EACfX,EAAOY,aAAanC,EAAMkC,EAAMlC,IAtBhCoC,CAAcb,EAAQK,EAAKM,OAGzBN,EAAKS,OACPd,EAAOc,KAAO,GAAKT,EAAKS,OAGd,WAAYd,EAASD,EAAWI,GACtCH,EAAQzD,GAKTyD,EAAOC,QACVF,EAASC,EAAQzD,GAGnB+D,EAAKS,YAAYf,MCnCfgB,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5B,IAAjB6B,EACH,OAAOA,EAAahG,QAGrB,IAAIC,EAAS4F,EAAyBE,GAAY,CAGjD/F,QAAS,IAOV,OAHAiG,EAAoBF,GAAU9F,EAAQA,EAAOD,QAAS8F,GAG/C7F,EAAOD,QClBW8F,CAAoB,KJO9C,I,EGTID","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/html-init.js","webpack://WaveSurfer.[name]/./node_modules/load-script/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"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\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(self, function() {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(531);\n"],"names":["root","factory","exports","module","define","amd","self","Init","WaveSurfer","params","Error","this","_params","Object","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","async","err","plugin","console","error","window","document","querySelectorAll","pluginCache","instances","initAllEls","Array","prototype","forEach","call","el","plugins","dataset","split","length","initEl","i","lib","jsonRegex","initialisedPlugins","map","attrName","options","attrNameRegex","RegExp","exec","attr","prop","test","JSON","parse","slice","toLowerCase","create","container","style","display","instance","peaks","undefined","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","stdOnEnd","script","onload","onerror","ieOnEnd","onreadystatechange","opts","head","getElementsByTagName","createElement","type","charset","attrs","setAttribute","setAttributes","text","appendChild","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js 5.1.0 (2021-06-20)
2
+ * wavesurfer.js 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ var __webpack_modules__ = ({
18
18
 
@@ -460,7 +460,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
460
460
 
461
461
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
462
462
 
463
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
463
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
464
464
 
465
465
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
466
466
 
@@ -960,7 +960,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
960
960
 
961
961
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
962
962
 
963
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
963
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
964
964
 
965
965
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
966
966
 
@@ -1643,7 +1643,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
1643
1643
 
1644
1644
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1645
1645
 
1646
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
1646
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1647
1647
 
1648
1648
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1649
1649
 
@@ -1798,7 +1798,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
1798
1798
 
1799
1799
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1800
1800
 
1801
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
1801
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1802
1802
 
1803
1803
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1804
1804
 
@@ -2984,6 +2984,12 @@ Object.defineProperty(exports, "withOrientation", ({
2984
2984
  return _orientation.default;
2985
2985
  }
2986
2986
  }));
2987
+ Object.defineProperty(exports, "ignoreSilenceMode", ({
2988
+ enumerable: true,
2989
+ get: function get() {
2990
+ return _silenceMode.default;
2991
+ }
2992
+ }));
2987
2993
 
2988
2994
  var _getId = _interopRequireDefault(__webpack_require__(/*! ./get-id */ "./src/util/get-id.js"));
2989
2995
 
@@ -3011,6 +3017,8 @@ var _clamp = _interopRequireDefault(__webpack_require__(/*! ./clamp */ "./src/ut
3011
3017
 
3012
3018
  var _orientation = _interopRequireDefault(__webpack_require__(/*! ./orientation */ "./src/util/orientation.js"));
3013
3019
 
3020
+ var _silenceMode = _interopRequireDefault(__webpack_require__(/*! ./silence-mode */ "./src/util/silence-mode.js"));
3021
+
3014
3022
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3015
3023
 
3016
3024
  /***/ }),
@@ -3469,6 +3477,56 @@ module.exports = exports.default;
3469
3477
 
3470
3478
  /***/ }),
3471
3479
 
3480
+ /***/ "./src/util/silence-mode.js":
3481
+ /*!**********************************!*\
3482
+ !*** ./src/util/silence-mode.js ***!
3483
+ \**********************************/
3484
+ /***/ ((module, exports) => {
3485
+
3486
+ "use strict";
3487
+
3488
+
3489
+ Object.defineProperty(exports, "__esModule", ({
3490
+ value: true
3491
+ }));
3492
+ exports.default = ignoreSilenceMode;
3493
+
3494
+ /**
3495
+ * Ignores device silence mode when using the `WebAudio` backend.
3496
+ *
3497
+ * Many mobile devices contain a hardware button to mute the ringtone for incoming
3498
+ * calls and messages. Unfortunately, on some platforms like iOS, this also mutes
3499
+ * wavesurfer's audio when using the `WebAudio` backend. This function creates a
3500
+ * temporary `<audio>` element that makes sure the WebAudio backend keeps playing
3501
+ * when muting the device ringer.
3502
+ *
3503
+ * @since 5.2.0
3504
+ */
3505
+ function ignoreSilenceMode() {
3506
+ // Set the src to a short bit of url encoded as a silent mp3
3507
+ // NOTE The silence MP3 must be high quality, when web audio sounds are played
3508
+ // in parallel the web audio sound is mixed to match the bitrate of the html sound
3509
+ // 0.01 seconds of silence VBR220-260 Joint Stereo 859B
3510
+ var audioData = "data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAACcQCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA//////////////////////////////////////////////////////////////////8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//sQxAADgnABGiAAQBCqgCRMAAgEAH///////////////7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq//////////////////9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ=="; // disable iOS Airplay (setting the attribute in js doesn't work)
3511
+
3512
+ var tmp = document.createElement("div");
3513
+ tmp.innerHTML = '<audio x-webkit-airplay="deny"></audio>';
3514
+ var audioSilentMode = tmp.children.item(0);
3515
+ audioSilentMode.src = audioData;
3516
+ audioSilentMode.preload = "auto";
3517
+ audioSilentMode.type = "audio/mpeg";
3518
+ audioSilentMode.disableRemotePlayback = true; // play
3519
+
3520
+ audioSilentMode.play(); // cleanup
3521
+
3522
+ audioSilentMode.remove();
3523
+ tmp.remove();
3524
+ }
3525
+
3526
+ module.exports = exports.default;
3527
+
3528
+ /***/ }),
3529
+
3472
3530
  /***/ "./src/util/style.js":
3473
3531
  /*!***************************!*\
3474
3532
  !*** ./src/util/style.js ***!
@@ -3544,7 +3602,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
3544
3602
 
3545
3603
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
3546
3604
 
3547
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
3605
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
3548
3606
 
3549
3607
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
3550
3608
 
@@ -3628,6 +3686,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
3628
3686
  * pixels.
3629
3687
  * @property {boolean} hideScrollbar=false Whether to hide the horizontal
3630
3688
  * scrollbar when one would normally be shown.
3689
+ * @property {boolean} ignoreSilenceMode=false If true, ignores device silence mode
3690
+ * when using the `WebAudio` backend.
3631
3691
  * @property {boolean} interact=true Whether the mouse interaction will be
3632
3692
  * enabled at initialization. You can switch this parameter at any time later
3633
3693
  * on.
@@ -3865,6 +3925,7 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
3865
3925
  forceDecode: false,
3866
3926
  height: 128,
3867
3927
  hideScrollbar: false,
3928
+ ignoreSilenceMode: false,
3868
3929
  interact: true,
3869
3930
  loopSelection: true,
3870
3931
  maxCanvasWidth: 4000,
@@ -4383,6 +4444,11 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
4383
4444
  value: function play(start, end) {
4384
4445
  var _this7 = this;
4385
4446
 
4447
+ if (this.params.ignoreSilenceMode) {
4448
+ // ignores device hardware silence mode
4449
+ util.ignoreSilenceMode();
4450
+ }
4451
+
4386
4452
  this.fireEvent('interaction', function () {
4387
4453
  return _this7.play(start, end);
4388
4454
  });
@@ -5185,17 +5251,19 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
5185
5251
  value: function decodeArrayBuffer(arraybuffer, callback) {
5186
5252
  var _this13 = this;
5187
5253
 
5188
- this.arraybuffer = arraybuffer;
5189
- this.backend.decodeArrayBuffer(arraybuffer, function (data) {
5190
- // Only use the decoded data if we haven't been destroyed or
5191
- // another decode started in the meantime
5192
- if (!_this13.isDestroyed && _this13.arraybuffer == arraybuffer) {
5193
- callback(data);
5194
- _this13.arraybuffer = null;
5195
- }
5196
- }, function () {
5197
- return _this13.fireEvent('error', 'Error decoding audiobuffer');
5198
- });
5254
+ if (!this.isDestroyed) {
5255
+ this.arraybuffer = arraybuffer;
5256
+ this.backend.decodeArrayBuffer(arraybuffer, function (data) {
5257
+ // Only use the decoded data if we haven't been destroyed or
5258
+ // another decode started in the meantime
5259
+ if (!_this13.isDestroyed && _this13.arraybuffer == arraybuffer) {
5260
+ callback(data);
5261
+ _this13.arraybuffer = null;
5262
+ }
5263
+ }, function () {
5264
+ return _this13.fireEvent('error', 'Error decoding audiobuffer');
5265
+ });
5266
+ }
5199
5267
  }
5200
5268
  /**
5201
5269
  * Load an array buffer using fetch and pass the result to a callback
@@ -5445,7 +5513,7 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
5445
5513
  }(util.Observer);
5446
5514
 
5447
5515
  exports.default = WaveSurfer;
5448
- WaveSurfer.VERSION = "5.1.0";
5516
+ WaveSurfer.VERSION = "5.2.0";
5449
5517
  WaveSurfer.util = util;
5450
5518
  module.exports = exports.default;
5451
5519
 
@@ -5487,7 +5555,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
5487
5555
 
5488
5556
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
5489
5557
 
5490
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
5558
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
5491
5559
 
5492
5560
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
5493
5561
 
@@ -6281,7 +6349,17 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
6281
6349
  value: function pause() {
6282
6350
  this.scheduledPause = null;
6283
6351
  this.startPosition += this.getPlayedTime();
6284
- this.source && this.source.stop(0);
6352
+
6353
+ try {
6354
+ this.source && this.source.stop(0);
6355
+ } catch (err) {// Calling stop can throw the following 2 errors:
6356
+ // - RangeError (The value specified for when is negative.)
6357
+ // - InvalidStateNode (The node has not been started by calling start().)
6358
+ // We can safely ignore both errors, because:
6359
+ // - The range is surely correct
6360
+ // - The node might not have been started yet, in which case we just want to carry on without causing any trouble.
6361
+ }
6362
+
6285
6363
  this.setState(PAUSED);
6286
6364
  this.fireEvent('pause');
6287
6365
  }