streamify-audio 2.1.13 → 2.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamify-audio",
3
- "version": "2.1.13",
3
+ "version": "2.1.15",
4
4
  "description": "Dual-mode audio library: HTTP streaming proxy + Discord player (Lavalink alternative). Supports YouTube, Spotify, SoundCloud with audio filters.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -47,6 +47,7 @@ class Player extends EventEmitter {
47
47
  this._prefetchedTrack = null;
48
48
  this._prefetching = false;
49
49
  this._changingStream = false;
50
+ this._manualSkip = false;
50
51
 
51
52
  this.autoLeave = {
52
53
  enabled: options.autoLeave?.enabled ?? true,
@@ -197,15 +198,17 @@ class Player extends EventEmitter {
197
198
 
198
199
  this.emit('trackEnd', track, 'finished');
199
200
 
200
- const next = this.queue.shift();
201
- if (next) {
202
- this._playTrack(next);
203
- } else {
204
- if (this.autoplay.enabled && track) {
205
- await this._handleAutoplay(track);
201
+ if (!this._manualSkip) {
202
+ const next = this.queue.shift();
203
+ if (next) {
204
+ this._playTrack(next);
206
205
  } else {
207
- this.emit('queueEnd');
208
- this._resetInactivityTimeout();
206
+ if (this.autoplay.enabled && track) {
207
+ await this._handleAutoplay(track);
208
+ } else {
209
+ this.emit('queueEnd');
210
+ this._resetInactivityTimeout();
211
+ }
209
212
  }
210
213
  }
211
214
  });
@@ -481,8 +484,23 @@ class Player extends EventEmitter {
481
484
  this.stream = null;
482
485
  }
483
486
 
487
+ this._manualSkip = true;
488
+ const next = this.queue.shift();
484
489
  this.audioPlayer.stop();
485
- return this.queue.current;
490
+
491
+ if (next) {
492
+ await this._playTrack(next);
493
+
494
+ await new Promise(resolve => setTimeout(resolve, 250));
495
+
496
+ if (this.queue.current && this.queue.current.id !== next.id) {
497
+ this._manualSkip = false;
498
+ return this.queue.current;
499
+ }
500
+ }
501
+
502
+ this._manualSkip = false;
503
+ return this.queue.current || next;
486
504
  }
487
505
 
488
506
  async previous() {
@@ -495,8 +513,19 @@ class Player extends EventEmitter {
495
513
  this.stream = null;
496
514
  }
497
515
 
516
+ this._manualSkip = true;
498
517
  this.audioPlayer.stop();
499
- return this._playTrack(prev);
518
+ await this._playTrack(prev);
519
+
520
+ await new Promise(resolve => setTimeout(resolve, 250));
521
+
522
+ if (this.queue.current && this.queue.current.id !== prev.id) {
523
+ this._manualSkip = false;
524
+ return this.queue.current;
525
+ }
526
+
527
+ this._manualSkip = false;
528
+ return this.queue.current || prev;
500
529
  }
501
530
 
502
531
  stop() {