@ddict/popup 1.0.11 → 1.0.13
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/popup.css +1 -1
- package/dist/popup.es.js +1219 -1257
- package/dist/popup.umd.js +9 -27
- package/package.json +1 -2
- package/dist/howler-DJIW9wc6.js +0 -1226
package/dist/howler-DJIW9wc6.js
DELETED
|
@@ -1,1226 +0,0 @@
|
|
|
1
|
-
function L(g, w) {
|
|
2
|
-
for (var r = 0; r < w.length; r++) {
|
|
3
|
-
const u = w[r];
|
|
4
|
-
if (typeof u != "string" && !Array.isArray(u)) {
|
|
5
|
-
for (const i in u)
|
|
6
|
-
if (i !== "default" && !(i in g)) {
|
|
7
|
-
const d = Object.getOwnPropertyDescriptor(u, i);
|
|
8
|
-
d && Object.defineProperty(g, i, d.get ? d : {
|
|
9
|
-
enumerable: !0,
|
|
10
|
-
get: () => u[i]
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return Object.freeze(Object.defineProperty(g, Symbol.toStringTag, { value: "Module" }));
|
|
16
|
-
}
|
|
17
|
-
var S = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
18
|
-
function D(g) {
|
|
19
|
-
return g && g.__esModule && Object.prototype.hasOwnProperty.call(g, "default") ? g.default : g;
|
|
20
|
-
}
|
|
21
|
-
var O = {};
|
|
22
|
-
/*!
|
|
23
|
-
* howler.js v2.2.4
|
|
24
|
-
* howlerjs.com
|
|
25
|
-
*
|
|
26
|
-
* (c) 2013-2020, James Simpson of GoldFire Studios
|
|
27
|
-
* goldfirestudios.com
|
|
28
|
-
*
|
|
29
|
-
* MIT License
|
|
30
|
-
*/
|
|
31
|
-
(function(g) {
|
|
32
|
-
(function() {
|
|
33
|
-
var w = function() {
|
|
34
|
-
this.init();
|
|
35
|
-
};
|
|
36
|
-
w.prototype = {
|
|
37
|
-
/**
|
|
38
|
-
* Initialize the global Howler object.
|
|
39
|
-
* @return {Howler}
|
|
40
|
-
*/
|
|
41
|
-
init: function() {
|
|
42
|
-
var e = this || r;
|
|
43
|
-
return e._counter = 1e3, e._html5AudioPool = [], e.html5PoolSize = 10, e._codecs = {}, e._howls = [], e._muted = !1, e._volume = 1, e._canPlayEvent = "canplaythrough", e._navigator = typeof window < "u" && window.navigator ? window.navigator : null, e.masterGain = null, e.noAudio = !1, e.usingWebAudio = !0, e.autoSuspend = !0, e.ctx = null, e.autoUnlock = !0, e._setup(), e;
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Get/set the global volume for all sounds.
|
|
47
|
-
* @param {Float} vol Volume from 0.0 to 1.0.
|
|
48
|
-
* @return {Howler/Float} Returns self or current volume.
|
|
49
|
-
*/
|
|
50
|
-
volume: function(e) {
|
|
51
|
-
var t = this || r;
|
|
52
|
-
if (e = parseFloat(e), t.ctx || A(), typeof e < "u" && e >= 0 && e <= 1) {
|
|
53
|
-
if (t._volume = e, t._muted)
|
|
54
|
-
return t;
|
|
55
|
-
t.usingWebAudio && t.masterGain.gain.setValueAtTime(e, r.ctx.currentTime);
|
|
56
|
-
for (var n = 0; n < t._howls.length; n++)
|
|
57
|
-
if (!t._howls[n]._webAudio)
|
|
58
|
-
for (var o = t._howls[n]._getSoundIds(), l = 0; l < o.length; l++) {
|
|
59
|
-
var _ = t._howls[n]._soundById(o[l]);
|
|
60
|
-
_ && _._node && (_._node.volume = _._volume * e);
|
|
61
|
-
}
|
|
62
|
-
return t;
|
|
63
|
-
}
|
|
64
|
-
return t._volume;
|
|
65
|
-
},
|
|
66
|
-
/**
|
|
67
|
-
* Handle muting and unmuting globally.
|
|
68
|
-
* @param {Boolean} muted Is muted or not.
|
|
69
|
-
*/
|
|
70
|
-
mute: function(e) {
|
|
71
|
-
var t = this || r;
|
|
72
|
-
t.ctx || A(), t._muted = e, t.usingWebAudio && t.masterGain.gain.setValueAtTime(e ? 0 : t._volume, r.ctx.currentTime);
|
|
73
|
-
for (var n = 0; n < t._howls.length; n++)
|
|
74
|
-
if (!t._howls[n]._webAudio)
|
|
75
|
-
for (var o = t._howls[n]._getSoundIds(), l = 0; l < o.length; l++) {
|
|
76
|
-
var _ = t._howls[n]._soundById(o[l]);
|
|
77
|
-
_ && _._node && (_._node.muted = e ? !0 : _._muted);
|
|
78
|
-
}
|
|
79
|
-
return t;
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* Handle stopping all sounds globally.
|
|
83
|
-
*/
|
|
84
|
-
stop: function() {
|
|
85
|
-
for (var e = this || r, t = 0; t < e._howls.length; t++)
|
|
86
|
-
e._howls[t].stop();
|
|
87
|
-
return e;
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Unload and destroy all currently loaded Howl objects.
|
|
91
|
-
* @return {Howler}
|
|
92
|
-
*/
|
|
93
|
-
unload: function() {
|
|
94
|
-
for (var e = this || r, t = e._howls.length - 1; t >= 0; t--)
|
|
95
|
-
e._howls[t].unload();
|
|
96
|
-
return e.usingWebAudio && e.ctx && typeof e.ctx.close < "u" && (e.ctx.close(), e.ctx = null, A()), e;
|
|
97
|
-
},
|
|
98
|
-
/**
|
|
99
|
-
* Check for codec support of specific extension.
|
|
100
|
-
* @param {String} ext Audio file extention.
|
|
101
|
-
* @return {Boolean}
|
|
102
|
-
*/
|
|
103
|
-
codecs: function(e) {
|
|
104
|
-
return (this || r)._codecs[e.replace(/^x-/, "")];
|
|
105
|
-
},
|
|
106
|
-
/**
|
|
107
|
-
* Setup various state values for global tracking.
|
|
108
|
-
* @return {Howler}
|
|
109
|
-
*/
|
|
110
|
-
_setup: function() {
|
|
111
|
-
var e = this || r;
|
|
112
|
-
if (e.state = e.ctx && e.ctx.state || "suspended", e._autoSuspend(), !e.usingWebAudio)
|
|
113
|
-
if (typeof Audio < "u")
|
|
114
|
-
try {
|
|
115
|
-
var t = new Audio();
|
|
116
|
-
typeof t.oncanplaythrough > "u" && (e._canPlayEvent = "canplay");
|
|
117
|
-
} catch {
|
|
118
|
-
e.noAudio = !0;
|
|
119
|
-
}
|
|
120
|
-
else
|
|
121
|
-
e.noAudio = !0;
|
|
122
|
-
try {
|
|
123
|
-
var t = new Audio();
|
|
124
|
-
t.muted && (e.noAudio = !0);
|
|
125
|
-
} catch {
|
|
126
|
-
}
|
|
127
|
-
return e.noAudio || e._setupCodecs(), e;
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Check for browser support for various codecs and cache the results.
|
|
131
|
-
* @return {Howler}
|
|
132
|
-
*/
|
|
133
|
-
_setupCodecs: function() {
|
|
134
|
-
var e = this || r, t = null;
|
|
135
|
-
try {
|
|
136
|
-
t = typeof Audio < "u" ? new Audio() : null;
|
|
137
|
-
} catch {
|
|
138
|
-
return e;
|
|
139
|
-
}
|
|
140
|
-
if (!t || typeof t.canPlayType != "function")
|
|
141
|
-
return e;
|
|
142
|
-
var n = t.canPlayType("audio/mpeg;").replace(/^no$/, ""), o = e._navigator ? e._navigator.userAgent : "", l = o.match(/OPR\/(\d+)/g), _ = l && parseInt(l[0].split("/")[1], 10) < 33, a = o.indexOf("Safari") !== -1 && o.indexOf("Chrome") === -1, f = o.match(/Version\/(.*?) /), m = a && f && parseInt(f[1], 10) < 15;
|
|
143
|
-
return e._codecs = {
|
|
144
|
-
mp3: !!(!_ && (n || t.canPlayType("audio/mp3;").replace(/^no$/, ""))),
|
|
145
|
-
mpeg: !!n,
|
|
146
|
-
opus: !!t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ""),
|
|
147
|
-
ogg: !!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
|
|
148
|
-
oga: !!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
|
|
149
|
-
wav: !!(t.canPlayType('audio/wav; codecs="1"') || t.canPlayType("audio/wav")).replace(/^no$/, ""),
|
|
150
|
-
aac: !!t.canPlayType("audio/aac;").replace(/^no$/, ""),
|
|
151
|
-
caf: !!t.canPlayType("audio/x-caf;").replace(/^no$/, ""),
|
|
152
|
-
m4a: !!(t.canPlayType("audio/x-m4a;") || t.canPlayType("audio/m4a;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
153
|
-
m4b: !!(t.canPlayType("audio/x-m4b;") || t.canPlayType("audio/m4b;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
154
|
-
mp4: !!(t.canPlayType("audio/x-mp4;") || t.canPlayType("audio/mp4;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
155
|
-
weba: !!(!m && t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
|
|
156
|
-
webm: !!(!m && t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
|
|
157
|
-
dolby: !!t.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ""),
|
|
158
|
-
flac: !!(t.canPlayType("audio/x-flac;") || t.canPlayType("audio/flac;")).replace(/^no$/, "")
|
|
159
|
-
}, e;
|
|
160
|
-
},
|
|
161
|
-
/**
|
|
162
|
-
* Some browsers/devices will only allow audio to be played after a user interaction.
|
|
163
|
-
* Attempt to automatically unlock audio on the first user interaction.
|
|
164
|
-
* Concept from: http://paulbakaus.com/tutorials/html5/web-audio-on-ios/
|
|
165
|
-
* @return {Howler}
|
|
166
|
-
*/
|
|
167
|
-
_unlockAudio: function() {
|
|
168
|
-
var e = this || r;
|
|
169
|
-
if (!(e._audioUnlocked || !e.ctx)) {
|
|
170
|
-
e._audioUnlocked = !1, e.autoUnlock = !1, !e._mobileUnloaded && e.ctx.sampleRate !== 44100 && (e._mobileUnloaded = !0, e.unload()), e._scratchBuffer = e.ctx.createBuffer(1, 1, 22050);
|
|
171
|
-
var t = function(n) {
|
|
172
|
-
for (; e._html5AudioPool.length < e.html5PoolSize; )
|
|
173
|
-
try {
|
|
174
|
-
var o = new Audio();
|
|
175
|
-
o._unlocked = !0, e._releaseHtml5Audio(o);
|
|
176
|
-
} catch {
|
|
177
|
-
e.noAudio = !0;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
for (var l = 0; l < e._howls.length; l++)
|
|
181
|
-
if (!e._howls[l]._webAudio)
|
|
182
|
-
for (var _ = e._howls[l]._getSoundIds(), a = 0; a < _.length; a++) {
|
|
183
|
-
var f = e._howls[l]._soundById(_[a]);
|
|
184
|
-
f && f._node && !f._node._unlocked && (f._node._unlocked = !0, f._node.load());
|
|
185
|
-
}
|
|
186
|
-
e._autoResume();
|
|
187
|
-
var m = e.ctx.createBufferSource();
|
|
188
|
-
m.buffer = e._scratchBuffer, m.connect(e.ctx.destination), typeof m.start > "u" ? m.noteOn(0) : m.start(0), typeof e.ctx.resume == "function" && e.ctx.resume(), m.onended = function() {
|
|
189
|
-
m.disconnect(0), e._audioUnlocked = !0, document.removeEventListener("touchstart", t, !0), document.removeEventListener("touchend", t, !0), document.removeEventListener("click", t, !0), document.removeEventListener("keydown", t, !0);
|
|
190
|
-
for (var y = 0; y < e._howls.length; y++)
|
|
191
|
-
e._howls[y]._emit("unlock");
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
return document.addEventListener("touchstart", t, !0), document.addEventListener("touchend", t, !0), document.addEventListener("click", t, !0), document.addEventListener("keydown", t, !0), e;
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
/**
|
|
198
|
-
* Get an unlocked HTML5 Audio object from the pool. If none are left,
|
|
199
|
-
* return a new Audio object and throw a warning.
|
|
200
|
-
* @return {Audio} HTML5 Audio object.
|
|
201
|
-
*/
|
|
202
|
-
_obtainHtml5Audio: function() {
|
|
203
|
-
var e = this || r;
|
|
204
|
-
if (e._html5AudioPool.length)
|
|
205
|
-
return e._html5AudioPool.pop();
|
|
206
|
-
var t = new Audio().play();
|
|
207
|
-
return t && typeof Promise < "u" && (t instanceof Promise || typeof t.then == "function") && t.catch(function() {
|
|
208
|
-
console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
|
|
209
|
-
}), new Audio();
|
|
210
|
-
},
|
|
211
|
-
/**
|
|
212
|
-
* Return an activated HTML5 Audio object to the pool.
|
|
213
|
-
* @return {Howler}
|
|
214
|
-
*/
|
|
215
|
-
_releaseHtml5Audio: function(e) {
|
|
216
|
-
var t = this || r;
|
|
217
|
-
return e._unlocked && t._html5AudioPool.push(e), t;
|
|
218
|
-
},
|
|
219
|
-
/**
|
|
220
|
-
* Automatically suspend the Web Audio AudioContext after no sound has played for 30 seconds.
|
|
221
|
-
* This saves processing/energy and fixes various browser-specific bugs with audio getting stuck.
|
|
222
|
-
* @return {Howler}
|
|
223
|
-
*/
|
|
224
|
-
_autoSuspend: function() {
|
|
225
|
-
var e = this;
|
|
226
|
-
if (!(!e.autoSuspend || !e.ctx || typeof e.ctx.suspend > "u" || !r.usingWebAudio)) {
|
|
227
|
-
for (var t = 0; t < e._howls.length; t++)
|
|
228
|
-
if (e._howls[t]._webAudio) {
|
|
229
|
-
for (var n = 0; n < e._howls[t]._sounds.length; n++)
|
|
230
|
-
if (!e._howls[t]._sounds[n]._paused)
|
|
231
|
-
return e;
|
|
232
|
-
}
|
|
233
|
-
return e._suspendTimer && clearTimeout(e._suspendTimer), e._suspendTimer = setTimeout(function() {
|
|
234
|
-
if (e.autoSuspend) {
|
|
235
|
-
e._suspendTimer = null, e.state = "suspending";
|
|
236
|
-
var o = function() {
|
|
237
|
-
e.state = "suspended", e._resumeAfterSuspend && (delete e._resumeAfterSuspend, e._autoResume());
|
|
238
|
-
};
|
|
239
|
-
e.ctx.suspend().then(o, o);
|
|
240
|
-
}
|
|
241
|
-
}, 3e4), e;
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
/**
|
|
245
|
-
* Automatically resume the Web Audio AudioContext when a new sound is played.
|
|
246
|
-
* @return {Howler}
|
|
247
|
-
*/
|
|
248
|
-
_autoResume: function() {
|
|
249
|
-
var e = this;
|
|
250
|
-
if (!(!e.ctx || typeof e.ctx.resume > "u" || !r.usingWebAudio))
|
|
251
|
-
return e.state === "running" && e.ctx.state !== "interrupted" && e._suspendTimer ? (clearTimeout(e._suspendTimer), e._suspendTimer = null) : e.state === "suspended" || e.state === "running" && e.ctx.state === "interrupted" ? (e.ctx.resume().then(function() {
|
|
252
|
-
e.state = "running";
|
|
253
|
-
for (var t = 0; t < e._howls.length; t++)
|
|
254
|
-
e._howls[t]._emit("resume");
|
|
255
|
-
}), e._suspendTimer && (clearTimeout(e._suspendTimer), e._suspendTimer = null)) : e.state === "suspending" && (e._resumeAfterSuspend = !0), e;
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
var r = new w(), u = function(e) {
|
|
259
|
-
var t = this;
|
|
260
|
-
if (!e.src || e.src.length === 0) {
|
|
261
|
-
console.error("An array of source files must be passed with any new Howl.");
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
t.init(e);
|
|
265
|
-
};
|
|
266
|
-
u.prototype = {
|
|
267
|
-
/**
|
|
268
|
-
* Initialize a new Howl group object.
|
|
269
|
-
* @param {Object} o Passed in properties for this group.
|
|
270
|
-
* @return {Howl}
|
|
271
|
-
*/
|
|
272
|
-
init: function(e) {
|
|
273
|
-
var t = this;
|
|
274
|
-
return r.ctx || A(), t._autoplay = e.autoplay || !1, t._format = typeof e.format != "string" ? e.format : [e.format], t._html5 = e.html5 || !1, t._muted = e.mute || !1, t._loop = e.loop || !1, t._pool = e.pool || 5, t._preload = typeof e.preload == "boolean" || e.preload === "metadata" ? e.preload : !0, t._rate = e.rate || 1, t._sprite = e.sprite || {}, t._src = typeof e.src != "string" ? e.src : [e.src], t._volume = e.volume !== void 0 ? e.volume : 1, t._xhr = {
|
|
275
|
-
method: e.xhr && e.xhr.method ? e.xhr.method : "GET",
|
|
276
|
-
headers: e.xhr && e.xhr.headers ? e.xhr.headers : null,
|
|
277
|
-
withCredentials: e.xhr && e.xhr.withCredentials ? e.xhr.withCredentials : !1
|
|
278
|
-
}, t._duration = 0, t._state = "unloaded", t._sounds = [], t._endTimers = {}, t._queue = [], t._playLock = !1, t._onend = e.onend ? [{ fn: e.onend }] : [], t._onfade = e.onfade ? [{ fn: e.onfade }] : [], t._onload = e.onload ? [{ fn: e.onload }] : [], t._onloaderror = e.onloaderror ? [{ fn: e.onloaderror }] : [], t._onplayerror = e.onplayerror ? [{ fn: e.onplayerror }] : [], t._onpause = e.onpause ? [{ fn: e.onpause }] : [], t._onplay = e.onplay ? [{ fn: e.onplay }] : [], t._onstop = e.onstop ? [{ fn: e.onstop }] : [], t._onmute = e.onmute ? [{ fn: e.onmute }] : [], t._onvolume = e.onvolume ? [{ fn: e.onvolume }] : [], t._onrate = e.onrate ? [{ fn: e.onrate }] : [], t._onseek = e.onseek ? [{ fn: e.onseek }] : [], t._onunlock = e.onunlock ? [{ fn: e.onunlock }] : [], t._onresume = [], t._webAudio = r.usingWebAudio && !t._html5, typeof r.ctx < "u" && r.ctx && r.autoUnlock && r._unlockAudio(), r._howls.push(t), t._autoplay && t._queue.push({
|
|
279
|
-
event: "play",
|
|
280
|
-
action: function() {
|
|
281
|
-
t.play();
|
|
282
|
-
}
|
|
283
|
-
}), t._preload && t._preload !== "none" && t.load(), t;
|
|
284
|
-
},
|
|
285
|
-
/**
|
|
286
|
-
* Load the audio file.
|
|
287
|
-
* @return {Howler}
|
|
288
|
-
*/
|
|
289
|
-
load: function() {
|
|
290
|
-
var e = this, t = null;
|
|
291
|
-
if (r.noAudio) {
|
|
292
|
-
e._emit("loaderror", null, "No audio support.");
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
typeof e._src == "string" && (e._src = [e._src]);
|
|
296
|
-
for (var n = 0; n < e._src.length; n++) {
|
|
297
|
-
var o, l;
|
|
298
|
-
if (e._format && e._format[n])
|
|
299
|
-
o = e._format[n];
|
|
300
|
-
else {
|
|
301
|
-
if (l = e._src[n], typeof l != "string") {
|
|
302
|
-
e._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
o = /^data:audio\/([^;,]+);/i.exec(l), o || (o = /\.([^.]+)$/.exec(l.split("?", 1)[0])), o && (o = o[1].toLowerCase());
|
|
306
|
-
}
|
|
307
|
-
if (o || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'), o && r.codecs(o)) {
|
|
308
|
-
t = e._src[n];
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (!t) {
|
|
313
|
-
e._emit("loaderror", null, "No codec support for selected audio sources.");
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
return e._src = t, e._state = "loading", window.location.protocol === "https:" && t.slice(0, 5) === "http:" && (e._html5 = !0, e._webAudio = !1), new i(e), e._webAudio && c(e), e;
|
|
317
|
-
},
|
|
318
|
-
/**
|
|
319
|
-
* Play a sound or resume previous playback.
|
|
320
|
-
* @param {String/Number} sprite Sprite name for sprite playback or sound id to continue previous.
|
|
321
|
-
* @param {Boolean} internal Internal Use: true prevents event firing.
|
|
322
|
-
* @return {Number} Sound ID.
|
|
323
|
-
*/
|
|
324
|
-
play: function(e, t) {
|
|
325
|
-
var n = this, o = null;
|
|
326
|
-
if (typeof e == "number")
|
|
327
|
-
o = e, e = null;
|
|
328
|
-
else {
|
|
329
|
-
if (typeof e == "string" && n._state === "loaded" && !n._sprite[e])
|
|
330
|
-
return null;
|
|
331
|
-
if (typeof e > "u" && (e = "__default", !n._playLock)) {
|
|
332
|
-
for (var l = 0, _ = 0; _ < n._sounds.length; _++)
|
|
333
|
-
n._sounds[_]._paused && !n._sounds[_]._ended && (l++, o = n._sounds[_]._id);
|
|
334
|
-
l === 1 ? e = null : o = null;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
var a = o ? n._soundById(o) : n._inactiveSound();
|
|
338
|
-
if (!a)
|
|
339
|
-
return null;
|
|
340
|
-
if (o && !e && (e = a._sprite || "__default"), n._state !== "loaded") {
|
|
341
|
-
a._sprite = e, a._ended = !1;
|
|
342
|
-
var f = a._id;
|
|
343
|
-
return n._queue.push({
|
|
344
|
-
event: "play",
|
|
345
|
-
action: function() {
|
|
346
|
-
n.play(f);
|
|
347
|
-
}
|
|
348
|
-
}), f;
|
|
349
|
-
}
|
|
350
|
-
if (o && !a._paused)
|
|
351
|
-
return t || n._loadQueue("play"), a._id;
|
|
352
|
-
n._webAudio && r._autoResume();
|
|
353
|
-
var m = Math.max(0, a._seek > 0 ? a._seek : n._sprite[e][0] / 1e3), y = Math.max(0, (n._sprite[e][0] + n._sprite[e][1]) / 1e3 - m), b = y * 1e3 / Math.abs(a._rate), T = n._sprite[e][0] / 1e3, k = (n._sprite[e][0] + n._sprite[e][1]) / 1e3;
|
|
354
|
-
a._sprite = e, a._ended = !1;
|
|
355
|
-
var I = function() {
|
|
356
|
-
a._paused = !1, a._seek = m, a._start = T, a._stop = k, a._loop = !!(a._loop || n._sprite[e][2]);
|
|
357
|
-
};
|
|
358
|
-
if (m >= k) {
|
|
359
|
-
n._ended(a);
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
var v = a._node;
|
|
363
|
-
if (n._webAudio) {
|
|
364
|
-
var P = function() {
|
|
365
|
-
n._playLock = !1, I(), n._refreshBuffer(a);
|
|
366
|
-
var x = a._muted || n._muted ? 0 : a._volume;
|
|
367
|
-
v.gain.setValueAtTime(x, r.ctx.currentTime), a._playStart = r.ctx.currentTime, typeof v.bufferSource.start > "u" ? a._loop ? v.bufferSource.noteGrainOn(0, m, 86400) : v.bufferSource.noteGrainOn(0, m, y) : a._loop ? v.bufferSource.start(0, m, 86400) : v.bufferSource.start(0, m, y), b !== 1 / 0 && (n._endTimers[a._id] = setTimeout(n._ended.bind(n, a), b)), t || setTimeout(function() {
|
|
368
|
-
n._emit("play", a._id), n._loadQueue();
|
|
369
|
-
}, 0);
|
|
370
|
-
};
|
|
371
|
-
r.state === "running" && r.ctx.state !== "interrupted" ? P() : (n._playLock = !0, n.once("resume", P), n._clearTimer(a._id));
|
|
372
|
-
} else {
|
|
373
|
-
var H = function() {
|
|
374
|
-
v.currentTime = m, v.muted = a._muted || n._muted || r._muted || v.muted, v.volume = a._volume * r.volume(), v.playbackRate = a._rate;
|
|
375
|
-
try {
|
|
376
|
-
var x = v.play();
|
|
377
|
-
if (x && typeof Promise < "u" && (x instanceof Promise || typeof x.then == "function") ? (n._playLock = !0, I(), x.then(function() {
|
|
378
|
-
n._playLock = !1, v._unlocked = !0, t ? n._loadQueue() : n._emit("play", a._id);
|
|
379
|
-
}).catch(function() {
|
|
380
|
-
n._playLock = !1, n._emit("playerror", a._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."), a._ended = !0, a._paused = !0;
|
|
381
|
-
})) : t || (n._playLock = !1, I(), n._emit("play", a._id)), v.playbackRate = a._rate, v.paused) {
|
|
382
|
-
n._emit("playerror", a._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
e !== "__default" || a._loop ? n._endTimers[a._id] = setTimeout(n._ended.bind(n, a), b) : (n._endTimers[a._id] = function() {
|
|
386
|
-
n._ended(a), v.removeEventListener("ended", n._endTimers[a._id], !1);
|
|
387
|
-
}, v.addEventListener("ended", n._endTimers[a._id], !1));
|
|
388
|
-
} catch (B) {
|
|
389
|
-
n._emit("playerror", a._id, B);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
v.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" && (v.src = n._src, v.load());
|
|
393
|
-
var F = window && window.ejecta || !v.readyState && r._navigator.isCocoonJS;
|
|
394
|
-
if (v.readyState >= 3 || F)
|
|
395
|
-
H();
|
|
396
|
-
else {
|
|
397
|
-
n._playLock = !0, n._state = "loading";
|
|
398
|
-
var M = function() {
|
|
399
|
-
n._state = "loaded", H(), v.removeEventListener(r._canPlayEvent, M, !1);
|
|
400
|
-
};
|
|
401
|
-
v.addEventListener(r._canPlayEvent, M, !1), n._clearTimer(a._id);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return a._id;
|
|
405
|
-
},
|
|
406
|
-
/**
|
|
407
|
-
* Pause playback and save current position.
|
|
408
|
-
* @param {Number} id The sound ID (empty to pause all in group).
|
|
409
|
-
* @return {Howl}
|
|
410
|
-
*/
|
|
411
|
-
pause: function(e) {
|
|
412
|
-
var t = this;
|
|
413
|
-
if (t._state !== "loaded" || t._playLock)
|
|
414
|
-
return t._queue.push({
|
|
415
|
-
event: "pause",
|
|
416
|
-
action: function() {
|
|
417
|
-
t.pause(e);
|
|
418
|
-
}
|
|
419
|
-
}), t;
|
|
420
|
-
for (var n = t._getSoundIds(e), o = 0; o < n.length; o++) {
|
|
421
|
-
t._clearTimer(n[o]);
|
|
422
|
-
var l = t._soundById(n[o]);
|
|
423
|
-
if (l && !l._paused && (l._seek = t.seek(n[o]), l._rateSeek = 0, l._paused = !0, t._stopFade(n[o]), l._node))
|
|
424
|
-
if (t._webAudio) {
|
|
425
|
-
if (!l._node.bufferSource)
|
|
426
|
-
continue;
|
|
427
|
-
typeof l._node.bufferSource.stop > "u" ? l._node.bufferSource.noteOff(0) : l._node.bufferSource.stop(0), t._cleanBuffer(l._node);
|
|
428
|
-
} else (!isNaN(l._node.duration) || l._node.duration === 1 / 0) && l._node.pause();
|
|
429
|
-
arguments[1] || t._emit("pause", l ? l._id : null);
|
|
430
|
-
}
|
|
431
|
-
return t;
|
|
432
|
-
},
|
|
433
|
-
/**
|
|
434
|
-
* Stop playback and reset to start.
|
|
435
|
-
* @param {Number} id The sound ID (empty to stop all in group).
|
|
436
|
-
* @param {Boolean} internal Internal Use: true prevents event firing.
|
|
437
|
-
* @return {Howl}
|
|
438
|
-
*/
|
|
439
|
-
stop: function(e, t) {
|
|
440
|
-
var n = this;
|
|
441
|
-
if (n._state !== "loaded" || n._playLock)
|
|
442
|
-
return n._queue.push({
|
|
443
|
-
event: "stop",
|
|
444
|
-
action: function() {
|
|
445
|
-
n.stop(e);
|
|
446
|
-
}
|
|
447
|
-
}), n;
|
|
448
|
-
for (var o = n._getSoundIds(e), l = 0; l < o.length; l++) {
|
|
449
|
-
n._clearTimer(o[l]);
|
|
450
|
-
var _ = n._soundById(o[l]);
|
|
451
|
-
_ && (_._seek = _._start || 0, _._rateSeek = 0, _._paused = !0, _._ended = !0, n._stopFade(o[l]), _._node && (n._webAudio ? _._node.bufferSource && (typeof _._node.bufferSource.stop > "u" ? _._node.bufferSource.noteOff(0) : _._node.bufferSource.stop(0), n._cleanBuffer(_._node)) : (!isNaN(_._node.duration) || _._node.duration === 1 / 0) && (_._node.currentTime = _._start || 0, _._node.pause(), _._node.duration === 1 / 0 && n._clearSound(_._node))), t || n._emit("stop", _._id));
|
|
452
|
-
}
|
|
453
|
-
return n;
|
|
454
|
-
},
|
|
455
|
-
/**
|
|
456
|
-
* Mute/unmute a single sound or all sounds in this Howl group.
|
|
457
|
-
* @param {Boolean} muted Set to true to mute and false to unmute.
|
|
458
|
-
* @param {Number} id The sound ID to update (omit to mute/unmute all).
|
|
459
|
-
* @return {Howl}
|
|
460
|
-
*/
|
|
461
|
-
mute: function(e, t) {
|
|
462
|
-
var n = this;
|
|
463
|
-
if (n._state !== "loaded" || n._playLock)
|
|
464
|
-
return n._queue.push({
|
|
465
|
-
event: "mute",
|
|
466
|
-
action: function() {
|
|
467
|
-
n.mute(e, t);
|
|
468
|
-
}
|
|
469
|
-
}), n;
|
|
470
|
-
if (typeof t > "u")
|
|
471
|
-
if (typeof e == "boolean")
|
|
472
|
-
n._muted = e;
|
|
473
|
-
else
|
|
474
|
-
return n._muted;
|
|
475
|
-
for (var o = n._getSoundIds(t), l = 0; l < o.length; l++) {
|
|
476
|
-
var _ = n._soundById(o[l]);
|
|
477
|
-
_ && (_._muted = e, _._interval && n._stopFade(_._id), n._webAudio && _._node ? _._node.gain.setValueAtTime(e ? 0 : _._volume, r.ctx.currentTime) : _._node && (_._node.muted = r._muted ? !0 : e), n._emit("mute", _._id));
|
|
478
|
-
}
|
|
479
|
-
return n;
|
|
480
|
-
},
|
|
481
|
-
/**
|
|
482
|
-
* Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments.
|
|
483
|
-
* volume() -> Returns the group's volume value.
|
|
484
|
-
* volume(id) -> Returns the sound id's current volume.
|
|
485
|
-
* volume(vol) -> Sets the volume of all sounds in this Howl group.
|
|
486
|
-
* volume(vol, id) -> Sets the volume of passed sound id.
|
|
487
|
-
* @return {Howl/Number} Returns self or current volume.
|
|
488
|
-
*/
|
|
489
|
-
volume: function() {
|
|
490
|
-
var e = this, t = arguments, n, o;
|
|
491
|
-
if (t.length === 0)
|
|
492
|
-
return e._volume;
|
|
493
|
-
if (t.length === 1 || t.length === 2 && typeof t[1] > "u") {
|
|
494
|
-
var l = e._getSoundIds(), _ = l.indexOf(t[0]);
|
|
495
|
-
_ >= 0 ? o = parseInt(t[0], 10) : n = parseFloat(t[0]);
|
|
496
|
-
} else t.length >= 2 && (n = parseFloat(t[0]), o = parseInt(t[1], 10));
|
|
497
|
-
var a;
|
|
498
|
-
if (typeof n < "u" && n >= 0 && n <= 1) {
|
|
499
|
-
if (e._state !== "loaded" || e._playLock)
|
|
500
|
-
return e._queue.push({
|
|
501
|
-
event: "volume",
|
|
502
|
-
action: function() {
|
|
503
|
-
e.volume.apply(e, t);
|
|
504
|
-
}
|
|
505
|
-
}), e;
|
|
506
|
-
typeof o > "u" && (e._volume = n), o = e._getSoundIds(o);
|
|
507
|
-
for (var f = 0; f < o.length; f++)
|
|
508
|
-
a = e._soundById(o[f]), a && (a._volume = n, t[2] || e._stopFade(o[f]), e._webAudio && a._node && !a._muted ? a._node.gain.setValueAtTime(n, r.ctx.currentTime) : a._node && !a._muted && (a._node.volume = n * r.volume()), e._emit("volume", a._id));
|
|
509
|
-
} else
|
|
510
|
-
return a = o ? e._soundById(o) : e._sounds[0], a ? a._volume : 0;
|
|
511
|
-
return e;
|
|
512
|
-
},
|
|
513
|
-
/**
|
|
514
|
-
* Fade a currently playing sound between two volumes (if no id is passed, all sounds will fade).
|
|
515
|
-
* @param {Number} from The value to fade from (0.0 to 1.0).
|
|
516
|
-
* @param {Number} to The volume to fade to (0.0 to 1.0).
|
|
517
|
-
* @param {Number} len Time in milliseconds to fade.
|
|
518
|
-
* @param {Number} id The sound id (omit to fade all sounds).
|
|
519
|
-
* @return {Howl}
|
|
520
|
-
*/
|
|
521
|
-
fade: function(e, t, n, o) {
|
|
522
|
-
var l = this;
|
|
523
|
-
if (l._state !== "loaded" || l._playLock)
|
|
524
|
-
return l._queue.push({
|
|
525
|
-
event: "fade",
|
|
526
|
-
action: function() {
|
|
527
|
-
l.fade(e, t, n, o);
|
|
528
|
-
}
|
|
529
|
-
}), l;
|
|
530
|
-
e = Math.min(Math.max(0, parseFloat(e)), 1), t = Math.min(Math.max(0, parseFloat(t)), 1), n = parseFloat(n), l.volume(e, o);
|
|
531
|
-
for (var _ = l._getSoundIds(o), a = 0; a < _.length; a++) {
|
|
532
|
-
var f = l._soundById(_[a]);
|
|
533
|
-
if (f) {
|
|
534
|
-
if (o || l._stopFade(_[a]), l._webAudio && !f._muted) {
|
|
535
|
-
var m = r.ctx.currentTime, y = m + n / 1e3;
|
|
536
|
-
f._volume = e, f._node.gain.setValueAtTime(e, m), f._node.gain.linearRampToValueAtTime(t, y);
|
|
537
|
-
}
|
|
538
|
-
l._startFadeInterval(f, e, t, n, _[a], typeof o > "u");
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return l;
|
|
542
|
-
},
|
|
543
|
-
/**
|
|
544
|
-
* Starts the internal interval to fade a sound.
|
|
545
|
-
* @param {Object} sound Reference to sound to fade.
|
|
546
|
-
* @param {Number} from The value to fade from (0.0 to 1.0).
|
|
547
|
-
* @param {Number} to The volume to fade to (0.0 to 1.0).
|
|
548
|
-
* @param {Number} len Time in milliseconds to fade.
|
|
549
|
-
* @param {Number} id The sound id to fade.
|
|
550
|
-
* @param {Boolean} isGroup If true, set the volume on the group.
|
|
551
|
-
*/
|
|
552
|
-
_startFadeInterval: function(e, t, n, o, l, _) {
|
|
553
|
-
var a = this, f = t, m = n - t, y = Math.abs(m / 0.01), b = Math.max(4, y > 0 ? o / y : o), T = Date.now();
|
|
554
|
-
e._fadeTo = n, e._interval = setInterval(function() {
|
|
555
|
-
var k = (Date.now() - T) / o;
|
|
556
|
-
T = Date.now(), f += m * k, f = Math.round(f * 100) / 100, m < 0 ? f = Math.max(n, f) : f = Math.min(n, f), a._webAudio ? e._volume = f : a.volume(f, e._id, !0), _ && (a._volume = f), (n < t && f <= n || n > t && f >= n) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, a.volume(n, e._id), a._emit("fade", e._id));
|
|
557
|
-
}, b);
|
|
558
|
-
},
|
|
559
|
-
/**
|
|
560
|
-
* Internal method that stops the currently playing fade when
|
|
561
|
-
* a new fade starts, volume is changed or the sound is stopped.
|
|
562
|
-
* @param {Number} id The sound id.
|
|
563
|
-
* @return {Howl}
|
|
564
|
-
*/
|
|
565
|
-
_stopFade: function(e) {
|
|
566
|
-
var t = this, n = t._soundById(e);
|
|
567
|
-
return n && n._interval && (t._webAudio && n._node.gain.cancelScheduledValues(r.ctx.currentTime), clearInterval(n._interval), n._interval = null, t.volume(n._fadeTo, e), n._fadeTo = null, t._emit("fade", e)), t;
|
|
568
|
-
},
|
|
569
|
-
/**
|
|
570
|
-
* Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments.
|
|
571
|
-
* loop() -> Returns the group's loop value.
|
|
572
|
-
* loop(id) -> Returns the sound id's loop value.
|
|
573
|
-
* loop(loop) -> Sets the loop value for all sounds in this Howl group.
|
|
574
|
-
* loop(loop, id) -> Sets the loop value of passed sound id.
|
|
575
|
-
* @return {Howl/Boolean} Returns self or current loop value.
|
|
576
|
-
*/
|
|
577
|
-
loop: function() {
|
|
578
|
-
var e = this, t = arguments, n, o, l;
|
|
579
|
-
if (t.length === 0)
|
|
580
|
-
return e._loop;
|
|
581
|
-
if (t.length === 1)
|
|
582
|
-
if (typeof t[0] == "boolean")
|
|
583
|
-
n = t[0], e._loop = n;
|
|
584
|
-
else
|
|
585
|
-
return l = e._soundById(parseInt(t[0], 10)), l ? l._loop : !1;
|
|
586
|
-
else t.length === 2 && (n = t[0], o = parseInt(t[1], 10));
|
|
587
|
-
for (var _ = e._getSoundIds(o), a = 0; a < _.length; a++)
|
|
588
|
-
l = e._soundById(_[a]), l && (l._loop = n, e._webAudio && l._node && l._node.bufferSource && (l._node.bufferSource.loop = n, n && (l._node.bufferSource.loopStart = l._start || 0, l._node.bufferSource.loopEnd = l._stop, e.playing(_[a]) && (e.pause(_[a], !0), e.play(_[a], !0)))));
|
|
589
|
-
return e;
|
|
590
|
-
},
|
|
591
|
-
/**
|
|
592
|
-
* Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments.
|
|
593
|
-
* rate() -> Returns the first sound node's current playback rate.
|
|
594
|
-
* rate(id) -> Returns the sound id's current playback rate.
|
|
595
|
-
* rate(rate) -> Sets the playback rate of all sounds in this Howl group.
|
|
596
|
-
* rate(rate, id) -> Sets the playback rate of passed sound id.
|
|
597
|
-
* @return {Howl/Number} Returns self or the current playback rate.
|
|
598
|
-
*/
|
|
599
|
-
rate: function() {
|
|
600
|
-
var e = this, t = arguments, n, o;
|
|
601
|
-
if (t.length === 0)
|
|
602
|
-
o = e._sounds[0]._id;
|
|
603
|
-
else if (t.length === 1) {
|
|
604
|
-
var l = e._getSoundIds(), _ = l.indexOf(t[0]);
|
|
605
|
-
_ >= 0 ? o = parseInt(t[0], 10) : n = parseFloat(t[0]);
|
|
606
|
-
} else t.length === 2 && (n = parseFloat(t[0]), o = parseInt(t[1], 10));
|
|
607
|
-
var a;
|
|
608
|
-
if (typeof n == "number") {
|
|
609
|
-
if (e._state !== "loaded" || e._playLock)
|
|
610
|
-
return e._queue.push({
|
|
611
|
-
event: "rate",
|
|
612
|
-
action: function() {
|
|
613
|
-
e.rate.apply(e, t);
|
|
614
|
-
}
|
|
615
|
-
}), e;
|
|
616
|
-
typeof o > "u" && (e._rate = n), o = e._getSoundIds(o);
|
|
617
|
-
for (var f = 0; f < o.length; f++)
|
|
618
|
-
if (a = e._soundById(o[f]), a) {
|
|
619
|
-
e.playing(o[f]) && (a._rateSeek = e.seek(o[f]), a._playStart = e._webAudio ? r.ctx.currentTime : a._playStart), a._rate = n, e._webAudio && a._node && a._node.bufferSource ? a._node.bufferSource.playbackRate.setValueAtTime(n, r.ctx.currentTime) : a._node && (a._node.playbackRate = n);
|
|
620
|
-
var m = e.seek(o[f]), y = (e._sprite[a._sprite][0] + e._sprite[a._sprite][1]) / 1e3 - m, b = y * 1e3 / Math.abs(a._rate);
|
|
621
|
-
(e._endTimers[o[f]] || !a._paused) && (e._clearTimer(o[f]), e._endTimers[o[f]] = setTimeout(e._ended.bind(e, a), b)), e._emit("rate", a._id);
|
|
622
|
-
}
|
|
623
|
-
} else
|
|
624
|
-
return a = e._soundById(o), a ? a._rate : e._rate;
|
|
625
|
-
return e;
|
|
626
|
-
},
|
|
627
|
-
/**
|
|
628
|
-
* Get/set the seek position of a sound. This method can optionally take 0, 1 or 2 arguments.
|
|
629
|
-
* seek() -> Returns the first sound node's current seek position.
|
|
630
|
-
* seek(id) -> Returns the sound id's current seek position.
|
|
631
|
-
* seek(seek) -> Sets the seek position of the first sound node.
|
|
632
|
-
* seek(seek, id) -> Sets the seek position of passed sound id.
|
|
633
|
-
* @return {Howl/Number} Returns self or the current seek position.
|
|
634
|
-
*/
|
|
635
|
-
seek: function() {
|
|
636
|
-
var e = this, t = arguments, n, o;
|
|
637
|
-
if (t.length === 0)
|
|
638
|
-
e._sounds.length && (o = e._sounds[0]._id);
|
|
639
|
-
else if (t.length === 1) {
|
|
640
|
-
var l = e._getSoundIds(), _ = l.indexOf(t[0]);
|
|
641
|
-
_ >= 0 ? o = parseInt(t[0], 10) : e._sounds.length && (o = e._sounds[0]._id, n = parseFloat(t[0]));
|
|
642
|
-
} else t.length === 2 && (n = parseFloat(t[0]), o = parseInt(t[1], 10));
|
|
643
|
-
if (typeof o > "u")
|
|
644
|
-
return 0;
|
|
645
|
-
if (typeof n == "number" && (e._state !== "loaded" || e._playLock))
|
|
646
|
-
return e._queue.push({
|
|
647
|
-
event: "seek",
|
|
648
|
-
action: function() {
|
|
649
|
-
e.seek.apply(e, t);
|
|
650
|
-
}
|
|
651
|
-
}), e;
|
|
652
|
-
var a = e._soundById(o);
|
|
653
|
-
if (a)
|
|
654
|
-
if (typeof n == "number" && n >= 0) {
|
|
655
|
-
var f = e.playing(o);
|
|
656
|
-
f && e.pause(o, !0), a._seek = n, a._ended = !1, e._clearTimer(o), !e._webAudio && a._node && !isNaN(a._node.duration) && (a._node.currentTime = n);
|
|
657
|
-
var m = function() {
|
|
658
|
-
f && e.play(o, !0), e._emit("seek", o);
|
|
659
|
-
};
|
|
660
|
-
if (f && !e._webAudio) {
|
|
661
|
-
var y = function() {
|
|
662
|
-
e._playLock ? setTimeout(y, 0) : m();
|
|
663
|
-
};
|
|
664
|
-
setTimeout(y, 0);
|
|
665
|
-
} else
|
|
666
|
-
m();
|
|
667
|
-
} else if (e._webAudio) {
|
|
668
|
-
var b = e.playing(o) ? r.ctx.currentTime - a._playStart : 0, T = a._rateSeek ? a._rateSeek - a._seek : 0;
|
|
669
|
-
return a._seek + (T + b * Math.abs(a._rate));
|
|
670
|
-
} else
|
|
671
|
-
return a._node.currentTime;
|
|
672
|
-
return e;
|
|
673
|
-
},
|
|
674
|
-
/**
|
|
675
|
-
* Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not.
|
|
676
|
-
* @param {Number} id The sound id to check. If none is passed, the whole sound group is checked.
|
|
677
|
-
* @return {Boolean} True if playing and false if not.
|
|
678
|
-
*/
|
|
679
|
-
playing: function(e) {
|
|
680
|
-
var t = this;
|
|
681
|
-
if (typeof e == "number") {
|
|
682
|
-
var n = t._soundById(e);
|
|
683
|
-
return n ? !n._paused : !1;
|
|
684
|
-
}
|
|
685
|
-
for (var o = 0; o < t._sounds.length; o++)
|
|
686
|
-
if (!t._sounds[o]._paused)
|
|
687
|
-
return !0;
|
|
688
|
-
return !1;
|
|
689
|
-
},
|
|
690
|
-
/**
|
|
691
|
-
* Get the duration of this sound. Passing a sound id will return the sprite duration.
|
|
692
|
-
* @param {Number} id The sound id to check. If none is passed, return full source duration.
|
|
693
|
-
* @return {Number} Audio duration in seconds.
|
|
694
|
-
*/
|
|
695
|
-
duration: function(e) {
|
|
696
|
-
var t = this, n = t._duration, o = t._soundById(e);
|
|
697
|
-
return o && (n = t._sprite[o._sprite][1] / 1e3), n;
|
|
698
|
-
},
|
|
699
|
-
/**
|
|
700
|
-
* Returns the current loaded state of this Howl.
|
|
701
|
-
* @return {String} 'unloaded', 'loading', 'loaded'
|
|
702
|
-
*/
|
|
703
|
-
state: function() {
|
|
704
|
-
return this._state;
|
|
705
|
-
},
|
|
706
|
-
/**
|
|
707
|
-
* Unload and destroy the current Howl object.
|
|
708
|
-
* This will immediately stop all sound instances attached to this group.
|
|
709
|
-
*/
|
|
710
|
-
unload: function() {
|
|
711
|
-
for (var e = this, t = e._sounds, n = 0; n < t.length; n++)
|
|
712
|
-
t[n]._paused || e.stop(t[n]._id), e._webAudio || (e._clearSound(t[n]._node), t[n]._node.removeEventListener("error", t[n]._errorFn, !1), t[n]._node.removeEventListener(r._canPlayEvent, t[n]._loadFn, !1), t[n]._node.removeEventListener("ended", t[n]._endFn, !1), r._releaseHtml5Audio(t[n]._node)), delete t[n]._node, e._clearTimer(t[n]._id);
|
|
713
|
-
var o = r._howls.indexOf(e);
|
|
714
|
-
o >= 0 && r._howls.splice(o, 1);
|
|
715
|
-
var l = !0;
|
|
716
|
-
for (n = 0; n < r._howls.length; n++)
|
|
717
|
-
if (r._howls[n]._src === e._src || e._src.indexOf(r._howls[n]._src) >= 0) {
|
|
718
|
-
l = !1;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
return d && l && delete d[e._src], r.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
|
|
722
|
-
},
|
|
723
|
-
/**
|
|
724
|
-
* Listen to a custom event.
|
|
725
|
-
* @param {String} event Event name.
|
|
726
|
-
* @param {Function} fn Listener to call.
|
|
727
|
-
* @param {Number} id (optional) Only listen to events for this sound.
|
|
728
|
-
* @param {Number} once (INTERNAL) Marks event to fire only once.
|
|
729
|
-
* @return {Howl}
|
|
730
|
-
*/
|
|
731
|
-
on: function(e, t, n, o) {
|
|
732
|
-
var l = this, _ = l["_on" + e];
|
|
733
|
-
return typeof t == "function" && _.push(o ? { id: n, fn: t, once: o } : { id: n, fn: t }), l;
|
|
734
|
-
},
|
|
735
|
-
/**
|
|
736
|
-
* Remove a custom event. Call without parameters to remove all events.
|
|
737
|
-
* @param {String} event Event name.
|
|
738
|
-
* @param {Function} fn Listener to remove. Leave empty to remove all.
|
|
739
|
-
* @param {Number} id (optional) Only remove events for this sound.
|
|
740
|
-
* @return {Howl}
|
|
741
|
-
*/
|
|
742
|
-
off: function(e, t, n) {
|
|
743
|
-
var o = this, l = o["_on" + e], _ = 0;
|
|
744
|
-
if (typeof t == "number" && (n = t, t = null), t || n)
|
|
745
|
-
for (_ = 0; _ < l.length; _++) {
|
|
746
|
-
var a = n === l[_].id;
|
|
747
|
-
if (t === l[_].fn && a || !t && a) {
|
|
748
|
-
l.splice(_, 1);
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
else if (e)
|
|
753
|
-
o["_on" + e] = [];
|
|
754
|
-
else {
|
|
755
|
-
var f = Object.keys(o);
|
|
756
|
-
for (_ = 0; _ < f.length; _++)
|
|
757
|
-
f[_].indexOf("_on") === 0 && Array.isArray(o[f[_]]) && (o[f[_]] = []);
|
|
758
|
-
}
|
|
759
|
-
return o;
|
|
760
|
-
},
|
|
761
|
-
/**
|
|
762
|
-
* Listen to a custom event and remove it once fired.
|
|
763
|
-
* @param {String} event Event name.
|
|
764
|
-
* @param {Function} fn Listener to call.
|
|
765
|
-
* @param {Number} id (optional) Only listen to events for this sound.
|
|
766
|
-
* @return {Howl}
|
|
767
|
-
*/
|
|
768
|
-
once: function(e, t, n) {
|
|
769
|
-
var o = this;
|
|
770
|
-
return o.on(e, t, n, 1), o;
|
|
771
|
-
},
|
|
772
|
-
/**
|
|
773
|
-
* Emit all events of a specific type and pass the sound id.
|
|
774
|
-
* @param {String} event Event name.
|
|
775
|
-
* @param {Number} id Sound ID.
|
|
776
|
-
* @param {Number} msg Message to go with event.
|
|
777
|
-
* @return {Howl}
|
|
778
|
-
*/
|
|
779
|
-
_emit: function(e, t, n) {
|
|
780
|
-
for (var o = this, l = o["_on" + e], _ = l.length - 1; _ >= 0; _--)
|
|
781
|
-
(!l[_].id || l[_].id === t || e === "load") && (setTimeout((function(a) {
|
|
782
|
-
a.call(this, t, n);
|
|
783
|
-
}).bind(o, l[_].fn), 0), l[_].once && o.off(e, l[_].fn, l[_].id));
|
|
784
|
-
return o._loadQueue(e), o;
|
|
785
|
-
},
|
|
786
|
-
/**
|
|
787
|
-
* Queue of actions initiated before the sound has loaded.
|
|
788
|
-
* These will be called in sequence, with the next only firing
|
|
789
|
-
* after the previous has finished executing (even if async like play).
|
|
790
|
-
* @return {Howl}
|
|
791
|
-
*/
|
|
792
|
-
_loadQueue: function(e) {
|
|
793
|
-
var t = this;
|
|
794
|
-
if (t._queue.length > 0) {
|
|
795
|
-
var n = t._queue[0];
|
|
796
|
-
n.event === e && (t._queue.shift(), t._loadQueue()), e || n.action();
|
|
797
|
-
}
|
|
798
|
-
return t;
|
|
799
|
-
},
|
|
800
|
-
/**
|
|
801
|
-
* Fired when playback ends at the end of the duration.
|
|
802
|
-
* @param {Sound} sound The sound object to work with.
|
|
803
|
-
* @return {Howl}
|
|
804
|
-
*/
|
|
805
|
-
_ended: function(e) {
|
|
806
|
-
var t = this, n = e._sprite;
|
|
807
|
-
if (!t._webAudio && e._node && !e._node.paused && !e._node.ended && e._node.currentTime < e._stop)
|
|
808
|
-
return setTimeout(t._ended.bind(t, e), 100), t;
|
|
809
|
-
var o = !!(e._loop || t._sprite[n][2]);
|
|
810
|
-
if (t._emit("end", e._id), !t._webAudio && o && t.stop(e._id, !0).play(e._id), t._webAudio && o) {
|
|
811
|
-
t._emit("play", e._id), e._seek = e._start || 0, e._rateSeek = 0, e._playStart = r.ctx.currentTime;
|
|
812
|
-
var l = (e._stop - e._start) * 1e3 / Math.abs(e._rate);
|
|
813
|
-
t._endTimers[e._id] = setTimeout(t._ended.bind(t, e), l);
|
|
814
|
-
}
|
|
815
|
-
return t._webAudio && !o && (e._paused = !0, e._ended = !0, e._seek = e._start || 0, e._rateSeek = 0, t._clearTimer(e._id), t._cleanBuffer(e._node), r._autoSuspend()), !t._webAudio && !o && t.stop(e._id, !0), t;
|
|
816
|
-
},
|
|
817
|
-
/**
|
|
818
|
-
* Clear the end timer for a sound playback.
|
|
819
|
-
* @param {Number} id The sound ID.
|
|
820
|
-
* @return {Howl}
|
|
821
|
-
*/
|
|
822
|
-
_clearTimer: function(e) {
|
|
823
|
-
var t = this;
|
|
824
|
-
if (t._endTimers[e]) {
|
|
825
|
-
if (typeof t._endTimers[e] != "function")
|
|
826
|
-
clearTimeout(t._endTimers[e]);
|
|
827
|
-
else {
|
|
828
|
-
var n = t._soundById(e);
|
|
829
|
-
n && n._node && n._node.removeEventListener("ended", t._endTimers[e], !1);
|
|
830
|
-
}
|
|
831
|
-
delete t._endTimers[e];
|
|
832
|
-
}
|
|
833
|
-
return t;
|
|
834
|
-
},
|
|
835
|
-
/**
|
|
836
|
-
* Return the sound identified by this ID, or return null.
|
|
837
|
-
* @param {Number} id Sound ID
|
|
838
|
-
* @return {Object} Sound object or null.
|
|
839
|
-
*/
|
|
840
|
-
_soundById: function(e) {
|
|
841
|
-
for (var t = this, n = 0; n < t._sounds.length; n++)
|
|
842
|
-
if (e === t._sounds[n]._id)
|
|
843
|
-
return t._sounds[n];
|
|
844
|
-
return null;
|
|
845
|
-
},
|
|
846
|
-
/**
|
|
847
|
-
* Return an inactive sound from the pool or create a new one.
|
|
848
|
-
* @return {Sound} Sound playback object.
|
|
849
|
-
*/
|
|
850
|
-
_inactiveSound: function() {
|
|
851
|
-
var e = this;
|
|
852
|
-
e._drain();
|
|
853
|
-
for (var t = 0; t < e._sounds.length; t++)
|
|
854
|
-
if (e._sounds[t]._ended)
|
|
855
|
-
return e._sounds[t].reset();
|
|
856
|
-
return new i(e);
|
|
857
|
-
},
|
|
858
|
-
/**
|
|
859
|
-
* Drain excess inactive sounds from the pool.
|
|
860
|
-
*/
|
|
861
|
-
_drain: function() {
|
|
862
|
-
var e = this, t = e._pool, n = 0, o = 0;
|
|
863
|
-
if (!(e._sounds.length < t)) {
|
|
864
|
-
for (o = 0; o < e._sounds.length; o++)
|
|
865
|
-
e._sounds[o]._ended && n++;
|
|
866
|
-
for (o = e._sounds.length - 1; o >= 0; o--) {
|
|
867
|
-
if (n <= t)
|
|
868
|
-
return;
|
|
869
|
-
e._sounds[o]._ended && (e._webAudio && e._sounds[o]._node && e._sounds[o]._node.disconnect(0), e._sounds.splice(o, 1), n--);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
/**
|
|
874
|
-
* Get all ID's from the sounds pool.
|
|
875
|
-
* @param {Number} id Only return one ID if one is passed.
|
|
876
|
-
* @return {Array} Array of IDs.
|
|
877
|
-
*/
|
|
878
|
-
_getSoundIds: function(e) {
|
|
879
|
-
var t = this;
|
|
880
|
-
if (typeof e > "u") {
|
|
881
|
-
for (var n = [], o = 0; o < t._sounds.length; o++)
|
|
882
|
-
n.push(t._sounds[o]._id);
|
|
883
|
-
return n;
|
|
884
|
-
} else
|
|
885
|
-
return [e];
|
|
886
|
-
},
|
|
887
|
-
/**
|
|
888
|
-
* Load the sound back into the buffer source.
|
|
889
|
-
* @param {Sound} sound The sound object to work with.
|
|
890
|
-
* @return {Howl}
|
|
891
|
-
*/
|
|
892
|
-
_refreshBuffer: function(e) {
|
|
893
|
-
var t = this;
|
|
894
|
-
return e._node.bufferSource = r.ctx.createBufferSource(), e._node.bufferSource.buffer = d[t._src], e._panner ? e._node.bufferSource.connect(e._panner) : e._node.bufferSource.connect(e._node), e._node.bufferSource.loop = e._loop, e._loop && (e._node.bufferSource.loopStart = e._start || 0, e._node.bufferSource.loopEnd = e._stop || 0), e._node.bufferSource.playbackRate.setValueAtTime(e._rate, r.ctx.currentTime), t;
|
|
895
|
-
},
|
|
896
|
-
/**
|
|
897
|
-
* Prevent memory leaks by cleaning up the buffer source after playback.
|
|
898
|
-
* @param {Object} node Sound's audio node containing the buffer source.
|
|
899
|
-
* @return {Howl}
|
|
900
|
-
*/
|
|
901
|
-
_cleanBuffer: function(e) {
|
|
902
|
-
var t = this, n = r._navigator && r._navigator.vendor.indexOf("Apple") >= 0;
|
|
903
|
-
if (!e.bufferSource)
|
|
904
|
-
return t;
|
|
905
|
-
if (r._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), n))
|
|
906
|
-
try {
|
|
907
|
-
e.bufferSource.buffer = r._scratchBuffer;
|
|
908
|
-
} catch {
|
|
909
|
-
}
|
|
910
|
-
return e.bufferSource = null, t;
|
|
911
|
-
},
|
|
912
|
-
/**
|
|
913
|
-
* Set the source to a 0-second silence to stop any downloading (except in IE).
|
|
914
|
-
* @param {Object} node Audio node to clear.
|
|
915
|
-
*/
|
|
916
|
-
_clearSound: function(e) {
|
|
917
|
-
var t = /MSIE |Trident\//.test(r._navigator && r._navigator.userAgent);
|
|
918
|
-
t || (e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA");
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
var i = function(e) {
|
|
922
|
-
this._parent = e, this.init();
|
|
923
|
-
};
|
|
924
|
-
i.prototype = {
|
|
925
|
-
/**
|
|
926
|
-
* Initialize a new Sound object.
|
|
927
|
-
* @return {Sound}
|
|
928
|
-
*/
|
|
929
|
-
init: function() {
|
|
930
|
-
var e = this, t = e._parent;
|
|
931
|
-
return e._muted = t._muted, e._loop = t._loop, e._volume = t._volume, e._rate = t._rate, e._seek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, t._sounds.push(e), e.create(), e;
|
|
932
|
-
},
|
|
933
|
-
/**
|
|
934
|
-
* Create and setup a new sound object, whether HTML5 Audio or Web Audio.
|
|
935
|
-
* @return {Sound}
|
|
936
|
-
*/
|
|
937
|
-
create: function() {
|
|
938
|
-
var e = this, t = e._parent, n = r._muted || e._muted || e._parent._muted ? 0 : e._volume;
|
|
939
|
-
return t._webAudio ? (e._node = typeof r.ctx.createGain > "u" ? r.ctx.createGainNode() : r.ctx.createGain(), e._node.gain.setValueAtTime(n, r.ctx.currentTime), e._node.paused = !0, e._node.connect(r.masterGain)) : r.noAudio || (e._node = r._obtainHtml5Audio(), e._errorFn = e._errorListener.bind(e), e._node.addEventListener("error", e._errorFn, !1), e._loadFn = e._loadListener.bind(e), e._node.addEventListener(r._canPlayEvent, e._loadFn, !1), e._endFn = e._endListener.bind(e), e._node.addEventListener("ended", e._endFn, !1), e._node.src = t._src, e._node.preload = t._preload === !0 ? "auto" : t._preload, e._node.volume = n * r.volume(), e._node.load()), e;
|
|
940
|
-
},
|
|
941
|
-
/**
|
|
942
|
-
* Reset the parameters of this sound to the original state (for recycle).
|
|
943
|
-
* @return {Sound}
|
|
944
|
-
*/
|
|
945
|
-
reset: function() {
|
|
946
|
-
var e = this, t = e._parent;
|
|
947
|
-
return e._muted = t._muted, e._loop = t._loop, e._volume = t._volume, e._rate = t._rate, e._seek = 0, e._rateSeek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, e;
|
|
948
|
-
},
|
|
949
|
-
/**
|
|
950
|
-
* HTML5 Audio error listener callback.
|
|
951
|
-
*/
|
|
952
|
-
_errorListener: function() {
|
|
953
|
-
var e = this;
|
|
954
|
-
e._parent._emit("loaderror", e._id, e._node.error ? e._node.error.code : 0), e._node.removeEventListener("error", e._errorFn, !1);
|
|
955
|
-
},
|
|
956
|
-
/**
|
|
957
|
-
* HTML5 Audio canplaythrough listener callback.
|
|
958
|
-
*/
|
|
959
|
-
_loadListener: function() {
|
|
960
|
-
var e = this, t = e._parent;
|
|
961
|
-
t._duration = Math.ceil(e._node.duration * 10) / 10, Object.keys(t._sprite).length === 0 && (t._sprite = { __default: [0, t._duration * 1e3] }), t._state !== "loaded" && (t._state = "loaded", t._emit("load"), t._loadQueue()), e._node.removeEventListener(r._canPlayEvent, e._loadFn, !1);
|
|
962
|
-
},
|
|
963
|
-
/**
|
|
964
|
-
* HTML5 Audio ended listener callback.
|
|
965
|
-
*/
|
|
966
|
-
_endListener: function() {
|
|
967
|
-
var e = this, t = e._parent;
|
|
968
|
-
t._duration === 1 / 0 && (t._duration = Math.ceil(e._node.duration * 10) / 10, t._sprite.__default[1] === 1 / 0 && (t._sprite.__default[1] = t._duration * 1e3), t._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
var d = {}, c = function(e) {
|
|
972
|
-
var t = e._src;
|
|
973
|
-
if (d[t]) {
|
|
974
|
-
e._duration = d[t].duration, s(e);
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
if (/^data:[^;]+;base64,/.test(t)) {
|
|
978
|
-
for (var n = atob(t.split(",")[1]), o = new Uint8Array(n.length), l = 0; l < n.length; ++l)
|
|
979
|
-
o[l] = n.charCodeAt(l);
|
|
980
|
-
p(o.buffer, e);
|
|
981
|
-
} else {
|
|
982
|
-
var _ = new XMLHttpRequest();
|
|
983
|
-
_.open(e._xhr.method, t, !0), _.withCredentials = e._xhr.withCredentials, _.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(a) {
|
|
984
|
-
_.setRequestHeader(a, e._xhr.headers[a]);
|
|
985
|
-
}), _.onload = function() {
|
|
986
|
-
var a = (_.status + "")[0];
|
|
987
|
-
if (a !== "0" && a !== "2" && a !== "3") {
|
|
988
|
-
e._emit("loaderror", null, "Failed loading audio file with status: " + _.status + ".");
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
p(_.response, e);
|
|
992
|
-
}, _.onerror = function() {
|
|
993
|
-
e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete d[t], e.load());
|
|
994
|
-
}, h(_);
|
|
995
|
-
}
|
|
996
|
-
}, h = function(e) {
|
|
997
|
-
try {
|
|
998
|
-
e.send();
|
|
999
|
-
} catch {
|
|
1000
|
-
e.onerror();
|
|
1001
|
-
}
|
|
1002
|
-
}, p = function(e, t) {
|
|
1003
|
-
var n = function() {
|
|
1004
|
-
t._emit("loaderror", null, "Decoding audio data failed.");
|
|
1005
|
-
}, o = function(l) {
|
|
1006
|
-
l && t._sounds.length > 0 ? (d[t._src] = l, s(t, l)) : n();
|
|
1007
|
-
};
|
|
1008
|
-
typeof Promise < "u" && r.ctx.decodeAudioData.length === 1 ? r.ctx.decodeAudioData(e).then(o).catch(n) : r.ctx.decodeAudioData(e, o, n);
|
|
1009
|
-
}, s = function(e, t) {
|
|
1010
|
-
t && !e._duration && (e._duration = t.duration), Object.keys(e._sprite).length === 0 && (e._sprite = { __default: [0, e._duration * 1e3] }), e._state !== "loaded" && (e._state = "loaded", e._emit("load"), e._loadQueue());
|
|
1011
|
-
}, A = function() {
|
|
1012
|
-
if (r.usingWebAudio) {
|
|
1013
|
-
try {
|
|
1014
|
-
typeof AudioContext < "u" ? r.ctx = new AudioContext() : typeof webkitAudioContext < "u" ? r.ctx = new webkitAudioContext() : r.usingWebAudio = !1;
|
|
1015
|
-
} catch {
|
|
1016
|
-
r.usingWebAudio = !1;
|
|
1017
|
-
}
|
|
1018
|
-
r.ctx || (r.usingWebAudio = !1);
|
|
1019
|
-
var e = /iP(hone|od|ad)/.test(r._navigator && r._navigator.platform), t = r._navigator && r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), n = t ? parseInt(t[1], 10) : null;
|
|
1020
|
-
if (e && n && n < 9) {
|
|
1021
|
-
var o = /safari/.test(r._navigator && r._navigator.userAgent.toLowerCase());
|
|
1022
|
-
r._navigator && !o && (r.usingWebAudio = !1);
|
|
1023
|
-
}
|
|
1024
|
-
r.usingWebAudio && (r.masterGain = typeof r.ctx.createGain > "u" ? r.ctx.createGainNode() : r.ctx.createGain(), r.masterGain.gain.setValueAtTime(r._muted ? 0 : r._volume, r.ctx.currentTime), r.masterGain.connect(r.ctx.destination)), r._setup();
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
g.Howler = r, g.Howl = u, typeof S < "u" ? (S.HowlerGlobal = w, S.Howler = r, S.Howl = u, S.Sound = i) : typeof window < "u" && (window.HowlerGlobal = w, window.Howler = r, window.Howl = u, window.Sound = i);
|
|
1028
|
-
})();
|
|
1029
|
-
/*!
|
|
1030
|
-
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
|
|
1031
|
-
*
|
|
1032
|
-
* howler.js v2.2.4
|
|
1033
|
-
* howlerjs.com
|
|
1034
|
-
*
|
|
1035
|
-
* (c) 2013-2020, James Simpson of GoldFire Studios
|
|
1036
|
-
* goldfirestudios.com
|
|
1037
|
-
*
|
|
1038
|
-
* MIT License
|
|
1039
|
-
*/
|
|
1040
|
-
(function() {
|
|
1041
|
-
HowlerGlobal.prototype._pos = [0, 0, 0], HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0], HowlerGlobal.prototype.stereo = function(r) {
|
|
1042
|
-
var u = this;
|
|
1043
|
-
if (!u.ctx || !u.ctx.listener)
|
|
1044
|
-
return u;
|
|
1045
|
-
for (var i = u._howls.length - 1; i >= 0; i--)
|
|
1046
|
-
u._howls[i].stereo(r);
|
|
1047
|
-
return u;
|
|
1048
|
-
}, HowlerGlobal.prototype.pos = function(r, u, i) {
|
|
1049
|
-
var d = this;
|
|
1050
|
-
if (!d.ctx || !d.ctx.listener)
|
|
1051
|
-
return d;
|
|
1052
|
-
if (u = typeof u != "number" ? d._pos[1] : u, i = typeof i != "number" ? d._pos[2] : i, typeof r == "number")
|
|
1053
|
-
d._pos = [r, u, i], typeof d.ctx.listener.positionX < "u" ? (d.ctx.listener.positionX.setTargetAtTime(d._pos[0], Howler.ctx.currentTime, 0.1), d.ctx.listener.positionY.setTargetAtTime(d._pos[1], Howler.ctx.currentTime, 0.1), d.ctx.listener.positionZ.setTargetAtTime(d._pos[2], Howler.ctx.currentTime, 0.1)) : d.ctx.listener.setPosition(d._pos[0], d._pos[1], d._pos[2]);
|
|
1054
|
-
else
|
|
1055
|
-
return d._pos;
|
|
1056
|
-
return d;
|
|
1057
|
-
}, HowlerGlobal.prototype.orientation = function(r, u, i, d, c, h) {
|
|
1058
|
-
var p = this;
|
|
1059
|
-
if (!p.ctx || !p.ctx.listener)
|
|
1060
|
-
return p;
|
|
1061
|
-
var s = p._orientation;
|
|
1062
|
-
if (u = typeof u != "number" ? s[1] : u, i = typeof i != "number" ? s[2] : i, d = typeof d != "number" ? s[3] : d, c = typeof c != "number" ? s[4] : c, h = typeof h != "number" ? s[5] : h, typeof r == "number")
|
|
1063
|
-
p._orientation = [r, u, i, d, c, h], typeof p.ctx.listener.forwardX < "u" ? (p.ctx.listener.forwardX.setTargetAtTime(r, Howler.ctx.currentTime, 0.1), p.ctx.listener.forwardY.setTargetAtTime(u, Howler.ctx.currentTime, 0.1), p.ctx.listener.forwardZ.setTargetAtTime(i, Howler.ctx.currentTime, 0.1), p.ctx.listener.upX.setTargetAtTime(d, Howler.ctx.currentTime, 0.1), p.ctx.listener.upY.setTargetAtTime(c, Howler.ctx.currentTime, 0.1), p.ctx.listener.upZ.setTargetAtTime(h, Howler.ctx.currentTime, 0.1)) : p.ctx.listener.setOrientation(r, u, i, d, c, h);
|
|
1064
|
-
else
|
|
1065
|
-
return s;
|
|
1066
|
-
return p;
|
|
1067
|
-
}, Howl.prototype.init = /* @__PURE__ */ function(r) {
|
|
1068
|
-
return function(u) {
|
|
1069
|
-
var i = this;
|
|
1070
|
-
return i._orientation = u.orientation || [1, 0, 0], i._stereo = u.stereo || null, i._pos = u.pos || null, i._pannerAttr = {
|
|
1071
|
-
coneInnerAngle: typeof u.coneInnerAngle < "u" ? u.coneInnerAngle : 360,
|
|
1072
|
-
coneOuterAngle: typeof u.coneOuterAngle < "u" ? u.coneOuterAngle : 360,
|
|
1073
|
-
coneOuterGain: typeof u.coneOuterGain < "u" ? u.coneOuterGain : 0,
|
|
1074
|
-
distanceModel: typeof u.distanceModel < "u" ? u.distanceModel : "inverse",
|
|
1075
|
-
maxDistance: typeof u.maxDistance < "u" ? u.maxDistance : 1e4,
|
|
1076
|
-
panningModel: typeof u.panningModel < "u" ? u.panningModel : "HRTF",
|
|
1077
|
-
refDistance: typeof u.refDistance < "u" ? u.refDistance : 1,
|
|
1078
|
-
rolloffFactor: typeof u.rolloffFactor < "u" ? u.rolloffFactor : 1
|
|
1079
|
-
}, i._onstereo = u.onstereo ? [{ fn: u.onstereo }] : [], i._onpos = u.onpos ? [{ fn: u.onpos }] : [], i._onorientation = u.onorientation ? [{ fn: u.onorientation }] : [], r.call(this, u);
|
|
1080
|
-
};
|
|
1081
|
-
}(Howl.prototype.init), Howl.prototype.stereo = function(r, u) {
|
|
1082
|
-
var i = this;
|
|
1083
|
-
if (!i._webAudio)
|
|
1084
|
-
return i;
|
|
1085
|
-
if (i._state !== "loaded")
|
|
1086
|
-
return i._queue.push({
|
|
1087
|
-
event: "stereo",
|
|
1088
|
-
action: function() {
|
|
1089
|
-
i.stereo(r, u);
|
|
1090
|
-
}
|
|
1091
|
-
}), i;
|
|
1092
|
-
var d = typeof Howler.ctx.createStereoPanner > "u" ? "spatial" : "stereo";
|
|
1093
|
-
if (typeof u > "u")
|
|
1094
|
-
if (typeof r == "number")
|
|
1095
|
-
i._stereo = r, i._pos = [r, 0, 0];
|
|
1096
|
-
else
|
|
1097
|
-
return i._stereo;
|
|
1098
|
-
for (var c = i._getSoundIds(u), h = 0; h < c.length; h++) {
|
|
1099
|
-
var p = i._soundById(c[h]);
|
|
1100
|
-
if (p)
|
|
1101
|
-
if (typeof r == "number")
|
|
1102
|
-
p._stereo = r, p._pos = [r, 0, 0], p._node && (p._pannerAttr.panningModel = "equalpower", (!p._panner || !p._panner.pan) && w(p, d), d === "spatial" ? typeof p._panner.positionX < "u" ? (p._panner.positionX.setValueAtTime(r, Howler.ctx.currentTime), p._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime), p._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime)) : p._panner.setPosition(r, 0, 0) : p._panner.pan.setValueAtTime(r, Howler.ctx.currentTime)), i._emit("stereo", p._id);
|
|
1103
|
-
else
|
|
1104
|
-
return p._stereo;
|
|
1105
|
-
}
|
|
1106
|
-
return i;
|
|
1107
|
-
}, Howl.prototype.pos = function(r, u, i, d) {
|
|
1108
|
-
var c = this;
|
|
1109
|
-
if (!c._webAudio)
|
|
1110
|
-
return c;
|
|
1111
|
-
if (c._state !== "loaded")
|
|
1112
|
-
return c._queue.push({
|
|
1113
|
-
event: "pos",
|
|
1114
|
-
action: function() {
|
|
1115
|
-
c.pos(r, u, i, d);
|
|
1116
|
-
}
|
|
1117
|
-
}), c;
|
|
1118
|
-
if (u = typeof u != "number" ? 0 : u, i = typeof i != "number" ? -0.5 : i, typeof d > "u")
|
|
1119
|
-
if (typeof r == "number")
|
|
1120
|
-
c._pos = [r, u, i];
|
|
1121
|
-
else
|
|
1122
|
-
return c._pos;
|
|
1123
|
-
for (var h = c._getSoundIds(d), p = 0; p < h.length; p++) {
|
|
1124
|
-
var s = c._soundById(h[p]);
|
|
1125
|
-
if (s)
|
|
1126
|
-
if (typeof r == "number")
|
|
1127
|
-
s._pos = [r, u, i], s._node && ((!s._panner || s._panner.pan) && w(s, "spatial"), typeof s._panner.positionX < "u" ? (s._panner.positionX.setValueAtTime(r, Howler.ctx.currentTime), s._panner.positionY.setValueAtTime(u, Howler.ctx.currentTime), s._panner.positionZ.setValueAtTime(i, Howler.ctx.currentTime)) : s._panner.setPosition(r, u, i)), c._emit("pos", s._id);
|
|
1128
|
-
else
|
|
1129
|
-
return s._pos;
|
|
1130
|
-
}
|
|
1131
|
-
return c;
|
|
1132
|
-
}, Howl.prototype.orientation = function(r, u, i, d) {
|
|
1133
|
-
var c = this;
|
|
1134
|
-
if (!c._webAudio)
|
|
1135
|
-
return c;
|
|
1136
|
-
if (c._state !== "loaded")
|
|
1137
|
-
return c._queue.push({
|
|
1138
|
-
event: "orientation",
|
|
1139
|
-
action: function() {
|
|
1140
|
-
c.orientation(r, u, i, d);
|
|
1141
|
-
}
|
|
1142
|
-
}), c;
|
|
1143
|
-
if (u = typeof u != "number" ? c._orientation[1] : u, i = typeof i != "number" ? c._orientation[2] : i, typeof d > "u")
|
|
1144
|
-
if (typeof r == "number")
|
|
1145
|
-
c._orientation = [r, u, i];
|
|
1146
|
-
else
|
|
1147
|
-
return c._orientation;
|
|
1148
|
-
for (var h = c._getSoundIds(d), p = 0; p < h.length; p++) {
|
|
1149
|
-
var s = c._soundById(h[p]);
|
|
1150
|
-
if (s)
|
|
1151
|
-
if (typeof r == "number")
|
|
1152
|
-
s._orientation = [r, u, i], s._node && (s._panner || (s._pos || (s._pos = c._pos || [0, 0, -0.5]), w(s, "spatial")), typeof s._panner.orientationX < "u" ? (s._panner.orientationX.setValueAtTime(r, Howler.ctx.currentTime), s._panner.orientationY.setValueAtTime(u, Howler.ctx.currentTime), s._panner.orientationZ.setValueAtTime(i, Howler.ctx.currentTime)) : s._panner.setOrientation(r, u, i)), c._emit("orientation", s._id);
|
|
1153
|
-
else
|
|
1154
|
-
return s._orientation;
|
|
1155
|
-
}
|
|
1156
|
-
return c;
|
|
1157
|
-
}, Howl.prototype.pannerAttr = function() {
|
|
1158
|
-
var r = this, u = arguments, i, d, c;
|
|
1159
|
-
if (!r._webAudio)
|
|
1160
|
-
return r;
|
|
1161
|
-
if (u.length === 0)
|
|
1162
|
-
return r._pannerAttr;
|
|
1163
|
-
if (u.length === 1)
|
|
1164
|
-
if (typeof u[0] == "object")
|
|
1165
|
-
i = u[0], typeof d > "u" && (i.pannerAttr || (i.pannerAttr = {
|
|
1166
|
-
coneInnerAngle: i.coneInnerAngle,
|
|
1167
|
-
coneOuterAngle: i.coneOuterAngle,
|
|
1168
|
-
coneOuterGain: i.coneOuterGain,
|
|
1169
|
-
distanceModel: i.distanceModel,
|
|
1170
|
-
maxDistance: i.maxDistance,
|
|
1171
|
-
refDistance: i.refDistance,
|
|
1172
|
-
rolloffFactor: i.rolloffFactor,
|
|
1173
|
-
panningModel: i.panningModel
|
|
1174
|
-
}), r._pannerAttr = {
|
|
1175
|
-
coneInnerAngle: typeof i.pannerAttr.coneInnerAngle < "u" ? i.pannerAttr.coneInnerAngle : r._coneInnerAngle,
|
|
1176
|
-
coneOuterAngle: typeof i.pannerAttr.coneOuterAngle < "u" ? i.pannerAttr.coneOuterAngle : r._coneOuterAngle,
|
|
1177
|
-
coneOuterGain: typeof i.pannerAttr.coneOuterGain < "u" ? i.pannerAttr.coneOuterGain : r._coneOuterGain,
|
|
1178
|
-
distanceModel: typeof i.pannerAttr.distanceModel < "u" ? i.pannerAttr.distanceModel : r._distanceModel,
|
|
1179
|
-
maxDistance: typeof i.pannerAttr.maxDistance < "u" ? i.pannerAttr.maxDistance : r._maxDistance,
|
|
1180
|
-
refDistance: typeof i.pannerAttr.refDistance < "u" ? i.pannerAttr.refDistance : r._refDistance,
|
|
1181
|
-
rolloffFactor: typeof i.pannerAttr.rolloffFactor < "u" ? i.pannerAttr.rolloffFactor : r._rolloffFactor,
|
|
1182
|
-
panningModel: typeof i.pannerAttr.panningModel < "u" ? i.pannerAttr.panningModel : r._panningModel
|
|
1183
|
-
});
|
|
1184
|
-
else
|
|
1185
|
-
return c = r._soundById(parseInt(u[0], 10)), c ? c._pannerAttr : r._pannerAttr;
|
|
1186
|
-
else u.length === 2 && (i = u[0], d = parseInt(u[1], 10));
|
|
1187
|
-
for (var h = r._getSoundIds(d), p = 0; p < h.length; p++)
|
|
1188
|
-
if (c = r._soundById(h[p]), c) {
|
|
1189
|
-
var s = c._pannerAttr;
|
|
1190
|
-
s = {
|
|
1191
|
-
coneInnerAngle: typeof i.coneInnerAngle < "u" ? i.coneInnerAngle : s.coneInnerAngle,
|
|
1192
|
-
coneOuterAngle: typeof i.coneOuterAngle < "u" ? i.coneOuterAngle : s.coneOuterAngle,
|
|
1193
|
-
coneOuterGain: typeof i.coneOuterGain < "u" ? i.coneOuterGain : s.coneOuterGain,
|
|
1194
|
-
distanceModel: typeof i.distanceModel < "u" ? i.distanceModel : s.distanceModel,
|
|
1195
|
-
maxDistance: typeof i.maxDistance < "u" ? i.maxDistance : s.maxDistance,
|
|
1196
|
-
refDistance: typeof i.refDistance < "u" ? i.refDistance : s.refDistance,
|
|
1197
|
-
rolloffFactor: typeof i.rolloffFactor < "u" ? i.rolloffFactor : s.rolloffFactor,
|
|
1198
|
-
panningModel: typeof i.panningModel < "u" ? i.panningModel : s.panningModel
|
|
1199
|
-
};
|
|
1200
|
-
var A = c._panner;
|
|
1201
|
-
A || (c._pos || (c._pos = r._pos || [0, 0, -0.5]), w(c, "spatial"), A = c._panner), A.coneInnerAngle = s.coneInnerAngle, A.coneOuterAngle = s.coneOuterAngle, A.coneOuterGain = s.coneOuterGain, A.distanceModel = s.distanceModel, A.maxDistance = s.maxDistance, A.refDistance = s.refDistance, A.rolloffFactor = s.rolloffFactor, A.panningModel = s.panningModel;
|
|
1202
|
-
}
|
|
1203
|
-
return r;
|
|
1204
|
-
}, Sound.prototype.init = /* @__PURE__ */ function(r) {
|
|
1205
|
-
return function() {
|
|
1206
|
-
var u = this, i = u._parent;
|
|
1207
|
-
u._orientation = i._orientation, u._stereo = i._stereo, u._pos = i._pos, u._pannerAttr = i._pannerAttr, r.call(this), u._stereo ? i.stereo(u._stereo) : u._pos && i.pos(u._pos[0], u._pos[1], u._pos[2], u._id);
|
|
1208
|
-
};
|
|
1209
|
-
}(Sound.prototype.init), Sound.prototype.reset = /* @__PURE__ */ function(r) {
|
|
1210
|
-
return function() {
|
|
1211
|
-
var u = this, i = u._parent;
|
|
1212
|
-
return u._orientation = i._orientation, u._stereo = i._stereo, u._pos = i._pos, u._pannerAttr = i._pannerAttr, u._stereo ? i.stereo(u._stereo) : u._pos ? i.pos(u._pos[0], u._pos[1], u._pos[2], u._id) : u._panner && (u._panner.disconnect(0), u._panner = void 0, i._refreshBuffer(u)), r.call(this);
|
|
1213
|
-
};
|
|
1214
|
-
}(Sound.prototype.reset);
|
|
1215
|
-
var w = function(r, u) {
|
|
1216
|
-
u = u || "spatial", u === "spatial" ? (r._panner = Howler.ctx.createPanner(), r._panner.coneInnerAngle = r._pannerAttr.coneInnerAngle, r._panner.coneOuterAngle = r._pannerAttr.coneOuterAngle, r._panner.coneOuterGain = r._pannerAttr.coneOuterGain, r._panner.distanceModel = r._pannerAttr.distanceModel, r._panner.maxDistance = r._pannerAttr.maxDistance, r._panner.refDistance = r._pannerAttr.refDistance, r._panner.rolloffFactor = r._pannerAttr.rolloffFactor, r._panner.panningModel = r._pannerAttr.panningModel, typeof r._panner.positionX < "u" ? (r._panner.positionX.setValueAtTime(r._pos[0], Howler.ctx.currentTime), r._panner.positionY.setValueAtTime(r._pos[1], Howler.ctx.currentTime), r._panner.positionZ.setValueAtTime(r._pos[2], Howler.ctx.currentTime)) : r._panner.setPosition(r._pos[0], r._pos[1], r._pos[2]), typeof r._panner.orientationX < "u" ? (r._panner.orientationX.setValueAtTime(r._orientation[0], Howler.ctx.currentTime), r._panner.orientationY.setValueAtTime(r._orientation[1], Howler.ctx.currentTime), r._panner.orientationZ.setValueAtTime(r._orientation[2], Howler.ctx.currentTime)) : r._panner.setOrientation(r._orientation[0], r._orientation[1], r._orientation[2])) : (r._panner = Howler.ctx.createStereoPanner(), r._panner.pan.setValueAtTime(r._stereo, Howler.ctx.currentTime)), r._panner.connect(r._node), r._paused || r._parent.pause(r._id, !0).play(r._id, !0);
|
|
1217
|
-
};
|
|
1218
|
-
})();
|
|
1219
|
-
})(O);
|
|
1220
|
-
const G = /* @__PURE__ */ D(O), E = /* @__PURE__ */ L({
|
|
1221
|
-
__proto__: null,
|
|
1222
|
-
default: G
|
|
1223
|
-
}, [O]);
|
|
1224
|
-
export {
|
|
1225
|
-
E as h
|
|
1226
|
-
};
|