magmastream 2.9.3-dev.2 → 2.9.3-dev.21
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/index.d.ts +196 -105
- package/dist/index.js +1 -1
- package/dist/statestorage/JsonQueue.js +28 -4
- package/dist/statestorage/MemoryQueue.js +51 -36
- package/dist/statestorage/RedisQueue.js +30 -9
- package/dist/structures/Enums.js +6 -0
- package/dist/structures/Filters.js +5 -4
- package/dist/structures/Manager.js +88 -71
- package/dist/structures/Node.js +91 -145
- package/dist/structures/Player.js +31 -124
- package/dist/structures/Rest.js +41 -21
- package/dist/structures/Utils.js +137 -76
- package/dist/wrappers/discord.js.js +19 -4
- package/dist/wrappers/discordeno.js +73 -0
- package/dist/wrappers/eris.js +20 -3
- package/dist/wrappers/oceanic.js +22 -4
- package/dist/wrappers/seyfert.js +25 -1
- package/package.json +30 -23
- package/dist/wrappers/detritus.js +0 -52
|
@@ -17,6 +17,10 @@ class JsonQueue {
|
|
|
17
17
|
* The base path for the queue files.
|
|
18
18
|
*/
|
|
19
19
|
basePath;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the queue has been destroyed.
|
|
22
|
+
*/
|
|
23
|
+
destroyed = false;
|
|
20
24
|
/**
|
|
21
25
|
* @param guildId The guild ID.
|
|
22
26
|
* @param manager The manager.
|
|
@@ -56,8 +60,7 @@ class JsonQueue {
|
|
|
56
60
|
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[JSONQUEUE] Added ${tracks.length} track(s) to queue`);
|
|
57
61
|
if (this.manager.players.has(this.guildId) && this.manager.players.get(this.guildId).isAutoplay) {
|
|
58
62
|
if (!isArray) {
|
|
59
|
-
|
|
60
|
-
if (AutoplayUser && AutoplayUser.id === track.requester.id) {
|
|
63
|
+
if (track.isAutoplay) {
|
|
61
64
|
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
62
65
|
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
63
66
|
details: {
|
|
@@ -173,6 +176,27 @@ class JsonQueue {
|
|
|
173
176
|
console.error(error);
|
|
174
177
|
}
|
|
175
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Destroys the queue and releases all resources.
|
|
181
|
+
* After calling this method, the queue must not be used again.
|
|
182
|
+
*/
|
|
183
|
+
async destroy() {
|
|
184
|
+
if (this.destroyed)
|
|
185
|
+
return;
|
|
186
|
+
this.destroyed = true;
|
|
187
|
+
try {
|
|
188
|
+
await Promise.all([this.deleteFile(this.queuePath), this.deleteFile(this.currentPath), this.deleteFile(this.previousPath)]);
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
console.error(err instanceof MagmastreamError_1.MagmaStreamError
|
|
192
|
+
? err
|
|
193
|
+
: new MagmastreamError_1.MagmaStreamError({
|
|
194
|
+
code: Enums_1.MagmaStreamErrorCode.QUEUE_JSON_ERROR,
|
|
195
|
+
message: `Failed to destroy JSONQueue for guild ${this.guildId}`,
|
|
196
|
+
cause: err,
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
176
200
|
/**
|
|
177
201
|
* @returns The total duration of the queue.
|
|
178
202
|
*/
|
|
@@ -349,7 +373,7 @@ class JsonQueue {
|
|
|
349
373
|
const queue = await this.getQueue();
|
|
350
374
|
const userMap = new Map();
|
|
351
375
|
for (const track of queue) {
|
|
352
|
-
const userId = track.requester.id;
|
|
376
|
+
const userId = track.requester.id.toString();
|
|
353
377
|
if (!userMap.has(userId))
|
|
354
378
|
userMap.set(userId, []);
|
|
355
379
|
userMap.get(userId).push(track);
|
|
@@ -474,7 +498,7 @@ class JsonQueue {
|
|
|
474
498
|
const queue = await this.getQueue();
|
|
475
499
|
const userMap = new Map();
|
|
476
500
|
for (const track of queue) {
|
|
477
|
-
const userId = track.requester.id;
|
|
501
|
+
const userId = track.requester.id.toString();
|
|
478
502
|
if (!userMap.has(userId))
|
|
479
503
|
userMap.set(userId, []);
|
|
480
504
|
userMap.get(userId).push(track);
|
|
@@ -16,6 +16,10 @@ class MemoryQueue extends Array {
|
|
|
16
16
|
manager;
|
|
17
17
|
/** The guild ID property. */
|
|
18
18
|
guildId;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the queue has been destroyed.
|
|
21
|
+
*/
|
|
22
|
+
destroyed = false;
|
|
19
23
|
/**
|
|
20
24
|
* Constructs a new Queue.
|
|
21
25
|
* @param guildId The guild ID.
|
|
@@ -34,7 +38,7 @@ class MemoryQueue extends Array {
|
|
|
34
38
|
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
35
39
|
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
36
40
|
*/
|
|
37
|
-
|
|
41
|
+
add(track, offset) {
|
|
38
42
|
try {
|
|
39
43
|
const isArray = Array.isArray(track);
|
|
40
44
|
const tracks = isArray ? [...track] : [track];
|
|
@@ -84,8 +88,7 @@ class MemoryQueue extends Array {
|
|
|
84
88
|
}
|
|
85
89
|
if (this.manager.players.has(this.guildId) && this.manager.players.get(this.guildId).isAutoplay) {
|
|
86
90
|
if (!isArray) {
|
|
87
|
-
|
|
88
|
-
if (AutoplayUser && AutoplayUser.id === track.requester.id) {
|
|
91
|
+
if (track.isAutoplay) {
|
|
89
92
|
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
90
93
|
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
91
94
|
details: {
|
|
@@ -123,7 +126,7 @@ class MemoryQueue extends Array {
|
|
|
123
126
|
* Adds a track to the previous tracks.
|
|
124
127
|
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
125
128
|
*/
|
|
126
|
-
|
|
129
|
+
addPrevious(track) {
|
|
127
130
|
try {
|
|
128
131
|
const max = this.manager.options.maxPreviousTracks;
|
|
129
132
|
if (Array.isArray(track)) {
|
|
@@ -155,7 +158,7 @@ class MemoryQueue extends Array {
|
|
|
155
158
|
* Clears the queue.
|
|
156
159
|
* This will remove all tracks from the queue and emit a state update event.
|
|
157
160
|
*/
|
|
158
|
-
|
|
161
|
+
clear() {
|
|
159
162
|
try {
|
|
160
163
|
// Capture the current state of the player for event emission.
|
|
161
164
|
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
@@ -187,20 +190,32 @@ class MemoryQueue extends Array {
|
|
|
187
190
|
/**
|
|
188
191
|
* Clears the previous tracks.
|
|
189
192
|
*/
|
|
190
|
-
|
|
193
|
+
clearPrevious() {
|
|
191
194
|
this.previous = [];
|
|
192
195
|
}
|
|
193
196
|
/**
|
|
194
197
|
* Removes the first element from the queue.
|
|
195
198
|
*/
|
|
196
|
-
|
|
199
|
+
dequeue() {
|
|
197
200
|
return super.shift();
|
|
198
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Destroys the queue and releases all resources.
|
|
204
|
+
* After calling this method, the queue must not be used again.
|
|
205
|
+
*/
|
|
206
|
+
destroy() {
|
|
207
|
+
if (this.destroyed)
|
|
208
|
+
return;
|
|
209
|
+
this.destroyed = true;
|
|
210
|
+
this.splice(0);
|
|
211
|
+
this.previous.length = 0;
|
|
212
|
+
this.current = null;
|
|
213
|
+
}
|
|
199
214
|
/**
|
|
200
215
|
* The total duration of the queue in milliseconds.
|
|
201
216
|
* This includes the duration of the currently playing track.
|
|
202
217
|
*/
|
|
203
|
-
|
|
218
|
+
duration() {
|
|
204
219
|
const current = this.current?.duration ?? 0;
|
|
205
220
|
return this.reduce((acc, cur) => acc + (cur.duration || 0), current);
|
|
206
221
|
}
|
|
@@ -208,7 +223,7 @@ class MemoryQueue extends Array {
|
|
|
208
223
|
* Adds the specified track or tracks to the front of the queue.
|
|
209
224
|
* @param track The track or tracks to add.
|
|
210
225
|
*/
|
|
211
|
-
|
|
226
|
+
enqueueFront(track) {
|
|
212
227
|
if (Array.isArray(track)) {
|
|
213
228
|
this.unshift(...track);
|
|
214
229
|
}
|
|
@@ -219,49 +234,49 @@ class MemoryQueue extends Array {
|
|
|
219
234
|
/**
|
|
220
235
|
* @returns Whether all elements in the queue satisfy the provided testing function.
|
|
221
236
|
*/
|
|
222
|
-
|
|
237
|
+
everyAsync(callback) {
|
|
223
238
|
return this.every(callback);
|
|
224
239
|
}
|
|
225
240
|
/**
|
|
226
241
|
* @returns A new array with all elements that pass the test implemented by the provided function.
|
|
227
242
|
*/
|
|
228
|
-
|
|
243
|
+
filterAsync(callback) {
|
|
229
244
|
return this.filter(callback);
|
|
230
245
|
}
|
|
231
246
|
/**
|
|
232
247
|
* @returns The first element in the queue that satisfies the provided testing function.
|
|
233
248
|
*/
|
|
234
|
-
|
|
249
|
+
findAsync(callback) {
|
|
235
250
|
return this.find(callback);
|
|
236
251
|
}
|
|
237
252
|
/**
|
|
238
253
|
* @returns The current track.
|
|
239
254
|
*/
|
|
240
|
-
|
|
255
|
+
getCurrent() {
|
|
241
256
|
return this.current;
|
|
242
257
|
}
|
|
243
258
|
/**
|
|
244
259
|
* @returns The previous tracks.
|
|
245
260
|
*/
|
|
246
|
-
|
|
261
|
+
getPrevious() {
|
|
247
262
|
return [...this.previous];
|
|
248
263
|
}
|
|
249
264
|
/**
|
|
250
265
|
* @returns The tracks in the queue from start to end.
|
|
251
266
|
*/
|
|
252
|
-
|
|
267
|
+
getSlice(start, end) {
|
|
253
268
|
return this.slice(start, end); // Native sync method, still wrapped in a Promise
|
|
254
269
|
}
|
|
255
270
|
/**
|
|
256
271
|
* @returns The tracks in the queue.
|
|
257
272
|
*/
|
|
258
|
-
|
|
273
|
+
getTracks() {
|
|
259
274
|
return [...this]; // clone to avoid direct mutation
|
|
260
275
|
}
|
|
261
276
|
/**
|
|
262
277
|
* @returns A new array with the results of calling a provided function on every element in the queue.
|
|
263
278
|
*/
|
|
264
|
-
|
|
279
|
+
mapAsync(callback) {
|
|
265
280
|
return this.map(callback);
|
|
266
281
|
}
|
|
267
282
|
/**
|
|
@@ -271,16 +286,16 @@ class MemoryQueue extends Array {
|
|
|
271
286
|
* @param items The elements to add to the queue.
|
|
272
287
|
* @returns The modified queue.
|
|
273
288
|
*/
|
|
274
|
-
|
|
289
|
+
modifyAt(start, deleteCount = 0, ...items) {
|
|
275
290
|
return super.splice(start, deleteCount, ...items);
|
|
276
291
|
}
|
|
277
292
|
/**
|
|
278
293
|
* @returns The newest track.
|
|
279
294
|
*/
|
|
280
|
-
|
|
295
|
+
popPrevious() {
|
|
281
296
|
return this.previous.pop() || null; // get newest track
|
|
282
297
|
}
|
|
283
|
-
|
|
298
|
+
remove(startOrPosition = 0, end) {
|
|
284
299
|
try {
|
|
285
300
|
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
286
301
|
if (typeof end !== "undefined") {
|
|
@@ -332,7 +347,7 @@ class MemoryQueue extends Array {
|
|
|
332
347
|
/**
|
|
333
348
|
* Shuffles the queue to play tracks requested by each user one by one.
|
|
334
349
|
*/
|
|
335
|
-
|
|
350
|
+
roundRobinShuffle() {
|
|
336
351
|
try {
|
|
337
352
|
// Capture the current state of the player for event emission.
|
|
338
353
|
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
@@ -340,11 +355,11 @@ class MemoryQueue extends Array {
|
|
|
340
355
|
const userTracks = new Map();
|
|
341
356
|
// Group the tracks in the queue by the user that requested them.
|
|
342
357
|
this.forEach((track) => {
|
|
343
|
-
const
|
|
344
|
-
if (!userTracks.has(
|
|
345
|
-
userTracks.set(
|
|
358
|
+
const userId = track.requester.id.toString();
|
|
359
|
+
if (!userTracks.has(userId)) {
|
|
360
|
+
userTracks.set(userId, []);
|
|
346
361
|
}
|
|
347
|
-
userTracks.get(
|
|
362
|
+
userTracks.get(userId).push(track);
|
|
348
363
|
});
|
|
349
364
|
// Shuffle the tracks of each user.
|
|
350
365
|
userTracks.forEach((tracks) => {
|
|
@@ -395,20 +410,20 @@ class MemoryQueue extends Array {
|
|
|
395
410
|
/**
|
|
396
411
|
* @param track The track to set.
|
|
397
412
|
*/
|
|
398
|
-
|
|
413
|
+
setCurrent(track) {
|
|
399
414
|
this.current = track;
|
|
400
415
|
}
|
|
401
416
|
/**
|
|
402
417
|
* @param tracks The tracks to set.
|
|
403
418
|
*/
|
|
404
|
-
|
|
419
|
+
setPrevious(tracks) {
|
|
405
420
|
this.previous = [...tracks];
|
|
406
421
|
}
|
|
407
422
|
/**
|
|
408
423
|
* Shuffles the queue.
|
|
409
424
|
* This will randomize the order of the tracks in the queue and emit a state update event.
|
|
410
425
|
*/
|
|
411
|
-
|
|
426
|
+
shuffle() {
|
|
412
427
|
try {
|
|
413
428
|
// Capture the current state of the player for event emission.
|
|
414
429
|
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
@@ -444,13 +459,13 @@ class MemoryQueue extends Array {
|
|
|
444
459
|
* This does not include the currently playing track.
|
|
445
460
|
* @returns The size of tracks in the queue.
|
|
446
461
|
*/
|
|
447
|
-
|
|
462
|
+
size() {
|
|
448
463
|
return this.length;
|
|
449
464
|
}
|
|
450
465
|
/**
|
|
451
466
|
* @returns Whether at least one element in the queue satisfies the provided testing function.
|
|
452
467
|
*/
|
|
453
|
-
|
|
468
|
+
someAsync(callback) {
|
|
454
469
|
return this.some(callback);
|
|
455
470
|
}
|
|
456
471
|
/**
|
|
@@ -458,24 +473,24 @@ class MemoryQueue extends Array {
|
|
|
458
473
|
* This includes the current track if it is not null.
|
|
459
474
|
* @returns The total size of tracks in the queue including the current track.
|
|
460
475
|
*/
|
|
461
|
-
|
|
476
|
+
totalSize() {
|
|
462
477
|
return this.length + (this.current ? 1 : 0);
|
|
463
478
|
}
|
|
464
479
|
/**
|
|
465
480
|
* Shuffles the queue to play tracks requested by each user one block at a time.
|
|
466
481
|
*/
|
|
467
|
-
|
|
482
|
+
userBlockShuffle() {
|
|
468
483
|
try {
|
|
469
484
|
// Capture the current state of the player for event emission.
|
|
470
485
|
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
471
486
|
// Group the tracks in the queue by the user that requested them.
|
|
472
487
|
const userTracks = new Map();
|
|
473
488
|
this.forEach((track) => {
|
|
474
|
-
const
|
|
475
|
-
if (!userTracks.has(
|
|
476
|
-
userTracks.set(
|
|
489
|
+
const userId = track.requester.id.toString();
|
|
490
|
+
if (!userTracks.has(userId)) {
|
|
491
|
+
userTracks.set(userId, []);
|
|
477
492
|
}
|
|
478
|
-
userTracks.get(
|
|
493
|
+
userTracks.get(userId).push(track);
|
|
479
494
|
});
|
|
480
495
|
// Create a new array for the shuffled queue.
|
|
481
496
|
const shuffledQueue = [];
|
|
@@ -18,6 +18,10 @@ class RedisQueue {
|
|
|
18
18
|
* The Redis instance.
|
|
19
19
|
*/
|
|
20
20
|
redis;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the queue has been destroyed.
|
|
23
|
+
*/
|
|
24
|
+
destroyed = false;
|
|
21
25
|
/**
|
|
22
26
|
* Constructs a new RedisQueue.
|
|
23
27
|
* @param guildId The guild ID.
|
|
@@ -27,11 +31,7 @@ class RedisQueue {
|
|
|
27
31
|
this.guildId = guildId;
|
|
28
32
|
this.manager = manager;
|
|
29
33
|
this.redis = manager.redis;
|
|
30
|
-
|
|
31
|
-
let clean = typeof rawPrefix === "string" ? rawPrefix.trim() : "";
|
|
32
|
-
if (!clean.endsWith(":"))
|
|
33
|
-
clean = clean || "magmastream";
|
|
34
|
-
this.redisPrefix = `${clean}:`;
|
|
34
|
+
this.redisPrefix = Utils_1.PlayerUtils.getRedisKey();
|
|
35
35
|
}
|
|
36
36
|
// #region Public
|
|
37
37
|
/**
|
|
@@ -81,8 +81,7 @@ class RedisQueue {
|
|
|
81
81
|
// Autoplay logic
|
|
82
82
|
if (this.manager.players.has(this.guildId) && this.manager.players.get(this.guildId).isAutoplay) {
|
|
83
83
|
if (!Array.isArray(track)) {
|
|
84
|
-
|
|
85
|
-
if (AutoplayUser && AutoplayUser.id === track.requester.id) {
|
|
84
|
+
if (track.isAutoplay) {
|
|
86
85
|
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
87
86
|
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
88
87
|
details: {
|
|
@@ -223,6 +222,28 @@ class RedisQueue {
|
|
|
223
222
|
console.error(error);
|
|
224
223
|
}
|
|
225
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Destroys the queue and releases all resources.
|
|
227
|
+
* After calling this method, the queue must not be used again.
|
|
228
|
+
*/
|
|
229
|
+
async destroy() {
|
|
230
|
+
if (this.destroyed)
|
|
231
|
+
return;
|
|
232
|
+
this.destroyed = true;
|
|
233
|
+
try {
|
|
234
|
+
await this.redis.del(this.queueKey, this.previousKey, this.currentKey);
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
const error = err instanceof MagmastreamError_1.MagmaStreamError
|
|
238
|
+
? err
|
|
239
|
+
: new MagmastreamError_1.MagmaStreamError({
|
|
240
|
+
code: Enums_1.MagmaStreamErrorCode.QUEUE_REDIS_ERROR,
|
|
241
|
+
message: `Failed to destroy RedisQueue for guild ${this.guildId}: ${err.message}`,
|
|
242
|
+
cause: err,
|
|
243
|
+
});
|
|
244
|
+
console.error(error);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
226
247
|
/**
|
|
227
248
|
* @returns The total duration of the queue in milliseconds.
|
|
228
249
|
* This includes the duration of the currently playing track.
|
|
@@ -488,7 +509,7 @@ class RedisQueue {
|
|
|
488
509
|
const deserialized = rawTracks.map(this.deserialize);
|
|
489
510
|
const userMap = new Map();
|
|
490
511
|
for (const track of deserialized) {
|
|
491
|
-
const userId = track.requester.id;
|
|
512
|
+
const userId = track.requester.id.toString();
|
|
492
513
|
if (!userMap.has(userId))
|
|
493
514
|
userMap.set(userId, []);
|
|
494
515
|
userMap.get(userId).push(track);
|
|
@@ -659,7 +680,7 @@ class RedisQueue {
|
|
|
659
680
|
const deserialized = rawTracks.map(this.deserialize);
|
|
660
681
|
const userMap = new Map();
|
|
661
682
|
for (const track of deserialized) {
|
|
662
|
-
const userId = track.requester.id;
|
|
683
|
+
const userId = track.requester.id.toString();
|
|
663
684
|
if (!userMap.has(userId))
|
|
664
685
|
userMap.set(userId, []);
|
|
665
686
|
userMap.get(userId).push(track);
|
package/dist/structures/Enums.js
CHANGED
|
@@ -163,6 +163,8 @@ var TrackPartial;
|
|
|
163
163
|
TrackPartial["PluginInfo"] = "pluginInfo";
|
|
164
164
|
/** The custom data of the track */
|
|
165
165
|
TrackPartial["CustomData"] = "customData";
|
|
166
|
+
/** Whether the track got autoplayed */
|
|
167
|
+
TrackPartial["IsAutoPlay"] = "isAutoplay";
|
|
166
168
|
})(TrackPartial || (exports.TrackPartial = TrackPartial = {}));
|
|
167
169
|
/**
|
|
168
170
|
* Manager Event Types Enum
|
|
@@ -283,6 +285,7 @@ var MagmaStreamErrorCode;
|
|
|
283
285
|
MagmaStreamErrorCode["GENERAL_UNKNOWN"] = "MS_GENERAL_UNKNOWN";
|
|
284
286
|
MagmaStreamErrorCode["GENERAL_TIMEOUT"] = "MS_GENERAL_TIMEOUT";
|
|
285
287
|
MagmaStreamErrorCode["GENERAL_INVALID_MANAGER"] = "MS_GENERAL_INVALID_MANAGER";
|
|
288
|
+
MagmaStreamErrorCode["INTENT_MISSING"] = "MS_INTENT_MISSING";
|
|
286
289
|
// MANAGER (1100)
|
|
287
290
|
MagmaStreamErrorCode["MANAGER_INIT_FAILED"] = "MS_MANAGER_INIT_FAILED";
|
|
288
291
|
MagmaStreamErrorCode["MANAGER_INVALID_CONFIG"] = "MS_MANAGER_INVALID_CONFIG";
|
|
@@ -326,6 +329,7 @@ var MagmaStreamErrorCode;
|
|
|
326
329
|
MagmaStreamErrorCode["UTILS_TRACK_PARTIAL_INVALID"] = "MS_UTILS_TRACK_PARTIAL_INVALID";
|
|
327
330
|
MagmaStreamErrorCode["UTILS_TRACK_BUILD_FAILED"] = "MS_UTILS_TRACK_BUILD_FAILED";
|
|
328
331
|
MagmaStreamErrorCode["UTILS_AUTOPLAY_BUILD_FAILED"] = "MS_UTILS_AUTOPLAY_BUILD_FAILED";
|
|
332
|
+
MagmaStreamErrorCode["UTILS_PLAYER_SERIALIZE_FAILED"] = "MS_UTILS_PLAYER_SERIALIZE_FAILED";
|
|
329
333
|
// PLUGIN (1800)
|
|
330
334
|
MagmaStreamErrorCode["PLUGIN_LOAD_FAILED"] = "MS_PLUGIN_LOAD_FAILED";
|
|
331
335
|
MagmaStreamErrorCode["PLUGIN_RUNTIME_ERROR"] = "MS_PLUGIN_RUNTIME_ERROR";
|
|
@@ -336,6 +340,7 @@ exports.MagmaStreamErrorNumbers = {
|
|
|
336
340
|
[MagmaStreamErrorCode.GENERAL_UNKNOWN]: 1000,
|
|
337
341
|
[MagmaStreamErrorCode.GENERAL_TIMEOUT]: 1001,
|
|
338
342
|
[MagmaStreamErrorCode.GENERAL_INVALID_MANAGER]: 1002,
|
|
343
|
+
[MagmaStreamErrorCode.INTENT_MISSING]: 1003,
|
|
339
344
|
// MANAGER
|
|
340
345
|
[MagmaStreamErrorCode.MANAGER_INIT_FAILED]: 1100,
|
|
341
346
|
[MagmaStreamErrorCode.MANAGER_INVALID_CONFIG]: 1101,
|
|
@@ -379,6 +384,7 @@ exports.MagmaStreamErrorNumbers = {
|
|
|
379
384
|
[MagmaStreamErrorCode.UTILS_TRACK_PARTIAL_INVALID]: 1700,
|
|
380
385
|
[MagmaStreamErrorCode.UTILS_TRACK_BUILD_FAILED]: 1701,
|
|
381
386
|
[MagmaStreamErrorCode.UTILS_AUTOPLAY_BUILD_FAILED]: 1702,
|
|
387
|
+
[MagmaStreamErrorCode.UTILS_PLAYER_SERIALIZE_FAILED]: 1703,
|
|
382
388
|
// PLUGIN
|
|
383
389
|
[MagmaStreamErrorCode.PLUGIN_LOAD_FAILED]: 1800,
|
|
384
390
|
[MagmaStreamErrorCode.PLUGIN_RUNTIME_ERROR]: 1801,
|
|
@@ -8,8 +8,6 @@ class Filters {
|
|
|
8
8
|
distortion;
|
|
9
9
|
equalizer;
|
|
10
10
|
karaoke;
|
|
11
|
-
manager;
|
|
12
|
-
player;
|
|
13
11
|
rotation;
|
|
14
12
|
timescale;
|
|
15
13
|
vibrato;
|
|
@@ -17,15 +15,16 @@ class Filters {
|
|
|
17
15
|
volume;
|
|
18
16
|
bassBoostlevel;
|
|
19
17
|
filtersStatus;
|
|
18
|
+
manager;
|
|
19
|
+
player;
|
|
20
20
|
constructor(player, manager) {
|
|
21
21
|
this.distortion = null;
|
|
22
22
|
this.equalizer = [];
|
|
23
23
|
this.karaoke = null;
|
|
24
|
-
this.manager = manager;
|
|
25
|
-
this.player = player;
|
|
26
24
|
this.rotation = null;
|
|
27
25
|
this.timescale = null;
|
|
28
26
|
this.vibrato = null;
|
|
27
|
+
this.reverb = null;
|
|
29
28
|
this.volume = 1.0;
|
|
30
29
|
this.bassBoostlevel = 0;
|
|
31
30
|
// Initialize filter status
|
|
@@ -33,6 +32,8 @@ class Filters {
|
|
|
33
32
|
acc[filter] = false;
|
|
34
33
|
return acc;
|
|
35
34
|
}, {});
|
|
35
|
+
this.manager = manager;
|
|
36
|
+
this.player = player;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Updates the player's audio filters.
|