@eva/plugin-sound 2.0.0-beta.0 → 2.0.0-beta.10
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.
- package/dist/EVA.plugin.sound.js +1708 -482
- package/dist/EVA.plugin.sound.min.js +1 -1
- package/dist/plugin-sound.cjs.js +131 -427
- package/dist/plugin-sound.cjs.prod.js +3 -2
- package/dist/plugin-sound.d.ts +64 -0
- package/dist/plugin-sound.esm.js +132 -428
- package/package.json +5 -3
- package/dist/packages/eva.js/lib/core/Component.d.ts +0 -35
- package/dist/packages/eva.js/lib/core/Component.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/core/ComponentObserver.d.ts +0 -22
- package/dist/packages/eva.js/lib/core/ComponentObserver.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/core/GameObject.d.ts +0 -31
- package/dist/packages/eva.js/lib/core/GameObject.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/core/System.d.ts +0 -30
- package/dist/packages/eva.js/lib/core/System.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/core/Transform.d.ts +0 -51
- package/dist/packages/eva.js/lib/core/Transform.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/core/observer.d.ts +0 -23
- package/dist/packages/eva.js/lib/core/observer.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/decorators/ide.d.ts +0 -2
- package/dist/packages/eva.js/lib/decorators/ide.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/decorators/system.d.ts +0 -11
- package/dist/packages/eva.js/lib/decorators/system.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/game/Game.d.ts +0 -72
- package/dist/packages/eva.js/lib/game/Game.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/game/Scene.d.ts +0 -12
- package/dist/packages/eva.js/lib/game/Scene.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/game/Ticker.d.ts +0 -25
- package/dist/packages/eva.js/lib/game/Ticker.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/index.d.ts +0 -26
- package/dist/packages/eva.js/lib/index.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/loader/Progress.d.ts +0 -21
- package/dist/packages/eva.js/lib/loader/Progress.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/loader/Resource.d.ts +0 -99
- package/dist/packages/eva.js/lib/loader/Resource.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/loader/resourceLoader.d.ts +0 -14
- package/dist/packages/eva.js/lib/loader/resourceLoader.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/timeline/index.d.ts +0 -40
- package/dist/packages/eva.js/lib/timeline/index.d.ts.map +0 -1
- package/dist/packages/eva.js/lib/timeline/utils.d.ts +0 -2
- package/dist/packages/eva.js/lib/timeline/utils.d.ts.map +0 -1
- package/dist/packages/plugin-a11y/lib/A11y.d.ts +0 -26
- package/dist/packages/plugin-a11y/lib/A11y.d.ts.map +0 -1
- package/dist/packages/plugin-a11y/lib/A11ySystem.d.ts +0 -54
- package/dist/packages/plugin-a11y/lib/A11ySystem.d.ts.map +0 -1
- package/dist/packages/plugin-a11y/lib/constant.d.ts +0 -34
- package/dist/packages/plugin-a11y/lib/constant.d.ts.map +0 -1
- package/dist/packages/plugin-a11y/lib/index.d.ts +0 -4
- package/dist/packages/plugin-a11y/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-a11y/lib/utils.d.ts +0 -6
- package/dist/packages/plugin-a11y/lib/utils.d.ts.map +0 -1
- package/dist/packages/plugin-evax/lib/EvaXComponent.d.ts +0 -20
- package/dist/packages/plugin-evax/lib/EvaXComponent.d.ts.map +0 -1
- package/dist/packages/plugin-evax/lib/EvaXSystem.d.ts +0 -33
- package/dist/packages/plugin-evax/lib/EvaXSystem.d.ts.map +0 -1
- package/dist/packages/plugin-evax/lib/index.d.ts +0 -10
- package/dist/packages/plugin-evax/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-evax/lib/utils.d.ts +0 -3
- package/dist/packages/plugin-evax/lib/utils.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/BodiesFactory.d.ts +0 -31
- package/dist/packages/plugin-matterjs/lib/BodiesFactory.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/Physics.d.ts +0 -32
- package/dist/packages/plugin-matterjs/lib/Physics.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/PhysicsEngine.d.ts +0 -35
- package/dist/packages/plugin-matterjs/lib/PhysicsEngine.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/PhysicsSystem.d.ts +0 -32
- package/dist/packages/plugin-matterjs/lib/PhysicsSystem.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/index.d.ts +0 -5
- package/dist/packages/plugin-matterjs/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-matterjs/lib/matter.d.ts +0 -3
- package/dist/packages/plugin-matterjs/lib/matter.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/Renderer.d.ts +0 -19
- package/dist/packages/plugin-renderer/lib/Renderer.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/System.d.ts +0 -40
- package/dist/packages/plugin-renderer/lib/System.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/Transform.d.ts +0 -28
- package/dist/packages/plugin-renderer/lib/Transform.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/compressedTexture/ability.d.ts +0 -20
- package/dist/packages/plugin-renderer/lib/compressedTexture/ability.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/compressedTexture/fix/loader.d.ts +0 -2
- package/dist/packages/plugin-renderer/lib/compressedTexture/fix/loader.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/compressedTexture/index.d.ts +0 -7
- package/dist/packages/plugin-renderer/lib/compressedTexture/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/index.d.ts +0 -8
- package/dist/packages/plugin-renderer/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/manager/ContainerManager.d.ts +0 -18
- package/dist/packages/plugin-renderer/lib/manager/ContainerManager.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/manager/RendererManager.d.ts +0 -17
- package/dist/packages/plugin-renderer/lib/manager/RendererManager.d.ts.map +0 -1
- package/dist/packages/plugin-renderer/lib/mixin.d.ts +0 -2
- package/dist/packages/plugin-renderer/lib/mixin.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-dragonbone/lib/component.d.ts +0 -26
- package/dist/packages/plugin-renderer-dragonbone/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-dragonbone/lib/db.d.ts +0 -3
- package/dist/packages/plugin-renderer-dragonbone/lib/db.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-dragonbone/lib/engine.d.ts +0 -10
- package/dist/packages/plugin-renderer-dragonbone/lib/engine.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-dragonbone/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-dragonbone/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-dragonbone/lib/system.d.ts +0 -24
- package/dist/packages/plugin-renderer-dragonbone/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-event/lib/component.d.ts +0 -52
- package/dist/packages/plugin-renderer-event/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-event/lib/index.d.ts +0 -5
- package/dist/packages/plugin-renderer-event/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-event/lib/system.d.ts +0 -19
- package/dist/packages/plugin-renderer-event/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-graphics/lib/component.d.ts +0 -8
- package/dist/packages/plugin-renderer-graphics/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-graphics/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-graphics/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-graphics/lib/system.d.ts +0 -12
- package/dist/packages/plugin-renderer-graphics/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-img/lib/component.d.ts +0 -10
- package/dist/packages/plugin-renderer-img/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-img/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-img/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-img/lib/system.d.ts +0 -18
- package/dist/packages/plugin-renderer-img/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/Lottie.d.ts +0 -27
- package/dist/packages/plugin-renderer-lottie/lib/Lottie.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/LottieSystem.d.ts +0 -18
- package/dist/packages/plugin-renderer-lottie/lib/LottieSystem.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/index.d.ts +0 -3
- package/dist/packages/plugin-renderer-lottie/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/lottie-pixi.d.ts +0 -180
- package/dist/packages/plugin-renderer-lottie/lib/lottie-pixi.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/types.d.ts +0 -18
- package/dist/packages/plugin-renderer-lottie/lib/types.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-lottie/lib/utils.d.ts +0 -2
- package/dist/packages/plugin-renderer-lottie/lib/utils.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-mask/lib/component.d.ts +0 -33
- package/dist/packages/plugin-renderer-mask/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-mask/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-mask/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-mask/lib/system.d.ts +0 -31
- package/dist/packages/plugin-renderer-mask/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-nine-patch/lib/component.d.ts +0 -22
- package/dist/packages/plugin-renderer-nine-patch/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-nine-patch/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-nine-patch/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-nine-patch/lib/system.d.ts +0 -19
- package/dist/packages/plugin-renderer-nine-patch/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-render/lib/component.d.ts +0 -17
- package/dist/packages/plugin-renderer-render/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-render/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-render/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-render/lib/system.d.ts +0 -17
- package/dist/packages/plugin-renderer-render/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-spine/lib/Spine.d.ts +0 -4
- package/dist/packages/plugin-renderer-spine/lib/Spine.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-spine/lib/SpineSystem.d.ts +0 -5
- package/dist/packages/plugin-renderer-spine/lib/SpineSystem.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-spine/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-spine/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite/lib/component.d.ts +0 -12
- package/dist/packages/plugin-renderer-sprite/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-sprite/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite/lib/system.d.ts +0 -17
- package/dist/packages/plugin-renderer-sprite/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite-animation/lib/component.d.ts +0 -31
- package/dist/packages/plugin-renderer-sprite-animation/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite-animation/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-sprite-animation/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-sprite-animation/lib/system.d.ts +0 -31
- package/dist/packages/plugin-renderer-sprite-animation/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-test/lib/component.d.ts +0 -20
- package/dist/packages/plugin-renderer-test/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-test/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-test/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-test/lib/system.d.ts +0 -21
- package/dist/packages/plugin-renderer-test/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-test/lib/system2.d.ts +0 -12
- package/dist/packages/plugin-renderer-test/lib/system2.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-text/lib/component.d.ts +0 -43
- package/dist/packages/plugin-renderer-text/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-text/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-text/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-text/lib/system.d.ts +0 -22
- package/dist/packages/plugin-renderer-text/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-tiling-sprite/lib/component.d.ts +0 -20
- package/dist/packages/plugin-renderer-tiling-sprite/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-tiling-sprite/lib/index.d.ts +0 -4
- package/dist/packages/plugin-renderer-tiling-sprite/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-renderer-tiling-sprite/lib/system.d.ts +0 -18
- package/dist/packages/plugin-renderer-tiling-sprite/lib/system.d.ts.map +0 -1
- package/dist/packages/plugin-sound/lib/Sound.d.ts +0 -44
- package/dist/packages/plugin-sound/lib/Sound.d.ts.map +0 -1
- package/dist/packages/plugin-sound/lib/SoundSystem.d.ts +0 -37
- package/dist/packages/plugin-sound/lib/SoundSystem.d.ts.map +0 -1
- package/dist/packages/plugin-sound/lib/index.d.ts +0 -3
- package/dist/packages/plugin-sound/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/Stats.d.ts +0 -19
- package/dist/packages/plugin-stats/lib/Stats.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/StatsComponent.d.ts +0 -7
- package/dist/packages/plugin-stats/lib/StatsComponent.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/StatsSystem.d.ts +0 -28
- package/dist/packages/plugin-stats/lib/StatsSystem.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/hooks/BaseHooks.d.ts +0 -18
- package/dist/packages/plugin-stats/lib/hooks/BaseHooks.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/hooks/GLHook.d.ts +0 -11
- package/dist/packages/plugin-stats/lib/hooks/GLHook.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/hooks/TextureHook.d.ts +0 -16
- package/dist/packages/plugin-stats/lib/hooks/TextureHook.d.ts.map +0 -1
- package/dist/packages/plugin-stats/lib/index.d.ts +0 -9
- package/dist/packages/plugin-stats/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-transition/lib/Animation.d.ts +0 -38
- package/dist/packages/plugin-transition/lib/Animation.d.ts.map +0 -1
- package/dist/packages/plugin-transition/lib/component.d.ts +0 -35
- package/dist/packages/plugin-transition/lib/component.d.ts.map +0 -1
- package/dist/packages/plugin-transition/lib/index.d.ts +0 -3
- package/dist/packages/plugin-transition/lib/index.d.ts.map +0 -1
- package/dist/packages/plugin-transition/lib/system.d.ts +0 -6
- package/dist/packages/plugin-transition/lib/system.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/Application.d.ts +0 -3
- package/dist/packages/renderer-adapter/lib/Application.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/Container.d.ts +0 -5
- package/dist/packages/renderer-adapter/lib/Container.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/Graphics.d.ts +0 -5
- package/dist/packages/renderer-adapter/lib/Graphics.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/NinePatch.d.ts +0 -5
- package/dist/packages/renderer-adapter/lib/NinePatch.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/Sprite.d.ts +0 -9
- package/dist/packages/renderer-adapter/lib/Sprite.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/SpriteAnimation.d.ts +0 -14
- package/dist/packages/renderer-adapter/lib/SpriteAnimation.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/Text.d.ts +0 -6
- package/dist/packages/renderer-adapter/lib/Text.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/TilingSprite.d.ts +0 -9
- package/dist/packages/renderer-adapter/lib/TilingSprite.d.ts.map +0 -1
- package/dist/packages/renderer-adapter/lib/index.d.ts +0 -9
- package/dist/packages/renderer-adapter/lib/index.d.ts.map +0 -1
- package/dist/packages/spine-base/lib/Spine.d.ts +0 -32
- package/dist/packages/spine-base/lib/Spine.d.ts.map +0 -1
- package/dist/packages/spine-base/lib/SpineData.d.ts +0 -5
- package/dist/packages/spine-base/lib/SpineData.d.ts.map +0 -1
- package/dist/packages/spine-base/lib/SpineSystem.d.ts +0 -20
- package/dist/packages/spine-base/lib/SpineSystem.d.ts.map +0 -1
- package/dist/packages/spine-base/lib/TexCache.d.ts +0 -10
- package/dist/packages/spine-base/lib/TexCache.d.ts.map +0 -1
- package/dist/packages/spine-base/lib/index.d.ts +0 -4
- package/dist/packages/spine-base/lib/index.d.ts.map +0 -1
package/dist/EVA.plugin.sound.js
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
6
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
7
|
window.EVA = window.EVA || {};
|
|
3
8
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
4
|
-
var _EVA_IIFE_sound = function (exports, eva_js) {
|
|
9
|
+
var _EVA_IIFE_sound = function (exports, eva_js, pixi_js) {
|
|
5
10
|
'use strict';
|
|
6
|
-
var extendStatics = function (d, b) {
|
|
7
|
-
extendStatics = Object.setPrototypeOf || {
|
|
8
|
-
__proto__: []
|
|
9
|
-
} instanceof Array && function (d, b) {
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
} || function (d, b) {
|
|
12
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
13
|
-
};
|
|
14
|
-
return extendStatics(d, b);
|
|
15
|
-
};
|
|
16
|
-
function __extends(d, b) {
|
|
17
|
-
extendStatics(d, b);
|
|
18
|
-
function __() {
|
|
19
|
-
this.constructor = d;
|
|
20
|
-
}
|
|
21
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
22
|
-
}
|
|
23
11
|
function __decorate(decorators, target, key, desc) {
|
|
24
12
|
var c = arguments.length,
|
|
25
13
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -54,417 +42,1720 @@ var _EVA_IIFE_sound = function (exports, eva_js) {
|
|
|
54
42
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
55
43
|
});
|
|
56
44
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
let instance;
|
|
46
|
+
function setInstance(sound) {
|
|
47
|
+
instance = sound;
|
|
48
|
+
return sound;
|
|
49
|
+
}
|
|
50
|
+
function getInstance() {
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
class WebAudioUtils {
|
|
54
|
+
static setParamValue(param, value) {
|
|
55
|
+
if (param.setValueAtTime) {
|
|
56
|
+
const context = getInstance().context;
|
|
57
|
+
param.setValueAtTime(value, context.audioContext.currentTime);
|
|
58
|
+
} else {
|
|
59
|
+
param.value = value;
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class HTMLAudioContext extends pixi_js.EventEmitter {
|
|
65
|
+
constructor() {
|
|
66
|
+
super(...arguments);
|
|
67
|
+
this.speed = 1;
|
|
68
|
+
this.muted = false;
|
|
69
|
+
this.volume = 1;
|
|
70
|
+
this.paused = false;
|
|
71
|
+
}
|
|
72
|
+
refresh() {
|
|
73
|
+
this.emit("refresh");
|
|
74
|
+
}
|
|
75
|
+
refreshPaused() {
|
|
76
|
+
this.emit("refreshPaused");
|
|
77
|
+
}
|
|
78
|
+
get filters() {
|
|
79
|
+
console.warn("HTML Audio does not support filters");
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
set filters(_filters) {
|
|
83
|
+
console.warn("HTML Audio does not support filters");
|
|
84
|
+
}
|
|
85
|
+
get audioContext() {
|
|
86
|
+
console.warn("HTML Audio does not support audioContext");
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
toggleMute() {
|
|
90
|
+
this.muted = !this.muted;
|
|
91
|
+
this.refresh();
|
|
92
|
+
return this.muted;
|
|
93
|
+
}
|
|
94
|
+
togglePause() {
|
|
95
|
+
this.paused = !this.paused;
|
|
96
|
+
this.refreshPaused();
|
|
97
|
+
return this.paused;
|
|
98
|
+
}
|
|
99
|
+
destroy() {
|
|
100
|
+
this.removeAllListeners();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
let id$1 = 0;
|
|
104
|
+
const _HTMLAudioInstance = class extends pixi_js.EventEmitter {
|
|
105
|
+
constructor(parent) {
|
|
106
|
+
super();
|
|
107
|
+
this.id = id$1++;
|
|
108
|
+
this.init(parent);
|
|
109
|
+
}
|
|
110
|
+
set(name, value) {
|
|
111
|
+
if (this[name] === void 0) {
|
|
112
|
+
throw new Error(`Property with name ${name} does not exist.`);
|
|
113
|
+
} else {
|
|
114
|
+
switch (name) {
|
|
115
|
+
case "speed":
|
|
116
|
+
this.speed = value;
|
|
117
|
+
break;
|
|
118
|
+
case "volume":
|
|
119
|
+
this.volume = value;
|
|
120
|
+
break;
|
|
121
|
+
case "paused":
|
|
122
|
+
this.paused = value;
|
|
123
|
+
break;
|
|
124
|
+
case "loop":
|
|
125
|
+
this.loop = value;
|
|
126
|
+
break;
|
|
127
|
+
case "muted":
|
|
128
|
+
this.muted = value;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
76
132
|
return this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
}
|
|
134
|
+
get progress() {
|
|
135
|
+
const {
|
|
136
|
+
currentTime
|
|
137
|
+
} = this._source;
|
|
138
|
+
return currentTime / this._duration;
|
|
139
|
+
}
|
|
140
|
+
get paused() {
|
|
141
|
+
return this._paused;
|
|
142
|
+
}
|
|
143
|
+
set paused(paused) {
|
|
144
|
+
this._paused = paused;
|
|
145
|
+
this.refreshPaused();
|
|
146
|
+
}
|
|
147
|
+
_onPlay() {
|
|
148
|
+
this._playing = true;
|
|
149
|
+
}
|
|
150
|
+
_onPause() {
|
|
151
|
+
this._playing = false;
|
|
152
|
+
}
|
|
153
|
+
init(media) {
|
|
154
|
+
this._playing = false;
|
|
155
|
+
this._duration = media.source.duration;
|
|
156
|
+
const source = this._source = media.source.cloneNode(false);
|
|
157
|
+
source.src = media.parent.url;
|
|
158
|
+
source.onplay = this._onPlay.bind(this);
|
|
159
|
+
source.onpause = this._onPause.bind(this);
|
|
160
|
+
media.context.on("refresh", this.refresh, this);
|
|
161
|
+
media.context.on("refreshPaused", this.refreshPaused, this);
|
|
162
|
+
this._media = media;
|
|
163
|
+
}
|
|
164
|
+
_internalStop() {
|
|
165
|
+
if (this._source && this._playing) {
|
|
166
|
+
this._source.onended = null;
|
|
167
|
+
this._source.pause();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
stop() {
|
|
171
|
+
this._internalStop();
|
|
172
|
+
if (this._source) {
|
|
173
|
+
this.emit("stop");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
get speed() {
|
|
177
|
+
return this._speed;
|
|
178
|
+
}
|
|
179
|
+
set speed(speed) {
|
|
180
|
+
this._speed = speed;
|
|
181
|
+
this.refresh();
|
|
182
|
+
}
|
|
183
|
+
get volume() {
|
|
184
|
+
return this._volume;
|
|
185
|
+
}
|
|
186
|
+
set volume(volume) {
|
|
187
|
+
this._volume = volume;
|
|
188
|
+
this.refresh();
|
|
189
|
+
}
|
|
190
|
+
get loop() {
|
|
191
|
+
return this._loop;
|
|
192
|
+
}
|
|
193
|
+
set loop(loop) {
|
|
194
|
+
this._loop = loop;
|
|
195
|
+
this.refresh();
|
|
196
|
+
}
|
|
197
|
+
get muted() {
|
|
198
|
+
return this._muted;
|
|
199
|
+
}
|
|
200
|
+
set muted(muted) {
|
|
201
|
+
this._muted = muted;
|
|
202
|
+
this.refresh();
|
|
203
|
+
}
|
|
204
|
+
get filters() {
|
|
205
|
+
console.warn("HTML Audio does not support filters");
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
set filters(_filters) {
|
|
209
|
+
console.warn("HTML Audio does not support filters");
|
|
210
|
+
}
|
|
211
|
+
refresh() {
|
|
212
|
+
const global = this._media.context;
|
|
213
|
+
const sound = this._media.parent;
|
|
214
|
+
this._source.loop = this._loop || sound.loop;
|
|
215
|
+
const globalVolume = global.volume * (global.muted ? 0 : 1);
|
|
216
|
+
const soundVolume = sound.volume * (sound.muted ? 0 : 1);
|
|
217
|
+
const instanceVolume = this._volume * (this._muted ? 0 : 1);
|
|
218
|
+
this._source.volume = instanceVolume * globalVolume * soundVolume;
|
|
219
|
+
this._source.playbackRate = this._speed * global.speed * sound.speed;
|
|
220
|
+
}
|
|
221
|
+
refreshPaused() {
|
|
222
|
+
const global = this._media.context;
|
|
223
|
+
const sound = this._media.parent;
|
|
224
|
+
const pausedReal = this._paused || sound.paused || global.paused;
|
|
225
|
+
if (pausedReal !== this._pausedReal) {
|
|
226
|
+
this._pausedReal = pausedReal;
|
|
227
|
+
if (pausedReal) {
|
|
228
|
+
this._internalStop();
|
|
229
|
+
this.emit("paused");
|
|
230
|
+
} else {
|
|
231
|
+
this.emit("resumed");
|
|
232
|
+
this.play({
|
|
233
|
+
start: this._source.currentTime,
|
|
234
|
+
end: this._end,
|
|
235
|
+
volume: this._volume,
|
|
236
|
+
speed: this._speed,
|
|
237
|
+
loop: this._loop
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
this.emit("pause", pausedReal);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
play(options) {
|
|
244
|
+
const {
|
|
245
|
+
start,
|
|
246
|
+
end,
|
|
247
|
+
speed,
|
|
248
|
+
loop,
|
|
249
|
+
volume,
|
|
250
|
+
muted
|
|
251
|
+
} = options;
|
|
252
|
+
if (end) {
|
|
253
|
+
console.assert(end > start, "End time is before start time");
|
|
254
|
+
}
|
|
255
|
+
this._speed = speed;
|
|
256
|
+
this._volume = volume;
|
|
257
|
+
this._loop = !!loop;
|
|
258
|
+
this._muted = muted;
|
|
259
|
+
this.refresh();
|
|
260
|
+
if (this.loop && end !== null) {
|
|
261
|
+
console.warn('Looping not support when specifying an "end" time');
|
|
262
|
+
this.loop = false;
|
|
263
|
+
}
|
|
264
|
+
this._start = start;
|
|
265
|
+
this._end = end || this._duration;
|
|
266
|
+
this._start = Math.max(0, this._start - _HTMLAudioInstance.PADDING);
|
|
267
|
+
this._end = Math.min(this._end + _HTMLAudioInstance.PADDING, this._duration);
|
|
268
|
+
this._source.onloadedmetadata = () => {
|
|
269
|
+
if (this._source) {
|
|
270
|
+
this._source.currentTime = start;
|
|
271
|
+
this._source.onloadedmetadata = null;
|
|
272
|
+
this.emit("progress", start / this._duration, this._duration);
|
|
273
|
+
pixi_js.Ticker.shared.add(this._onUpdate, this);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
this._source.onended = this._onComplete.bind(this);
|
|
277
|
+
this._source.play();
|
|
278
|
+
this.emit("start");
|
|
279
|
+
}
|
|
280
|
+
_onUpdate() {
|
|
281
|
+
this.emit("progress", this.progress, this._duration);
|
|
282
|
+
if (this._source.currentTime >= this._end && !this._source.loop) {
|
|
283
|
+
this._onComplete();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
_onComplete() {
|
|
287
|
+
pixi_js.Ticker.shared.remove(this._onUpdate, this);
|
|
288
|
+
this._internalStop();
|
|
289
|
+
this.emit("progress", 1, this._duration);
|
|
290
|
+
this.emit("end", this);
|
|
291
|
+
}
|
|
292
|
+
destroy() {
|
|
293
|
+
pixi_js.Ticker.shared.remove(this._onUpdate, this);
|
|
294
|
+
this.removeAllListeners();
|
|
295
|
+
const source = this._source;
|
|
296
|
+
if (source) {
|
|
297
|
+
source.onended = null;
|
|
298
|
+
source.onplay = null;
|
|
299
|
+
source.onpause = null;
|
|
300
|
+
this._internalStop();
|
|
301
|
+
}
|
|
302
|
+
this._source = null;
|
|
303
|
+
this._speed = 1;
|
|
304
|
+
this._volume = 1;
|
|
305
|
+
this._loop = false;
|
|
306
|
+
this._end = null;
|
|
307
|
+
this._start = 0;
|
|
308
|
+
this._duration = 0;
|
|
309
|
+
this._playing = false;
|
|
310
|
+
this._pausedReal = false;
|
|
311
|
+
this._paused = false;
|
|
312
|
+
this._muted = false;
|
|
313
|
+
if (this._media) {
|
|
314
|
+
this._media.context.off("refresh", this.refresh, this);
|
|
315
|
+
this._media.context.off("refreshPaused", this.refreshPaused, this);
|
|
316
|
+
this._media = null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
toString() {
|
|
320
|
+
return `[HTMLAudioInstance id=${this.id}]`;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
let HTMLAudioInstance = _HTMLAudioInstance;
|
|
324
|
+
HTMLAudioInstance.PADDING = 0.1;
|
|
325
|
+
class HTMLAudioMedia extends pixi_js.EventEmitter {
|
|
326
|
+
init(parent) {
|
|
327
|
+
this.parent = parent;
|
|
328
|
+
this._source = parent.options.source || new Audio();
|
|
329
|
+
if (parent.url) {
|
|
330
|
+
this._source.src = parent.url;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
create() {
|
|
334
|
+
return new HTMLAudioInstance(this);
|
|
335
|
+
}
|
|
336
|
+
get isPlayable() {
|
|
337
|
+
return !!this._source && this._source.readyState === 4;
|
|
338
|
+
}
|
|
339
|
+
get duration() {
|
|
340
|
+
return this._source.duration;
|
|
341
|
+
}
|
|
342
|
+
get context() {
|
|
343
|
+
return this.parent.context;
|
|
344
|
+
}
|
|
345
|
+
get filters() {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
set filters(_filters) {
|
|
349
|
+
console.warn("HTML Audio does not support filters");
|
|
350
|
+
}
|
|
351
|
+
destroy() {
|
|
352
|
+
this.removeAllListeners();
|
|
353
|
+
this.parent = null;
|
|
354
|
+
if (this._source) {
|
|
355
|
+
this._source.src = "";
|
|
356
|
+
this._source.load();
|
|
357
|
+
this._source = null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
get source() {
|
|
361
|
+
return this._source;
|
|
362
|
+
}
|
|
363
|
+
load(callback) {
|
|
364
|
+
const source = this._source;
|
|
365
|
+
const sound = this.parent;
|
|
366
|
+
if (source.readyState === 4) {
|
|
367
|
+
sound.isLoaded = true;
|
|
368
|
+
const instance = sound.autoPlayStart();
|
|
369
|
+
if (callback) {
|
|
370
|
+
setTimeout(() => {
|
|
371
|
+
callback(null, sound, instance);
|
|
372
|
+
}, 0);
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!sound.url) {
|
|
377
|
+
callback(new Error("sound.url or sound.source must be set"));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
source.src = sound.url;
|
|
381
|
+
const onLoad = () => {
|
|
382
|
+
removeListeners();
|
|
383
|
+
sound.isLoaded = true;
|
|
384
|
+
const instance = sound.autoPlayStart();
|
|
385
|
+
if (callback) {
|
|
386
|
+
callback(null, sound, instance);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
const onAbort = () => {
|
|
390
|
+
removeListeners();
|
|
391
|
+
if (callback) {
|
|
392
|
+
callback(new Error("Sound loading has been aborted"));
|
|
393
|
+
}
|
|
81
394
|
};
|
|
395
|
+
const onError = () => {
|
|
396
|
+
removeListeners();
|
|
397
|
+
const message = `Failed to load audio element (code: ${source.error.code})`;
|
|
398
|
+
if (callback) {
|
|
399
|
+
callback(new Error(message));
|
|
400
|
+
} else {
|
|
401
|
+
console.error(message);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const removeListeners = () => {
|
|
405
|
+
source.removeEventListener("canplaythrough", onLoad);
|
|
406
|
+
source.removeEventListener("load", onLoad);
|
|
407
|
+
source.removeEventListener("abort", onAbort);
|
|
408
|
+
source.removeEventListener("error", onError);
|
|
409
|
+
};
|
|
410
|
+
source.addEventListener("canplaythrough", onLoad, false);
|
|
411
|
+
source.addEventListener("load", onLoad, false);
|
|
412
|
+
source.addEventListener("abort", onAbort, false);
|
|
413
|
+
source.addEventListener("error", onError, false);
|
|
414
|
+
source.load();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
class SoundSprite {
|
|
418
|
+
constructor(parent, options) {
|
|
419
|
+
this.parent = parent;
|
|
420
|
+
_extends(this, options);
|
|
421
|
+
this.duration = this.end - this.start;
|
|
422
|
+
console.assert(this.duration > 0, "End time must be after start time");
|
|
423
|
+
}
|
|
424
|
+
play(complete) {
|
|
425
|
+
return this.parent.play({
|
|
426
|
+
complete,
|
|
427
|
+
speed: this.speed || this.parent.speed,
|
|
428
|
+
end: this.end,
|
|
429
|
+
start: this.start,
|
|
430
|
+
loop: this.loop
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
destroy() {
|
|
434
|
+
this.parent = null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const extensions = ["ogg", "oga", "opus", "m4a", "mp3", "mpeg", "wav", "aiff", "wma", "mid", "caf"];
|
|
438
|
+
const mimes = ["audio/mpeg", "audio/ogg"];
|
|
439
|
+
const supported = {};
|
|
440
|
+
function validateFormats(typeOverrides) {
|
|
441
|
+
const overrides = _objectSpread({
|
|
442
|
+
m4a: "audio/mp4",
|
|
443
|
+
oga: "audio/ogg",
|
|
444
|
+
opus: 'audio/ogg; codecs="opus"',
|
|
445
|
+
caf: 'audio/x-caf; codecs="opus"'
|
|
446
|
+
}, typeOverrides || {});
|
|
447
|
+
const audio = document.createElement("audio");
|
|
448
|
+
const formats = {};
|
|
449
|
+
const no = /^no$/;
|
|
450
|
+
extensions.forEach(ext => {
|
|
451
|
+
const canByExt = audio.canPlayType(`audio/${ext}`).replace(no, "");
|
|
452
|
+
const canByType = overrides[ext] ? audio.canPlayType(overrides[ext]).replace(no, "") : "";
|
|
453
|
+
formats[ext] = !!canByExt || !!canByType;
|
|
454
|
+
});
|
|
455
|
+
_extends(supported, formats);
|
|
456
|
+
}
|
|
457
|
+
validateFormats();
|
|
458
|
+
let id = 0;
|
|
459
|
+
class WebAudioInstance extends pixi_js.EventEmitter {
|
|
460
|
+
constructor(media) {
|
|
461
|
+
super();
|
|
462
|
+
this.id = id++;
|
|
463
|
+
this._media = null;
|
|
464
|
+
this._paused = false;
|
|
465
|
+
this._muted = false;
|
|
466
|
+
this._elapsed = 0;
|
|
467
|
+
this.init(media);
|
|
82
468
|
}
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
469
|
+
set(name, value) {
|
|
470
|
+
if (this[name] === void 0) {
|
|
471
|
+
throw new Error(`Property with name ${name} does not exist.`);
|
|
472
|
+
} else {
|
|
473
|
+
switch (name) {
|
|
474
|
+
case "speed":
|
|
475
|
+
this.speed = value;
|
|
476
|
+
break;
|
|
477
|
+
case "volume":
|
|
478
|
+
this.volume = value;
|
|
479
|
+
break;
|
|
480
|
+
case "muted":
|
|
481
|
+
this.muted = value;
|
|
482
|
+
break;
|
|
483
|
+
case "loop":
|
|
484
|
+
this.loop = value;
|
|
485
|
+
break;
|
|
486
|
+
case "paused":
|
|
487
|
+
this.paused = value;
|
|
92
488
|
break;
|
|
93
|
-
case 4:
|
|
94
|
-
_.label++;
|
|
95
|
-
return {
|
|
96
|
-
value: op[1],
|
|
97
|
-
done: false
|
|
98
|
-
};
|
|
99
|
-
case 5:
|
|
100
|
-
_.label++;
|
|
101
|
-
y = op[1];
|
|
102
|
-
op = [0];
|
|
103
|
-
continue;
|
|
104
|
-
case 7:
|
|
105
|
-
op = _.ops.pop();
|
|
106
|
-
_.trys.pop();
|
|
107
|
-
continue;
|
|
108
|
-
default:
|
|
109
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
110
|
-
_ = 0;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
114
|
-
_.label = op[1];
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
118
|
-
_.label = t[1];
|
|
119
|
-
t = op;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
if (t && _.label < t[2]) {
|
|
123
|
-
_.label = t[2];
|
|
124
|
-
_.ops.push(op);
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
if (t[2]) _.ops.pop();
|
|
128
|
-
_.trys.pop();
|
|
129
|
-
continue;
|
|
130
489
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
490
|
+
}
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
stop() {
|
|
494
|
+
if (this._source) {
|
|
495
|
+
this._internalStop();
|
|
496
|
+
this.emit("stop");
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
get speed() {
|
|
500
|
+
return this._speed;
|
|
501
|
+
}
|
|
502
|
+
set speed(speed) {
|
|
503
|
+
this._speed = speed;
|
|
504
|
+
this.refresh();
|
|
505
|
+
this._update(true);
|
|
506
|
+
}
|
|
507
|
+
get volume() {
|
|
508
|
+
return this._volume;
|
|
509
|
+
}
|
|
510
|
+
set volume(volume) {
|
|
511
|
+
this._volume = volume;
|
|
512
|
+
this.refresh();
|
|
513
|
+
}
|
|
514
|
+
get muted() {
|
|
515
|
+
return this._muted;
|
|
516
|
+
}
|
|
517
|
+
set muted(muted) {
|
|
518
|
+
this._muted = muted;
|
|
519
|
+
this.refresh();
|
|
520
|
+
}
|
|
521
|
+
get loop() {
|
|
522
|
+
return this._loop;
|
|
523
|
+
}
|
|
524
|
+
set loop(loop) {
|
|
525
|
+
this._loop = loop;
|
|
526
|
+
this.refresh();
|
|
527
|
+
}
|
|
528
|
+
get filters() {
|
|
529
|
+
return this._filters;
|
|
530
|
+
}
|
|
531
|
+
set filters(filters) {
|
|
532
|
+
if (this._filters) {
|
|
533
|
+
var _this$_filters;
|
|
534
|
+
(_this$_filters = this._filters) === null || _this$_filters === void 0 ? void 0 : _this$_filters.filter(filter => filter).forEach(filter => filter.disconnect());
|
|
535
|
+
this._filters = null;
|
|
536
|
+
this._source.connect(this._gain);
|
|
537
|
+
}
|
|
538
|
+
this._filters = filters !== null && filters !== void 0 && filters.length ? filters.slice(0) : null;
|
|
539
|
+
this.refresh();
|
|
540
|
+
}
|
|
541
|
+
refresh() {
|
|
542
|
+
if (!this._source) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const global = this._media.context;
|
|
546
|
+
const sound = this._media.parent;
|
|
547
|
+
this._source.loop = this._loop || sound.loop;
|
|
548
|
+
const globalVolume = global.volume * (global.muted ? 0 : 1);
|
|
549
|
+
const soundVolume = sound.volume * (sound.muted ? 0 : 1);
|
|
550
|
+
const instanceVolume = this._volume * (this._muted ? 0 : 1);
|
|
551
|
+
WebAudioUtils.setParamValue(this._gain.gain, instanceVolume * soundVolume * globalVolume);
|
|
552
|
+
WebAudioUtils.setParamValue(this._source.playbackRate, this._speed * sound.speed * global.speed);
|
|
553
|
+
this.applyFilters();
|
|
554
|
+
}
|
|
555
|
+
applyFilters() {
|
|
556
|
+
var _this$_filters2;
|
|
557
|
+
if ((_this$_filters2 = this._filters) !== null && _this$_filters2 !== void 0 && _this$_filters2.length) {
|
|
558
|
+
this._source.disconnect();
|
|
559
|
+
let source = this._source;
|
|
560
|
+
this._filters.forEach(filter => {
|
|
561
|
+
source.connect(filter.destination);
|
|
562
|
+
source = filter;
|
|
563
|
+
});
|
|
564
|
+
source.connect(this._gain);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
refreshPaused() {
|
|
568
|
+
const global = this._media.context;
|
|
569
|
+
const sound = this._media.parent;
|
|
570
|
+
const pausedReal = this._paused || sound.paused || global.paused;
|
|
571
|
+
if (pausedReal !== this._pausedReal) {
|
|
572
|
+
this._pausedReal = pausedReal;
|
|
573
|
+
if (pausedReal) {
|
|
574
|
+
this._internalStop();
|
|
575
|
+
this.emit("paused");
|
|
576
|
+
} else {
|
|
577
|
+
this.emit("resumed");
|
|
578
|
+
this.play({
|
|
579
|
+
start: this._elapsed % this._duration,
|
|
580
|
+
end: this._end,
|
|
581
|
+
speed: this._speed,
|
|
582
|
+
loop: this._loop,
|
|
583
|
+
volume: this._volume
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
this.emit("pause", pausedReal);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
play(options) {
|
|
590
|
+
const {
|
|
591
|
+
start,
|
|
592
|
+
end,
|
|
593
|
+
speed,
|
|
594
|
+
loop,
|
|
595
|
+
volume,
|
|
596
|
+
muted,
|
|
597
|
+
filters
|
|
598
|
+
} = options;
|
|
599
|
+
if (end) {
|
|
600
|
+
console.assert(end > start, "End time is before start time");
|
|
601
|
+
}
|
|
602
|
+
this._paused = false;
|
|
603
|
+
const {
|
|
604
|
+
source,
|
|
605
|
+
gain
|
|
606
|
+
} = this._media.nodes.cloneBufferSource();
|
|
607
|
+
this._source = source;
|
|
608
|
+
this._gain = gain;
|
|
609
|
+
this._speed = speed;
|
|
610
|
+
this._volume = volume;
|
|
611
|
+
this._loop = !!loop;
|
|
612
|
+
this._muted = muted;
|
|
613
|
+
this._filters = filters;
|
|
614
|
+
this.refresh();
|
|
615
|
+
const duration = this._source.buffer.duration;
|
|
616
|
+
this._duration = duration;
|
|
617
|
+
this._end = end;
|
|
618
|
+
this._lastUpdate = this._now();
|
|
619
|
+
this._elapsed = start;
|
|
620
|
+
this._source.onended = this._onComplete.bind(this);
|
|
621
|
+
if (this._loop) {
|
|
622
|
+
this._source.loopEnd = end;
|
|
623
|
+
this._source.loopStart = start;
|
|
624
|
+
this._source.start(0, start);
|
|
625
|
+
} else if (end) {
|
|
626
|
+
this._source.start(0, start, end - start);
|
|
627
|
+
} else {
|
|
628
|
+
this._source.start(0, start);
|
|
629
|
+
}
|
|
630
|
+
this.emit("start");
|
|
631
|
+
this._update(true);
|
|
632
|
+
this.enableTicker(true);
|
|
633
|
+
}
|
|
634
|
+
enableTicker(enabled) {
|
|
635
|
+
pixi_js.Ticker.shared.remove(this._updateListener, this);
|
|
636
|
+
if (enabled) {
|
|
637
|
+
pixi_js.Ticker.shared.add(this._updateListener, this);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
get progress() {
|
|
641
|
+
return this._progress;
|
|
642
|
+
}
|
|
643
|
+
get paused() {
|
|
644
|
+
return this._paused;
|
|
645
|
+
}
|
|
646
|
+
set paused(paused) {
|
|
647
|
+
this._paused = paused;
|
|
648
|
+
this.refreshPaused();
|
|
649
|
+
}
|
|
650
|
+
destroy() {
|
|
651
|
+
var _this$_filters3;
|
|
652
|
+
this.removeAllListeners();
|
|
653
|
+
this._internalStop();
|
|
654
|
+
if (this._gain) {
|
|
655
|
+
this._gain.disconnect();
|
|
656
|
+
this._gain = null;
|
|
657
|
+
}
|
|
658
|
+
if (this._media) {
|
|
659
|
+
this._media.context.events.off("refresh", this.refresh, this);
|
|
660
|
+
this._media.context.events.off("refreshPaused", this.refreshPaused, this);
|
|
661
|
+
this._media = null;
|
|
662
|
+
}
|
|
663
|
+
(_this$_filters3 = this._filters) === null || _this$_filters3 === void 0 ? void 0 : _this$_filters3.forEach(filter => filter.disconnect());
|
|
664
|
+
this._filters = null;
|
|
665
|
+
this._end = null;
|
|
666
|
+
this._speed = 1;
|
|
667
|
+
this._volume = 1;
|
|
668
|
+
this._loop = false;
|
|
669
|
+
this._elapsed = 0;
|
|
670
|
+
this._duration = 0;
|
|
671
|
+
this._paused = false;
|
|
672
|
+
this._muted = false;
|
|
673
|
+
this._pausedReal = false;
|
|
674
|
+
}
|
|
675
|
+
toString() {
|
|
676
|
+
return `[WebAudioInstance id=${this.id}]`;
|
|
677
|
+
}
|
|
678
|
+
_now() {
|
|
679
|
+
return this._media.context.audioContext.currentTime;
|
|
680
|
+
}
|
|
681
|
+
_updateListener() {
|
|
682
|
+
this._update();
|
|
683
|
+
}
|
|
684
|
+
_update(force = false) {
|
|
685
|
+
if (this._source) {
|
|
686
|
+
const now = this._now();
|
|
687
|
+
const delta = now - this._lastUpdate;
|
|
688
|
+
if (delta > 0 || force) {
|
|
689
|
+
const speed = this._source.playbackRate.value;
|
|
690
|
+
this._elapsed += delta * speed;
|
|
691
|
+
this._lastUpdate = now;
|
|
692
|
+
const duration = this._duration;
|
|
693
|
+
let progress;
|
|
694
|
+
if (this._source.loopStart) {
|
|
695
|
+
const soundLength = this._source.loopEnd - this._source.loopStart;
|
|
696
|
+
progress = (this._source.loopStart + this._elapsed % soundLength) / duration;
|
|
697
|
+
} else {
|
|
698
|
+
progress = this._elapsed % duration / duration;
|
|
699
|
+
}
|
|
700
|
+
this._progress = progress;
|
|
701
|
+
this.emit("progress", this._progress, duration);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
init(media) {
|
|
706
|
+
this._media = media;
|
|
707
|
+
media.context.events.on("refresh", this.refresh, this);
|
|
708
|
+
media.context.events.on("refreshPaused", this.refreshPaused, this);
|
|
709
|
+
}
|
|
710
|
+
_internalStop() {
|
|
711
|
+
if (this._source) {
|
|
712
|
+
this.enableTicker(false);
|
|
713
|
+
this._source.onended = null;
|
|
714
|
+
this._source.stop(0);
|
|
715
|
+
this._source.disconnect();
|
|
716
|
+
try {
|
|
717
|
+
this._source.buffer = null;
|
|
718
|
+
} catch (err) {
|
|
719
|
+
console.warn("Failed to set AudioBufferSourceNode.buffer to null:", err);
|
|
720
|
+
}
|
|
721
|
+
this._source = null;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
_onComplete() {
|
|
725
|
+
if (this._source) {
|
|
726
|
+
this.enableTicker(false);
|
|
727
|
+
this._source.onended = null;
|
|
728
|
+
this._source.disconnect();
|
|
729
|
+
try {
|
|
730
|
+
this._source.buffer = null;
|
|
731
|
+
} catch (err) {
|
|
732
|
+
console.warn("Failed to set AudioBufferSourceNode.buffer to null:", err);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
this._source = null;
|
|
736
|
+
this._progress = 1;
|
|
737
|
+
this.emit("progress", 1, this._duration);
|
|
738
|
+
this.emit("end", this);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
class Filterable {
|
|
742
|
+
constructor(input, output) {
|
|
743
|
+
this._output = output;
|
|
744
|
+
this._input = input;
|
|
745
|
+
}
|
|
746
|
+
get destination() {
|
|
747
|
+
return this._input;
|
|
748
|
+
}
|
|
749
|
+
get filters() {
|
|
750
|
+
return this._filters;
|
|
751
|
+
}
|
|
752
|
+
set filters(filters) {
|
|
753
|
+
if (this._filters) {
|
|
754
|
+
this._filters.forEach(filter => {
|
|
755
|
+
if (filter) {
|
|
756
|
+
filter.disconnect();
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
this._filters = null;
|
|
760
|
+
this._input.connect(this._output);
|
|
761
|
+
}
|
|
762
|
+
if (filters && filters.length) {
|
|
763
|
+
this._filters = filters.slice(0);
|
|
764
|
+
this._input.disconnect();
|
|
765
|
+
let prevFilter = null;
|
|
766
|
+
filters.forEach(filter => {
|
|
767
|
+
if (prevFilter === null) {
|
|
768
|
+
this._input.connect(filter.destination);
|
|
769
|
+
} else {
|
|
770
|
+
prevFilter.connect(filter.destination);
|
|
771
|
+
}
|
|
772
|
+
prevFilter = filter;
|
|
773
|
+
});
|
|
774
|
+
prevFilter.connect(this._output);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
destroy() {
|
|
778
|
+
this.filters = null;
|
|
779
|
+
this._input = null;
|
|
780
|
+
this._output = null;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const _WebAudioNodes = class extends Filterable {
|
|
784
|
+
constructor(context) {
|
|
785
|
+
const audioContext = context.audioContext;
|
|
786
|
+
const bufferSource = audioContext.createBufferSource();
|
|
787
|
+
const gain = audioContext.createGain();
|
|
788
|
+
const analyser = audioContext.createAnalyser();
|
|
789
|
+
bufferSource.connect(analyser);
|
|
790
|
+
analyser.connect(gain);
|
|
791
|
+
gain.connect(context.destination);
|
|
792
|
+
super(analyser, gain);
|
|
793
|
+
this.context = context;
|
|
794
|
+
this.bufferSource = bufferSource;
|
|
795
|
+
this.gain = gain;
|
|
796
|
+
this.analyser = analyser;
|
|
797
|
+
}
|
|
798
|
+
get script() {
|
|
799
|
+
if (!this._script) {
|
|
800
|
+
this._script = this.context.audioContext.createScriptProcessor(_WebAudioNodes.BUFFER_SIZE);
|
|
801
|
+
this._script.connect(this.context.destination);
|
|
802
|
+
}
|
|
803
|
+
return this._script;
|
|
804
|
+
}
|
|
805
|
+
destroy() {
|
|
806
|
+
super.destroy();
|
|
807
|
+
this.bufferSource.disconnect();
|
|
808
|
+
if (this._script) {
|
|
809
|
+
this._script.disconnect();
|
|
810
|
+
}
|
|
811
|
+
this.gain.disconnect();
|
|
812
|
+
this.analyser.disconnect();
|
|
813
|
+
this.bufferSource = null;
|
|
814
|
+
this._script = null;
|
|
815
|
+
this.gain = null;
|
|
816
|
+
this.analyser = null;
|
|
817
|
+
this.context = null;
|
|
818
|
+
}
|
|
819
|
+
cloneBufferSource() {
|
|
820
|
+
const orig = this.bufferSource;
|
|
821
|
+
const source = this.context.audioContext.createBufferSource();
|
|
822
|
+
source.buffer = orig.buffer;
|
|
823
|
+
WebAudioUtils.setParamValue(source.playbackRate, orig.playbackRate.value);
|
|
824
|
+
source.loop = orig.loop;
|
|
825
|
+
const gain = this.context.audioContext.createGain();
|
|
826
|
+
source.connect(gain);
|
|
827
|
+
gain.connect(this.destination);
|
|
139
828
|
return {
|
|
140
|
-
|
|
141
|
-
|
|
829
|
+
source,
|
|
830
|
+
gain
|
|
142
831
|
};
|
|
143
832
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
833
|
+
get bufferSize() {
|
|
834
|
+
return this.script.bufferSize;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
let WebAudioNodes = _WebAudioNodes;
|
|
838
|
+
WebAudioNodes.BUFFER_SIZE = 0;
|
|
839
|
+
class WebAudioMedia {
|
|
840
|
+
init(parent) {
|
|
841
|
+
this.parent = parent;
|
|
842
|
+
this._nodes = new WebAudioNodes(this.context);
|
|
843
|
+
this._source = this._nodes.bufferSource;
|
|
844
|
+
this.source = parent.options.source;
|
|
845
|
+
}
|
|
846
|
+
destroy() {
|
|
847
|
+
this.parent = null;
|
|
848
|
+
this._nodes.destroy();
|
|
849
|
+
this._nodes = null;
|
|
850
|
+
try {
|
|
851
|
+
this._source.buffer = null;
|
|
852
|
+
} catch (err) {
|
|
853
|
+
console.warn("Failed to set AudioBufferSourceNode.buffer to null:", err);
|
|
854
|
+
}
|
|
855
|
+
this._source = null;
|
|
856
|
+
this.source = null;
|
|
857
|
+
}
|
|
858
|
+
create() {
|
|
859
|
+
return new WebAudioInstance(this);
|
|
860
|
+
}
|
|
861
|
+
get context() {
|
|
862
|
+
return this.parent.context;
|
|
863
|
+
}
|
|
864
|
+
get isPlayable() {
|
|
865
|
+
return !!this._source && !!this._source.buffer;
|
|
866
|
+
}
|
|
867
|
+
get filters() {
|
|
868
|
+
return this._nodes.filters;
|
|
869
|
+
}
|
|
870
|
+
set filters(filters) {
|
|
871
|
+
this._nodes.filters = filters;
|
|
872
|
+
}
|
|
873
|
+
get duration() {
|
|
874
|
+
console.assert(this.isPlayable, "Sound not yet playable, no duration");
|
|
875
|
+
return this._source.buffer.duration;
|
|
876
|
+
}
|
|
877
|
+
get buffer() {
|
|
878
|
+
return this._source.buffer;
|
|
879
|
+
}
|
|
880
|
+
set buffer(buffer) {
|
|
881
|
+
this._source.buffer = buffer;
|
|
882
|
+
}
|
|
883
|
+
get nodes() {
|
|
884
|
+
return this._nodes;
|
|
885
|
+
}
|
|
886
|
+
load(callback) {
|
|
887
|
+
if (this.source) {
|
|
888
|
+
this._decode(this.source, callback);
|
|
889
|
+
} else if (this.parent.url) {
|
|
890
|
+
this._loadUrl(callback);
|
|
891
|
+
} else if (callback) {
|
|
892
|
+
callback(new Error("sound.url or sound.source must be set"));
|
|
893
|
+
} else {
|
|
894
|
+
console.error("sound.url or sound.source must be set");
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
async _loadUrl(callback) {
|
|
898
|
+
const url = this.parent.url;
|
|
899
|
+
const response = await pixi_js.DOMAdapter.get().fetch(url);
|
|
900
|
+
this._decode(await response.arrayBuffer(), callback);
|
|
901
|
+
}
|
|
902
|
+
_decode(arrayBuffer, callback) {
|
|
903
|
+
const audioBufferReadyFn = (err, buffer) => {
|
|
904
|
+
if (err) {
|
|
905
|
+
if (callback) {
|
|
906
|
+
callback(err);
|
|
907
|
+
}
|
|
908
|
+
} else {
|
|
909
|
+
this.parent.isLoaded = true;
|
|
910
|
+
this.buffer = buffer;
|
|
911
|
+
const instance = this.parent.autoPlayStart();
|
|
912
|
+
if (callback) {
|
|
913
|
+
callback(null, this.parent, instance);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
if (arrayBuffer instanceof AudioBuffer) {
|
|
918
|
+
audioBufferReadyFn(null, arrayBuffer);
|
|
919
|
+
} else {
|
|
920
|
+
const context = this.parent.context;
|
|
921
|
+
context.decode(arrayBuffer, audioBufferReadyFn);
|
|
157
922
|
}
|
|
158
|
-
}
|
|
159
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
923
|
+
}
|
|
160
924
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
925
|
+
const _Sound = class {
|
|
926
|
+
static from(source) {
|
|
927
|
+
let options = {};
|
|
928
|
+
if (typeof source === "string") {
|
|
929
|
+
options.url = source;
|
|
930
|
+
} else if (source instanceof ArrayBuffer || source instanceof AudioBuffer || source instanceof HTMLAudioElement) {
|
|
931
|
+
options.source = source;
|
|
932
|
+
} else if (Array.isArray(source)) {
|
|
933
|
+
options.url = source;
|
|
934
|
+
} else {
|
|
935
|
+
options = source;
|
|
936
|
+
}
|
|
937
|
+
options = _objectSpread({
|
|
938
|
+
autoPlay: false,
|
|
939
|
+
singleInstance: false,
|
|
940
|
+
url: null,
|
|
941
|
+
source: null,
|
|
942
|
+
preload: false,
|
|
943
|
+
volume: 1,
|
|
944
|
+
speed: 1,
|
|
945
|
+
complete: null,
|
|
946
|
+
loaded: null,
|
|
947
|
+
loop: false
|
|
948
|
+
}, options);
|
|
949
|
+
Object.freeze(options);
|
|
950
|
+
const media = getInstance().useLegacy ? new HTMLAudioMedia() : new WebAudioMedia();
|
|
951
|
+
return new _Sound(media, options);
|
|
952
|
+
}
|
|
953
|
+
constructor(media, options) {
|
|
954
|
+
this.media = media;
|
|
955
|
+
this.options = options;
|
|
956
|
+
this._instances = [];
|
|
957
|
+
this._sprites = {};
|
|
958
|
+
this.media.init(this);
|
|
959
|
+
const complete = options.complete;
|
|
960
|
+
this._autoPlayOptions = complete ? {
|
|
961
|
+
complete
|
|
962
|
+
} : null;
|
|
963
|
+
this.isLoaded = false;
|
|
964
|
+
this._preloadQueue = null;
|
|
965
|
+
this.isPlaying = false;
|
|
966
|
+
this.autoPlay = options.autoPlay;
|
|
967
|
+
this.singleInstance = options.singleInstance;
|
|
968
|
+
this.preload = options.preload || this.autoPlay;
|
|
969
|
+
this.url = Array.isArray(options.url) ? this.preferUrl(options.url) : options.url;
|
|
970
|
+
this.speed = options.speed;
|
|
971
|
+
this.volume = options.volume;
|
|
972
|
+
this.loop = options.loop;
|
|
973
|
+
if (options.sprites) {
|
|
974
|
+
this.addSprites(options.sprites);
|
|
975
|
+
}
|
|
976
|
+
if (this.preload) {
|
|
977
|
+
this._preload(options.loaded);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
preferUrl(urls) {
|
|
981
|
+
const [file] = urls.map(url => ({
|
|
982
|
+
url,
|
|
983
|
+
ext: pixi_js.path.extname(url).slice(1)
|
|
984
|
+
})).filter(({
|
|
985
|
+
ext
|
|
986
|
+
}) => supported[ext]).sort((a, b) => extensions.indexOf(a.ext) - extensions.indexOf(b.ext));
|
|
987
|
+
if (!file) {
|
|
988
|
+
throw new Error("No supported file type found");
|
|
989
|
+
}
|
|
990
|
+
return file.url;
|
|
991
|
+
}
|
|
992
|
+
get context() {
|
|
993
|
+
return getInstance().context;
|
|
994
|
+
}
|
|
995
|
+
pause() {
|
|
996
|
+
this.isPlaying = false;
|
|
997
|
+
this.paused = true;
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
resume() {
|
|
1001
|
+
this.isPlaying = this._instances.length > 0;
|
|
1002
|
+
this.paused = false;
|
|
1003
|
+
return this;
|
|
1004
|
+
}
|
|
1005
|
+
get paused() {
|
|
1006
|
+
return this._paused;
|
|
1007
|
+
}
|
|
1008
|
+
set paused(paused) {
|
|
1009
|
+
this._paused = paused;
|
|
1010
|
+
this.refreshPaused();
|
|
1011
|
+
}
|
|
1012
|
+
get speed() {
|
|
1013
|
+
return this._speed;
|
|
1014
|
+
}
|
|
1015
|
+
set speed(speed) {
|
|
1016
|
+
this._speed = speed;
|
|
1017
|
+
this.refresh();
|
|
1018
|
+
}
|
|
1019
|
+
get filters() {
|
|
1020
|
+
return this.media.filters;
|
|
1021
|
+
}
|
|
1022
|
+
set filters(filters) {
|
|
1023
|
+
this.media.filters = filters;
|
|
1024
|
+
}
|
|
1025
|
+
addSprites(source, data) {
|
|
1026
|
+
if (typeof source === "object") {
|
|
1027
|
+
const results = {};
|
|
1028
|
+
for (const alias in source) {
|
|
1029
|
+
results[alias] = this.addSprites(alias, source[alias]);
|
|
180
1030
|
}
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
1031
|
+
return results;
|
|
1032
|
+
}
|
|
1033
|
+
console.assert(!this._sprites[source], `Alias ${source} is already taken`);
|
|
1034
|
+
const sprite = new SoundSprite(this, data);
|
|
1035
|
+
this._sprites[source] = sprite;
|
|
1036
|
+
return sprite;
|
|
1037
|
+
}
|
|
1038
|
+
destroy() {
|
|
1039
|
+
this._removeInstances();
|
|
1040
|
+
this.removeSprites();
|
|
1041
|
+
this.media.destroy();
|
|
1042
|
+
this.media = null;
|
|
1043
|
+
this._sprites = null;
|
|
1044
|
+
this._instances = null;
|
|
1045
|
+
}
|
|
1046
|
+
removeSprites(alias) {
|
|
1047
|
+
if (!alias) {
|
|
1048
|
+
for (const name in this._sprites) {
|
|
1049
|
+
this.removeSprites(name);
|
|
193
1050
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
Object.defineProperty(SoundSystem.prototype, "audioLocked", {
|
|
200
|
-
get: function () {
|
|
201
|
-
if (!this.ctx) {
|
|
202
|
-
return true;
|
|
1051
|
+
} else {
|
|
1052
|
+
const sprite = this._sprites[alias];
|
|
1053
|
+
if (sprite !== void 0) {
|
|
1054
|
+
sprite.destroy();
|
|
1055
|
+
delete this._sprites[alias];
|
|
203
1056
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
1057
|
+
}
|
|
1058
|
+
return this;
|
|
1059
|
+
}
|
|
1060
|
+
get isPlayable() {
|
|
1061
|
+
return this.isLoaded && this.media && this.media.isPlayable;
|
|
1062
|
+
}
|
|
1063
|
+
stop() {
|
|
1064
|
+
if (!this.isPlayable) {
|
|
1065
|
+
this.autoPlay = false;
|
|
1066
|
+
this._autoPlayOptions = null;
|
|
1067
|
+
return this;
|
|
1068
|
+
}
|
|
1069
|
+
this.isPlaying = false;
|
|
1070
|
+
for (let i = this._instances.length - 1; i >= 0; i--) {
|
|
1071
|
+
this._instances[i].stop();
|
|
1072
|
+
}
|
|
1073
|
+
return this;
|
|
1074
|
+
}
|
|
1075
|
+
play(source, complete) {
|
|
1076
|
+
let options;
|
|
1077
|
+
if (typeof source === "string") {
|
|
1078
|
+
const sprite = source;
|
|
1079
|
+
options = {
|
|
1080
|
+
sprite,
|
|
1081
|
+
loop: this.loop,
|
|
1082
|
+
complete
|
|
1083
|
+
};
|
|
1084
|
+
} else if (typeof source === "function") {
|
|
1085
|
+
options = {};
|
|
1086
|
+
options.complete = source;
|
|
1087
|
+
} else {
|
|
1088
|
+
options = source;
|
|
1089
|
+
}
|
|
1090
|
+
options = _objectSpread({
|
|
1091
|
+
complete: null,
|
|
1092
|
+
loaded: null,
|
|
1093
|
+
sprite: null,
|
|
1094
|
+
end: null,
|
|
1095
|
+
start: 0,
|
|
1096
|
+
volume: 1,
|
|
1097
|
+
speed: 1,
|
|
1098
|
+
muted: false,
|
|
1099
|
+
loop: false
|
|
1100
|
+
}, options || {});
|
|
1101
|
+
if (options.sprite) {
|
|
1102
|
+
const alias = options.sprite;
|
|
1103
|
+
console.assert(!!this._sprites[alias], `Alias ${alias} is not available`);
|
|
1104
|
+
const sprite = this._sprites[alias];
|
|
1105
|
+
options.start = sprite.start + (options.start || 0);
|
|
1106
|
+
options.end = sprite.end;
|
|
1107
|
+
options.speed = sprite.speed || 1;
|
|
1108
|
+
options.loop = sprite.loop || options.loop;
|
|
1109
|
+
delete options.sprite;
|
|
1110
|
+
}
|
|
1111
|
+
if (options.offset) {
|
|
1112
|
+
options.start = options.offset;
|
|
1113
|
+
}
|
|
1114
|
+
if (!this.isLoaded) {
|
|
1115
|
+
if (this._preloadQueue) {
|
|
1116
|
+
return new Promise(resolve => {
|
|
1117
|
+
this._preloadQueue.push(() => {
|
|
1118
|
+
resolve(this.play(options));
|
|
1119
|
+
});
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
this._preloadQueue = [];
|
|
1123
|
+
this.autoPlay = true;
|
|
1124
|
+
this._autoPlayOptions = options;
|
|
1125
|
+
return new Promise((resolve, reject) => {
|
|
1126
|
+
this._preload((err, sound, media) => {
|
|
1127
|
+
this._preloadQueue.forEach(resolve2 => resolve2());
|
|
1128
|
+
this._preloadQueue = null;
|
|
1129
|
+
if (err) {
|
|
1130
|
+
reject(err);
|
|
1131
|
+
} else {
|
|
1132
|
+
if (options.loaded) {
|
|
1133
|
+
options.loaded(err, sound, media);
|
|
1134
|
+
}
|
|
1135
|
+
resolve(media);
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
214
1138
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1139
|
+
}
|
|
1140
|
+
if (this.singleInstance || options.singleInstance) {
|
|
1141
|
+
this._removeInstances();
|
|
1142
|
+
}
|
|
1143
|
+
const instance = this._createInstance();
|
|
1144
|
+
this._instances.push(instance);
|
|
1145
|
+
this.isPlaying = true;
|
|
1146
|
+
instance.once("end", () => {
|
|
1147
|
+
if (options.complete) {
|
|
1148
|
+
options.complete(this);
|
|
225
1149
|
}
|
|
1150
|
+
this._onComplete(instance);
|
|
226
1151
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
SoundSystem.prototype.stopAll = function () {
|
|
230
|
-
this.components.forEach(function (component) {
|
|
231
|
-
if (component.playing) {
|
|
232
|
-
component.stop();
|
|
233
|
-
}
|
|
1152
|
+
instance.once("stop", () => {
|
|
1153
|
+
this._onComplete(instance);
|
|
234
1154
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
1155
|
+
instance.play(options);
|
|
1156
|
+
return instance;
|
|
1157
|
+
}
|
|
1158
|
+
refresh() {
|
|
1159
|
+
const len = this._instances.length;
|
|
1160
|
+
for (let i = 0; i < len; i++) {
|
|
1161
|
+
this._instances[i].refresh();
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
refreshPaused() {
|
|
1165
|
+
const len = this._instances.length;
|
|
1166
|
+
for (let i = 0; i < len; i++) {
|
|
1167
|
+
this._instances[i].refreshPaused();
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
get volume() {
|
|
1171
|
+
return this._volume;
|
|
1172
|
+
}
|
|
1173
|
+
set volume(volume) {
|
|
1174
|
+
this._volume = volume;
|
|
1175
|
+
this.refresh();
|
|
1176
|
+
}
|
|
1177
|
+
get muted() {
|
|
1178
|
+
return this._muted;
|
|
1179
|
+
}
|
|
1180
|
+
set muted(muted) {
|
|
1181
|
+
this._muted = muted;
|
|
1182
|
+
this.refresh();
|
|
1183
|
+
}
|
|
1184
|
+
get loop() {
|
|
1185
|
+
return this._loop;
|
|
1186
|
+
}
|
|
1187
|
+
set loop(loop) {
|
|
1188
|
+
this._loop = loop;
|
|
1189
|
+
this.refresh();
|
|
1190
|
+
}
|
|
1191
|
+
_preload(callback) {
|
|
1192
|
+
this.media.load(callback);
|
|
1193
|
+
}
|
|
1194
|
+
get instances() {
|
|
1195
|
+
return this._instances;
|
|
1196
|
+
}
|
|
1197
|
+
get sprites() {
|
|
1198
|
+
return this._sprites;
|
|
1199
|
+
}
|
|
1200
|
+
get duration() {
|
|
1201
|
+
return this.media.duration;
|
|
1202
|
+
}
|
|
1203
|
+
autoPlayStart() {
|
|
1204
|
+
let instance;
|
|
1205
|
+
if (this.autoPlay) {
|
|
1206
|
+
instance = this.play(this._autoPlayOptions);
|
|
1207
|
+
}
|
|
1208
|
+
return instance;
|
|
1209
|
+
}
|
|
1210
|
+
_removeInstances() {
|
|
1211
|
+
for (let i = this._instances.length - 1; i >= 0; i--) {
|
|
1212
|
+
this._poolInstance(this._instances[i]);
|
|
1213
|
+
}
|
|
1214
|
+
this._instances.length = 0;
|
|
1215
|
+
}
|
|
1216
|
+
_onComplete(instance) {
|
|
1217
|
+
if (this._instances) {
|
|
1218
|
+
const index = this._instances.indexOf(instance);
|
|
1219
|
+
if (index > -1) {
|
|
1220
|
+
this._instances.splice(index, 1);
|
|
1221
|
+
}
|
|
1222
|
+
this.isPlaying = this._instances.length > 0;
|
|
1223
|
+
}
|
|
1224
|
+
this._poolInstance(instance);
|
|
1225
|
+
}
|
|
1226
|
+
_createInstance() {
|
|
1227
|
+
if (_Sound._pool.length > 0) {
|
|
1228
|
+
const instance = _Sound._pool.pop();
|
|
1229
|
+
instance.init(this.media);
|
|
1230
|
+
return instance;
|
|
1231
|
+
}
|
|
1232
|
+
return this.media.create();
|
|
1233
|
+
}
|
|
1234
|
+
_poolInstance(instance) {
|
|
1235
|
+
instance.destroy();
|
|
1236
|
+
if (_Sound._pool.indexOf(instance) < 0) {
|
|
1237
|
+
_Sound._pool.push(instance);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
let Sound$2 = _Sound;
|
|
1242
|
+
Sound$2._pool = [];
|
|
1243
|
+
class WebAudioContext extends Filterable {
|
|
1244
|
+
constructor() {
|
|
1245
|
+
const win = window;
|
|
1246
|
+
const ctx = new WebAudioContext.AudioContext();
|
|
1247
|
+
const compressor = ctx.createDynamicsCompressor();
|
|
1248
|
+
const analyser = ctx.createAnalyser();
|
|
1249
|
+
analyser.connect(compressor);
|
|
1250
|
+
compressor.connect(ctx.destination);
|
|
1251
|
+
super(analyser, compressor);
|
|
1252
|
+
this.autoPause = true;
|
|
1253
|
+
this._ctx = ctx;
|
|
1254
|
+
this._offlineCtx = new WebAudioContext.OfflineAudioContext(1, 2, win.OfflineAudioContext ? Math.max(8e3, Math.min(96e3, ctx.sampleRate)) : 44100);
|
|
1255
|
+
this.compressor = compressor;
|
|
1256
|
+
this.analyser = analyser;
|
|
1257
|
+
this.events = new pixi_js.EventEmitter();
|
|
1258
|
+
this.volume = 1;
|
|
1259
|
+
this.speed = 1;
|
|
1260
|
+
this.muted = false;
|
|
1261
|
+
this.paused = false;
|
|
1262
|
+
this._locked = ctx.state === "suspended" && ("ontouchstart" in globalThis || "onclick" in globalThis);
|
|
1263
|
+
if (this._locked) {
|
|
1264
|
+
this._unlock();
|
|
1265
|
+
this._unlock = this._unlock.bind(this);
|
|
1266
|
+
document.addEventListener("mousedown", this._unlock, true);
|
|
1267
|
+
document.addEventListener("touchstart", this._unlock, true);
|
|
1268
|
+
document.addEventListener("touchend", this._unlock, true);
|
|
1269
|
+
}
|
|
1270
|
+
this.onFocus = this.onFocus.bind(this);
|
|
1271
|
+
this.onBlur = this.onBlur.bind(this);
|
|
1272
|
+
globalThis.addEventListener("focus", this.onFocus);
|
|
1273
|
+
globalThis.addEventListener("blur", this.onBlur);
|
|
1274
|
+
}
|
|
1275
|
+
onFocus() {
|
|
1276
|
+
if (!this.autoPause) {
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
const state = this._ctx.state;
|
|
1280
|
+
if (state === "suspended" || state === "interrupted" || !this._locked) {
|
|
1281
|
+
this.paused = this._pausedOnBlur;
|
|
1282
|
+
this.refreshPaused();
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
onBlur() {
|
|
1286
|
+
if (!this.autoPause) {
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (!this._locked) {
|
|
1290
|
+
this._pausedOnBlur = this._paused;
|
|
1291
|
+
this.paused = true;
|
|
1292
|
+
this.refreshPaused();
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
_unlock() {
|
|
1296
|
+
if (!this._locked) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
this.playEmptySound();
|
|
1300
|
+
if (this._ctx.state === "running") {
|
|
1301
|
+
document.removeEventListener("mousedown", this._unlock, true);
|
|
1302
|
+
document.removeEventListener("touchend", this._unlock, true);
|
|
1303
|
+
document.removeEventListener("touchstart", this._unlock, true);
|
|
1304
|
+
this._locked = false;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
playEmptySound() {
|
|
1308
|
+
const source = this._ctx.createBufferSource();
|
|
1309
|
+
source.buffer = this._ctx.createBuffer(1, 1, 22050);
|
|
1310
|
+
source.connect(this._ctx.destination);
|
|
1311
|
+
source.start(0, 0, 0);
|
|
1312
|
+
if (source.context.state === "suspended") {
|
|
1313
|
+
source.context.resume();
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
static get AudioContext() {
|
|
1317
|
+
const win = window;
|
|
1318
|
+
return win.AudioContext || win.webkitAudioContext || null;
|
|
1319
|
+
}
|
|
1320
|
+
static get OfflineAudioContext() {
|
|
1321
|
+
const win = window;
|
|
1322
|
+
return win.OfflineAudioContext || win.webkitOfflineAudioContext || null;
|
|
1323
|
+
}
|
|
1324
|
+
destroy() {
|
|
1325
|
+
super.destroy();
|
|
1326
|
+
const ctx = this._ctx;
|
|
1327
|
+
if (typeof ctx.close !== "undefined") {
|
|
1328
|
+
ctx.close();
|
|
1329
|
+
}
|
|
1330
|
+
globalThis.removeEventListener("focus", this.onFocus);
|
|
1331
|
+
globalThis.removeEventListener("blur", this.onBlur);
|
|
1332
|
+
this.events.removeAllListeners();
|
|
1333
|
+
this.analyser.disconnect();
|
|
1334
|
+
this.compressor.disconnect();
|
|
1335
|
+
this.analyser = null;
|
|
1336
|
+
this.compressor = null;
|
|
1337
|
+
this.events = null;
|
|
1338
|
+
this._offlineCtx = null;
|
|
1339
|
+
this._ctx = null;
|
|
1340
|
+
}
|
|
1341
|
+
get audioContext() {
|
|
1342
|
+
return this._ctx;
|
|
1343
|
+
}
|
|
1344
|
+
get offlineContext() {
|
|
1345
|
+
return this._offlineCtx;
|
|
1346
|
+
}
|
|
1347
|
+
set paused(paused) {
|
|
1348
|
+
if (paused && this._ctx.state === "running") {
|
|
1349
|
+
this._ctx.suspend();
|
|
1350
|
+
} else if (!paused && this._ctx.state === "suspended") {
|
|
1351
|
+
this._ctx.resume();
|
|
1352
|
+
}
|
|
1353
|
+
this._paused = paused;
|
|
1354
|
+
}
|
|
1355
|
+
get paused() {
|
|
1356
|
+
return this._paused;
|
|
1357
|
+
}
|
|
1358
|
+
refresh() {
|
|
1359
|
+
this.events.emit("refresh");
|
|
1360
|
+
}
|
|
1361
|
+
refreshPaused() {
|
|
1362
|
+
this.events.emit("refreshPaused");
|
|
1363
|
+
}
|
|
1364
|
+
toggleMute() {
|
|
1365
|
+
this.muted = !this.muted;
|
|
1366
|
+
this.refresh();
|
|
1367
|
+
return this.muted;
|
|
1368
|
+
}
|
|
1369
|
+
togglePause() {
|
|
1370
|
+
this.paused = !this.paused;
|
|
1371
|
+
this.refreshPaused();
|
|
1372
|
+
return this._paused;
|
|
1373
|
+
}
|
|
1374
|
+
decode(arrayBuffer, callback) {
|
|
1375
|
+
const handleError = err => {
|
|
1376
|
+
callback(new Error((err === null || err === void 0 ? void 0 : err.message) || "Unable to decode file"));
|
|
1377
|
+
};
|
|
1378
|
+
const result = this._offlineCtx.decodeAudioData(arrayBuffer, buffer => {
|
|
1379
|
+
callback(null, buffer);
|
|
1380
|
+
}, handleError);
|
|
1381
|
+
if (result) {
|
|
1382
|
+
result.catch(handleError);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
class SoundLibrary {
|
|
1387
|
+
constructor() {
|
|
1388
|
+
this.init();
|
|
1389
|
+
}
|
|
1390
|
+
init() {
|
|
1391
|
+
if (this.supported) {
|
|
1392
|
+
this._webAudioContext = new WebAudioContext();
|
|
1393
|
+
}
|
|
1394
|
+
this._htmlAudioContext = new HTMLAudioContext();
|
|
1395
|
+
this._sounds = {};
|
|
1396
|
+
this.useLegacy = !this.supported;
|
|
1397
|
+
return this;
|
|
1398
|
+
}
|
|
1399
|
+
get context() {
|
|
1400
|
+
return this._context;
|
|
1401
|
+
}
|
|
1402
|
+
get filtersAll() {
|
|
1403
|
+
if (!this.useLegacy) {
|
|
1404
|
+
return this._context.filters;
|
|
1405
|
+
}
|
|
1406
|
+
return [];
|
|
1407
|
+
}
|
|
1408
|
+
set filtersAll(filtersAll) {
|
|
1409
|
+
if (!this.useLegacy) {
|
|
1410
|
+
this._context.filters = filtersAll;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
get supported() {
|
|
1414
|
+
return WebAudioContext.AudioContext !== null;
|
|
1415
|
+
}
|
|
1416
|
+
add(source, sourceOptions) {
|
|
1417
|
+
if (typeof source === "object") {
|
|
1418
|
+
const results = {};
|
|
1419
|
+
for (const alias in source) {
|
|
1420
|
+
const options2 = this._getOptions(source[alias], sourceOptions);
|
|
1421
|
+
results[alias] = this.add(alias, options2);
|
|
248
1422
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
1423
|
+
return results;
|
|
1424
|
+
}
|
|
1425
|
+
console.assert(!this._sounds[source], `Sound with alias ${source} already exists.`);
|
|
1426
|
+
if (sourceOptions instanceof Sound$2) {
|
|
1427
|
+
this._sounds[source] = sourceOptions;
|
|
1428
|
+
return sourceOptions;
|
|
1429
|
+
}
|
|
1430
|
+
const options = this._getOptions(sourceOptions);
|
|
1431
|
+
const sound = Sound$2.from(options);
|
|
1432
|
+
this._sounds[source] = sound;
|
|
1433
|
+
return sound;
|
|
1434
|
+
}
|
|
1435
|
+
_getOptions(source, overrides) {
|
|
1436
|
+
let options;
|
|
1437
|
+
if (typeof source === "string") {
|
|
1438
|
+
options = {
|
|
1439
|
+
url: source
|
|
252
1440
|
};
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
1441
|
+
} else if (Array.isArray(source)) {
|
|
1442
|
+
options = {
|
|
1443
|
+
url: source
|
|
1444
|
+
};
|
|
1445
|
+
} else if (source instanceof ArrayBuffer || source instanceof AudioBuffer || source instanceof HTMLAudioElement) {
|
|
1446
|
+
options = {
|
|
1447
|
+
source
|
|
1448
|
+
};
|
|
1449
|
+
} else {
|
|
1450
|
+
options = source;
|
|
1451
|
+
}
|
|
1452
|
+
options = _objectSpread(_objectSpread({}, options), overrides || {});
|
|
1453
|
+
return options;
|
|
1454
|
+
}
|
|
1455
|
+
get useLegacy() {
|
|
1456
|
+
return this._useLegacy;
|
|
1457
|
+
}
|
|
1458
|
+
set useLegacy(legacy) {
|
|
1459
|
+
this._useLegacy = legacy;
|
|
1460
|
+
this._context = !legacy && this.supported ? this._webAudioContext : this._htmlAudioContext;
|
|
1461
|
+
}
|
|
1462
|
+
get disableAutoPause() {
|
|
1463
|
+
return !this._webAudioContext.autoPause;
|
|
1464
|
+
}
|
|
1465
|
+
set disableAutoPause(autoPause) {
|
|
1466
|
+
this._webAudioContext.autoPause = !autoPause;
|
|
1467
|
+
}
|
|
1468
|
+
remove(alias) {
|
|
1469
|
+
this.exists(alias, true);
|
|
1470
|
+
this._sounds[alias].destroy();
|
|
1471
|
+
delete this._sounds[alias];
|
|
1472
|
+
return this;
|
|
1473
|
+
}
|
|
1474
|
+
get volumeAll() {
|
|
1475
|
+
return this._context.volume;
|
|
1476
|
+
}
|
|
1477
|
+
set volumeAll(volume) {
|
|
1478
|
+
this._context.volume = volume;
|
|
1479
|
+
this._context.refresh();
|
|
1480
|
+
}
|
|
1481
|
+
get speedAll() {
|
|
1482
|
+
return this._context.speed;
|
|
1483
|
+
}
|
|
1484
|
+
set speedAll(speed) {
|
|
1485
|
+
this._context.speed = speed;
|
|
1486
|
+
this._context.refresh();
|
|
1487
|
+
}
|
|
1488
|
+
togglePauseAll() {
|
|
1489
|
+
return this._context.togglePause();
|
|
1490
|
+
}
|
|
1491
|
+
pauseAll() {
|
|
1492
|
+
this._context.paused = true;
|
|
1493
|
+
this._context.refreshPaused();
|
|
1494
|
+
return this;
|
|
1495
|
+
}
|
|
1496
|
+
resumeAll() {
|
|
1497
|
+
this._context.paused = false;
|
|
1498
|
+
this._context.refreshPaused();
|
|
1499
|
+
return this;
|
|
1500
|
+
}
|
|
1501
|
+
toggleMuteAll() {
|
|
1502
|
+
return this._context.toggleMute();
|
|
1503
|
+
}
|
|
1504
|
+
muteAll() {
|
|
1505
|
+
this._context.muted = true;
|
|
1506
|
+
this._context.refresh();
|
|
1507
|
+
return this;
|
|
1508
|
+
}
|
|
1509
|
+
unmuteAll() {
|
|
1510
|
+
this._context.muted = false;
|
|
1511
|
+
this._context.refresh();
|
|
1512
|
+
return this;
|
|
1513
|
+
}
|
|
1514
|
+
removeAll() {
|
|
1515
|
+
for (const alias in this._sounds) {
|
|
1516
|
+
this._sounds[alias].destroy();
|
|
1517
|
+
delete this._sounds[alias];
|
|
1518
|
+
}
|
|
1519
|
+
return this;
|
|
1520
|
+
}
|
|
1521
|
+
stopAll() {
|
|
1522
|
+
for (const alias in this._sounds) {
|
|
1523
|
+
this._sounds[alias].stop();
|
|
1524
|
+
}
|
|
1525
|
+
return this;
|
|
1526
|
+
}
|
|
1527
|
+
exists(alias, assert = false) {
|
|
1528
|
+
const exists = !!this._sounds[alias];
|
|
1529
|
+
if (assert) {
|
|
1530
|
+
console.assert(exists, `No sound matching alias '${alias}'.`);
|
|
1531
|
+
}
|
|
1532
|
+
return exists;
|
|
1533
|
+
}
|
|
1534
|
+
isPlaying() {
|
|
1535
|
+
for (const alias in this._sounds) {
|
|
1536
|
+
if (this._sounds[alias].isPlaying) {
|
|
1537
|
+
return true;
|
|
258
1538
|
}
|
|
259
1539
|
}
|
|
260
|
-
|
|
261
|
-
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
find(alias) {
|
|
1543
|
+
this.exists(alias, true);
|
|
1544
|
+
return this._sounds[alias];
|
|
1545
|
+
}
|
|
1546
|
+
play(alias, options) {
|
|
1547
|
+
return this.find(alias).play(options);
|
|
1548
|
+
}
|
|
1549
|
+
stop(alias) {
|
|
1550
|
+
return this.find(alias).stop();
|
|
1551
|
+
}
|
|
1552
|
+
pause(alias) {
|
|
1553
|
+
return this.find(alias).pause();
|
|
1554
|
+
}
|
|
1555
|
+
resume(alias) {
|
|
1556
|
+
return this.find(alias).resume();
|
|
1557
|
+
}
|
|
1558
|
+
volume(alias, volume) {
|
|
1559
|
+
const sound = this.find(alias);
|
|
1560
|
+
if (volume !== void 0) {
|
|
1561
|
+
sound.volume = volume;
|
|
1562
|
+
}
|
|
1563
|
+
return sound.volume;
|
|
1564
|
+
}
|
|
1565
|
+
speed(alias, speed) {
|
|
1566
|
+
const sound = this.find(alias);
|
|
1567
|
+
if (speed !== void 0) {
|
|
1568
|
+
sound.speed = speed;
|
|
1569
|
+
}
|
|
1570
|
+
return sound.speed;
|
|
1571
|
+
}
|
|
1572
|
+
duration(alias) {
|
|
1573
|
+
return this.find(alias).duration;
|
|
1574
|
+
}
|
|
1575
|
+
close() {
|
|
1576
|
+
this.removeAll();
|
|
1577
|
+
this._sounds = null;
|
|
1578
|
+
if (this._webAudioContext) {
|
|
1579
|
+
this._webAudioContext.destroy();
|
|
1580
|
+
this._webAudioContext = null;
|
|
1581
|
+
}
|
|
1582
|
+
if (this._htmlAudioContext) {
|
|
1583
|
+
this._htmlAudioContext.destroy();
|
|
1584
|
+
this._htmlAudioContext = null;
|
|
1585
|
+
}
|
|
1586
|
+
this._context = null;
|
|
1587
|
+
return this;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
const getAlias = asset => {
|
|
1591
|
+
var _asset$alias;
|
|
1592
|
+
const src = asset.src;
|
|
1593
|
+
let alias = asset === null || asset === void 0 ? void 0 : (_asset$alias = asset.alias) === null || _asset$alias === void 0 ? void 0 : _asset$alias[0];
|
|
1594
|
+
if (!alias || asset.src === alias) {
|
|
1595
|
+
alias = pixi_js.path.basename(src, pixi_js.path.extname(src));
|
|
1596
|
+
}
|
|
1597
|
+
return alias;
|
|
1598
|
+
};
|
|
1599
|
+
const soundAsset = {
|
|
1600
|
+
extension: pixi_js.ExtensionType.Asset,
|
|
1601
|
+
detection: {
|
|
1602
|
+
test: async () => true,
|
|
1603
|
+
add: async formats => [...formats, ...extensions.filter(ext => supported[ext])],
|
|
1604
|
+
remove: async formats => formats.filter(ext => formats.includes(ext))
|
|
1605
|
+
},
|
|
1606
|
+
loader: {
|
|
1607
|
+
name: "sound",
|
|
1608
|
+
extension: {
|
|
1609
|
+
type: [pixi_js.ExtensionType.LoadParser],
|
|
1610
|
+
priority: pixi_js.LoaderParserPriority.High
|
|
1611
|
+
},
|
|
1612
|
+
test(url) {
|
|
1613
|
+
const ext = pixi_js.path.extname(url).slice(1);
|
|
1614
|
+
return !!supported[ext] || mimes.some(mime => url.startsWith(`data:${mime}`));
|
|
1615
|
+
},
|
|
1616
|
+
async load(url, asset) {
|
|
1617
|
+
const sound = await new Promise((resolve, reject) => Sound$2.from(_objectSpread(_objectSpread({}, asset.data), {}, {
|
|
1618
|
+
url,
|
|
1619
|
+
preload: true,
|
|
1620
|
+
loaded(err, sound2) {
|
|
1621
|
+
var _asset$data, _asset$data$loaded;
|
|
1622
|
+
if (err) {
|
|
1623
|
+
reject(err);
|
|
1624
|
+
} else {
|
|
1625
|
+
resolve(sound2);
|
|
1626
|
+
}
|
|
1627
|
+
(_asset$data = asset.data) === null || _asset$data === void 0 ? void 0 : (_asset$data$loaded = _asset$data.loaded) === null || _asset$data$loaded === void 0 ? void 0 : _asset$data$loaded.call(_asset$data, err, sound2);
|
|
1628
|
+
}
|
|
1629
|
+
})));
|
|
1630
|
+
getInstance().add(getAlias(asset), sound);
|
|
1631
|
+
return sound;
|
|
1632
|
+
},
|
|
1633
|
+
async unload(_sound, asset) {
|
|
1634
|
+
getInstance().remove(getAlias(asset));
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
pixi_js.extensions.add(soundAsset);
|
|
1639
|
+
const sound = setInstance(new SoundLibrary());
|
|
1640
|
+
pixi_js.extensions.add(soundAsset);
|
|
1641
|
+
let SoundSystem = class SoundSystem extends eva_js.System {
|
|
1642
|
+
constructor(obj) {
|
|
1643
|
+
super();
|
|
1644
|
+
this.autoPauseAndStart = true;
|
|
1645
|
+
this.components = [];
|
|
1646
|
+
this.audioBufferCache = {};
|
|
1647
|
+
_extends(this, obj);
|
|
1648
|
+
}
|
|
1649
|
+
resumeAll() {
|
|
1650
|
+
sound.resumeAll();
|
|
1651
|
+
}
|
|
1652
|
+
pauseAll() {
|
|
1653
|
+
sound.pauseAll();
|
|
1654
|
+
}
|
|
1655
|
+
stopAll() {
|
|
1656
|
+
sound.stopAll();
|
|
1657
|
+
}
|
|
1658
|
+
update() {
|
|
1659
|
+
const changes = this.componentObserver.clear();
|
|
1660
|
+
for (const changed of changes) {
|
|
1661
|
+
this.componentChanged(changed);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
onResume() {
|
|
262
1665
|
if (!this.autoPauseAndStart) {
|
|
263
1666
|
return;
|
|
264
1667
|
}
|
|
265
1668
|
this.resumeAll();
|
|
266
|
-
}
|
|
267
|
-
|
|
1669
|
+
}
|
|
1670
|
+
onPause() {
|
|
268
1671
|
if (!this.autoPauseAndStart) {
|
|
269
1672
|
return;
|
|
270
1673
|
}
|
|
271
1674
|
this.pauseAll();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
this.components.forEach(
|
|
1675
|
+
}
|
|
1676
|
+
onDestroy() {
|
|
1677
|
+
this.components.forEach(component => {
|
|
275
1678
|
component.onDestroy();
|
|
276
1679
|
});
|
|
277
1680
|
this.components = [];
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
SoundSystem.prototype.componentChanged = function (changed) {
|
|
286
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
287
|
-
return __generator(this, function (_a) {
|
|
288
|
-
if (changed.componentName !== 'Sound') return [2];
|
|
289
|
-
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
290
|
-
this.add(changed);
|
|
291
|
-
}
|
|
292
|
-
return [2];
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
SoundSystem.prototype.setupAudioContext = function () {
|
|
297
|
-
try {
|
|
298
|
-
var AudioContext_1 = window.AudioContext || window.webkitAudioContext;
|
|
299
|
-
this.ctx = new AudioContext_1();
|
|
300
|
-
} catch (error) {
|
|
301
|
-
console.error(error);
|
|
302
|
-
if (this.onError) {
|
|
303
|
-
this.onError(error);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (!this.ctx) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
this.gainNode = typeof this.ctx.createGain === 'undefined' ? this.ctx.createGainNode() : this.ctx.createGain();
|
|
310
|
-
this.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime);
|
|
311
|
-
this.gainNode.connect(this.ctx.destination);
|
|
312
|
-
this.unlockAudio();
|
|
313
|
-
};
|
|
314
|
-
SoundSystem.prototype.unlockAudio = function () {
|
|
315
|
-
var _this = this;
|
|
316
|
-
if (!this.ctx || !this.audioLocked) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
var unlock = function () {
|
|
320
|
-
if (_this.ctx) {
|
|
321
|
-
var removeListenerFn = function () {
|
|
322
|
-
document.body.removeEventListener('touchstart', unlock);
|
|
323
|
-
document.body.removeEventListener('touchend', unlock);
|
|
324
|
-
document.body.removeEventListener('click', unlock);
|
|
325
|
-
};
|
|
326
|
-
_this.ctx.resume().then(removeListenerFn, removeListenerFn);
|
|
1681
|
+
sound.removeAll();
|
|
1682
|
+
}
|
|
1683
|
+
componentChanged(changed) {
|
|
1684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1685
|
+
if (changed.componentName !== 'Sound') return;
|
|
1686
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
1687
|
+
this.add(changed);
|
|
327
1688
|
}
|
|
328
|
-
};
|
|
329
|
-
document.body.addEventListener('touchstart', unlock);
|
|
330
|
-
document.body.addEventListener('touchend', unlock);
|
|
331
|
-
document.body.addEventListener('click', unlock);
|
|
332
|
-
};
|
|
333
|
-
SoundSystem.prototype.add = function (changed) {
|
|
334
|
-
var _a;
|
|
335
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
-
var component, config, audio, _b, _c, error_1;
|
|
337
|
-
return __generator(this, function (_d) {
|
|
338
|
-
switch (_d.label) {
|
|
339
|
-
case 0:
|
|
340
|
-
component = changed.component;
|
|
341
|
-
this.components.push(component);
|
|
342
|
-
_d.label = 1;
|
|
343
|
-
case 1:
|
|
344
|
-
_d.trys.push([1, 5,, 6]);
|
|
345
|
-
config = component.config;
|
|
346
|
-
component.state = 'loading';
|
|
347
|
-
return [4, eva_js.resource.getResource(config.resource)];
|
|
348
|
-
case 2:
|
|
349
|
-
audio = _d.sent();
|
|
350
|
-
if (!(!this.audioBufferCache[audio.name] && ((_a = audio === null || audio === void 0 ? void 0 : audio.data) === null || _a === void 0 ? void 0 : _a.audio))) return [3, 4];
|
|
351
|
-
_b = this.audioBufferCache;
|
|
352
|
-
_c = audio.name;
|
|
353
|
-
return [4, this.decodeAudioData(audio.data.audio, audio.name)];
|
|
354
|
-
case 3:
|
|
355
|
-
_b[_c] = _d.sent();
|
|
356
|
-
_d.label = 4;
|
|
357
|
-
case 4:
|
|
358
|
-
if (this.audioBufferCache[audio.name]) {
|
|
359
|
-
component.systemContext = this.ctx;
|
|
360
|
-
component.systemDestination = this.gainNode;
|
|
361
|
-
component.onload(this.audioBufferCache[audio.name]);
|
|
362
|
-
}
|
|
363
|
-
return [3, 6];
|
|
364
|
-
case 5:
|
|
365
|
-
error_1 = _d.sent();
|
|
366
|
-
if (this.onError) {
|
|
367
|
-
this.onError(error_1);
|
|
368
|
-
}
|
|
369
|
-
return [3, 6];
|
|
370
|
-
case 6:
|
|
371
|
-
return [2];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
1689
|
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
1690
|
+
}
|
|
1691
|
+
add(changed) {
|
|
1692
|
+
var _a, _b;
|
|
1693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1694
|
+
const component = changed.component;
|
|
1695
|
+
this.components.push(component);
|
|
1696
|
+
try {
|
|
1697
|
+
const {
|
|
1698
|
+
config
|
|
1699
|
+
} = component;
|
|
1700
|
+
component.state = 'loading';
|
|
1701
|
+
const audio = yield eva_js.resource.getResource(config.resource);
|
|
1702
|
+
if (!this.audioBufferCache[audio.name] && ((_a = audio === null || audio === void 0 ? void 0 : audio.data) === null || _a === void 0 ? void 0 : _a.audio)) {
|
|
1703
|
+
this.audioBufferCache[audio.name] = (_b = audio === null || audio === void 0 ? void 0 : audio.data) === null || _b === void 0 ? void 0 : _b.audio;
|
|
388
1704
|
}
|
|
389
|
-
if (
|
|
390
|
-
|
|
391
|
-
} else {
|
|
392
|
-
reject(new Error("Error decoding audio " + name));
|
|
1705
|
+
if (this.audioBufferCache[audio.name]) {
|
|
1706
|
+
component.onload(this.audioBufferCache[audio.name]);
|
|
393
1707
|
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
delete _this.decodeAudioPromiseMap[name];
|
|
1708
|
+
} catch (error) {
|
|
1709
|
+
if (this.onError) {
|
|
1710
|
+
this.onError(error);
|
|
398
1711
|
}
|
|
399
|
-
reject(new Error(err + ". arrayBuffer byteLength: " + (arraybuffer ? arraybuffer.byteLength : 0)));
|
|
400
|
-
};
|
|
401
|
-
var promise = _this.ctx.decodeAudioData(arraybuffer, success, error);
|
|
402
|
-
if (promise instanceof Promise) {
|
|
403
|
-
promise.catch(function (err) {
|
|
404
|
-
reject(new Error("catch " + err + ", arrayBuffer byteLength: " + (arraybuffer ? arraybuffer.byteLength : 0)));
|
|
405
|
-
});
|
|
406
1712
|
}
|
|
407
1713
|
});
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
})], SoundSystem);
|
|
415
|
-
return SoundSystem;
|
|
416
|
-
}(eva_js.System);
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
SoundSystem.systemName = 'SoundSystem';
|
|
1717
|
+
SoundSystem = __decorate([eva_js.decorators.componentObserver({
|
|
1718
|
+
Sound: []
|
|
1719
|
+
})], SoundSystem);
|
|
417
1720
|
var SoundSystem$1 = SoundSystem;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
_this.config = {
|
|
1721
|
+
class Sound extends eva_js.Component {
|
|
1722
|
+
constructor() {
|
|
1723
|
+
super(...arguments);
|
|
1724
|
+
this.state = 'unloaded';
|
|
1725
|
+
this.config = {
|
|
424
1726
|
resource: '',
|
|
425
1727
|
autoplay: false,
|
|
426
1728
|
muted: false,
|
|
427
1729
|
volume: 1,
|
|
428
1730
|
loop: false,
|
|
429
|
-
seek: 0
|
|
1731
|
+
seek: 0,
|
|
1732
|
+
speed: 1
|
|
430
1733
|
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
this.config.volume = v;
|
|
459
|
-
if (!this.gainNode) {
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
this.gainNode.gain.setValueAtTime(v, 0);
|
|
463
|
-
},
|
|
464
|
-
enumerable: false,
|
|
465
|
-
configurable: true
|
|
466
|
-
});
|
|
467
|
-
Sound.prototype.init = function (obj) {
|
|
1734
|
+
this.actionQueue = [];
|
|
1735
|
+
this.startTime = 0;
|
|
1736
|
+
}
|
|
1737
|
+
get systemContext() {
|
|
1738
|
+
return sound.context;
|
|
1739
|
+
}
|
|
1740
|
+
get playing() {
|
|
1741
|
+
if (!this.buffer) return false;
|
|
1742
|
+
return this.buffer.isPlaying;
|
|
1743
|
+
}
|
|
1744
|
+
get muted() {
|
|
1745
|
+
var _a;
|
|
1746
|
+
return ((_a = this.buffer) === null || _a === void 0 ? void 0 : _a.muted) || false;
|
|
1747
|
+
}
|
|
1748
|
+
set muted(v) {
|
|
1749
|
+
if (this.buffer) this.buffer.muted = v;
|
|
1750
|
+
}
|
|
1751
|
+
get volume() {
|
|
1752
|
+
var _a;
|
|
1753
|
+
return ((_a = this.buffer) === null || _a === void 0 ? void 0 : _a.volume) || 0;
|
|
1754
|
+
}
|
|
1755
|
+
set volume(v) {
|
|
1756
|
+
if (this.buffer) this.buffer.volume = v;
|
|
1757
|
+
}
|
|
1758
|
+
init(obj) {
|
|
468
1759
|
if (!obj) {
|
|
469
1760
|
return;
|
|
470
1761
|
}
|
|
@@ -472,112 +1763,47 @@ var _EVA_IIFE_sound = function (exports, eva_js) {
|
|
|
472
1763
|
if (this.config.autoplay) {
|
|
473
1764
|
this.actionQueue.push(this.play.bind(this));
|
|
474
1765
|
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
var _this = this;
|
|
1766
|
+
}
|
|
1767
|
+
play() {
|
|
478
1768
|
if (this.state !== 'loaded') {
|
|
479
1769
|
this.actionQueue.push(this.play.bind(this));
|
|
480
1770
|
}
|
|
481
|
-
this.
|
|
482
|
-
this.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
this.
|
|
495
|
-
this.
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
if (_this.config.onEnd) {
|
|
500
|
-
_this.config.onEnd();
|
|
501
|
-
}
|
|
502
|
-
if (_this.playing) {
|
|
503
|
-
_this.destroySource();
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
this.sourceNode.addEventListener('ended', this.endedListener);
|
|
507
|
-
};
|
|
508
|
-
Sound.prototype.pause = function () {
|
|
509
|
-
if (this.state !== 'loaded') {
|
|
510
|
-
this.actionQueue.push(this.pause.bind(this));
|
|
511
|
-
}
|
|
512
|
-
if (this.paused || !this.playing) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
this.paused = true;
|
|
516
|
-
this.playing = false;
|
|
517
|
-
this.config.seek = this.getCurrentTime();
|
|
518
|
-
this.destroySource();
|
|
519
|
-
};
|
|
520
|
-
Sound.prototype.stop = function () {
|
|
521
|
-
if (this.state !== 'loaded') {
|
|
522
|
-
this.actionQueue.push(this.stop.bind(this));
|
|
523
|
-
}
|
|
524
|
-
if (!this.paused && !this.playing) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
this.playing = false;
|
|
528
|
-
this.paused = false;
|
|
529
|
-
this.destroySource();
|
|
530
|
-
this.resetConfig();
|
|
531
|
-
};
|
|
532
|
-
Sound.prototype.onload = function (buffer) {
|
|
1771
|
+
if (!this.buffer) return;
|
|
1772
|
+
this.startTime = this.systemContext.currentTime;
|
|
1773
|
+
this.buffer.play();
|
|
1774
|
+
}
|
|
1775
|
+
resume() {
|
|
1776
|
+
if (!this.buffer) return;
|
|
1777
|
+
this.buffer.resume();
|
|
1778
|
+
}
|
|
1779
|
+
pause() {
|
|
1780
|
+
if (!this.buffer) return;
|
|
1781
|
+
this.buffer.pause();
|
|
1782
|
+
}
|
|
1783
|
+
stop() {
|
|
1784
|
+
if (!this.buffer) return;
|
|
1785
|
+
this.buffer.stop();
|
|
1786
|
+
}
|
|
1787
|
+
onload(buffer) {
|
|
533
1788
|
this.state = 'loaded';
|
|
534
1789
|
this.buffer = buffer;
|
|
535
|
-
this.
|
|
536
|
-
this.
|
|
537
|
-
|
|
538
|
-
|
|
1790
|
+
this.buffer.muted = this.config.muted;
|
|
1791
|
+
this.buffer.volume = this.config.volume;
|
|
1792
|
+
this.buffer.loop = this.config.loop;
|
|
1793
|
+
this.buffer.speed = this.config.speed;
|
|
1794
|
+
this.actionQueue.forEach(action => action());
|
|
539
1795
|
this.actionQueue.length = 0;
|
|
540
|
-
}
|
|
541
|
-
|
|
1796
|
+
}
|
|
1797
|
+
onDestroy() {
|
|
542
1798
|
this.actionQueue.length = 0;
|
|
543
|
-
this.destroySource();
|
|
544
|
-
};
|
|
545
|
-
Sound.prototype.resetConfig = function () {
|
|
546
|
-
this.config.seek = 0;
|
|
547
|
-
};
|
|
548
|
-
Sound.prototype.getCurrentTime = function () {
|
|
549
|
-
if (this.config.loop && this.duration > 0) {
|
|
550
|
-
return (this.systemContext.currentTime - this.playTime) % this.duration;
|
|
551
|
-
}
|
|
552
|
-
return this.systemContext.currentTime - this.playTime;
|
|
553
|
-
};
|
|
554
|
-
Sound.prototype.createSource = function () {
|
|
555
|
-
if (!this.systemContext || this.state !== 'loaded') {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
this.sourceNode = this.systemContext.createBufferSource();
|
|
559
|
-
this.sourceNode.buffer = this.buffer;
|
|
560
|
-
this.sourceNode.loop = this.config.loop;
|
|
561
|
-
if (!this.gainNode) {
|
|
562
|
-
this.gainNode = this.systemContext.createGain();
|
|
563
|
-
this.gainNode.connect(this.systemDestination);
|
|
564
|
-
_extends(this, this.config);
|
|
565
|
-
}
|
|
566
|
-
this.sourceNode.connect(this.gainNode);
|
|
567
|
-
};
|
|
568
|
-
Sound.prototype.destroySource = function () {
|
|
569
|
-
if (!this.sourceNode) return;
|
|
570
|
-
this.sourceNode.removeEventListener('ended', this.endedListener);
|
|
571
|
-
this.sourceNode.stop();
|
|
572
|
-
this.sourceNode.disconnect();
|
|
573
|
-
this.sourceNode = null;
|
|
574
1799
|
this.startTime = 0;
|
|
575
|
-
this.
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
1800
|
+
if (this.buffer) {
|
|
1801
|
+
this.buffer.destroy();
|
|
1802
|
+
this.buffer = null;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
Sound.componentName = 'Sound';
|
|
581
1807
|
var Sound$1 = Sound;
|
|
582
1808
|
exports.Sound = Sound$1;
|
|
583
1809
|
exports.SoundSystem = SoundSystem$1;
|
|
@@ -585,5 +1811,5 @@ var _EVA_IIFE_sound = function (exports, eva_js) {
|
|
|
585
1811
|
value: true
|
|
586
1812
|
});
|
|
587
1813
|
return exports;
|
|
588
|
-
}({}, EVA);
|
|
1814
|
+
}({}, EVA, PIXI);
|
|
589
1815
|
window.EVA.plugin.sound = window.EVA.plugin.sound || _EVA_IIFE_sound;
|