@kattowo/distube 6.2.0 → 6.2.1

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.mts CHANGED
@@ -1444,6 +1444,15 @@ declare class DisTubeStream extends TypedEmitter<{
1444
1444
  * The seek time in seconds that this stream started from
1445
1445
  */
1446
1446
  readonly seekTime: number;
1447
+ /**
1448
+ * Whether FFmpeg has already produced audio that is waiting to be read.
1449
+ *
1450
+ * The stream is spawned ahead of the playback (crossfade warmup) and the
1451
+ * pipe backs up once its buffers are full, so this is `true` as soon as the
1452
+ * first frame exists. A stream that is still `false` at playback time would
1453
+ * leave the audio player buffering until FFmpeg catches up.
1454
+ */
1455
+ get hasBufferedAudio(): boolean;
1447
1456
  /**
1448
1457
  * Create a DisTubeStream to play with {@link DisTubeVoice}
1449
1458
  * @param url - Stream URL
package/dist/index.d.ts CHANGED
@@ -1444,6 +1444,15 @@ declare class DisTubeStream extends TypedEmitter<{
1444
1444
  * The seek time in seconds that this stream started from
1445
1445
  */
1446
1446
  readonly seekTime: number;
1447
+ /**
1448
+ * Whether FFmpeg has already produced audio that is waiting to be read.
1449
+ *
1450
+ * The stream is spawned ahead of the playback (crossfade warmup) and the
1451
+ * pipe backs up once its buffers are full, so this is `true` as soon as the
1452
+ * first frame exists. A stream that is still `false` at playback time would
1453
+ * leave the audio player buffering until FFmpeg catches up.
1454
+ */
1455
+ get hasBufferedAudio(): boolean;
1447
1456
  /**
1448
1457
  * Create a DisTubeStream to play with {@link DisTubeVoice}
1449
1458
  * @param url - Stream URL
package/dist/index.js CHANGED
@@ -102,7 +102,7 @@ __export(index_exports, {
102
102
  module.exports = __toCommonJS(index_exports);
103
103
 
104
104
  // src/constant.ts
105
- var version = "6.2.0";
105
+ var version = "6.2.1";
106
106
  var AUDIO_SAMPLE_RATE = 48e3;
107
107
  var AUDIO_CHANNELS = 2;
108
108
  var DEFAULT_VOLUME = 50;
@@ -2793,6 +2793,17 @@ var DisTubeStream = class extends import_tiny_typed_emitter2.TypedEmitter {
2793
2793
  * The seek time in seconds that this stream started from
2794
2794
  */
2795
2795
  seekTime;
2796
+ /**
2797
+ * Whether FFmpeg has already produced audio that is waiting to be read.
2798
+ *
2799
+ * The stream is spawned ahead of the playback (crossfade warmup) and the
2800
+ * pipe backs up once its buffers are full, so this is `true` as soon as the
2801
+ * first frame exists. A stream that is still `false` at playback time would
2802
+ * leave the audio player buffering until FFmpeg catches up.
2803
+ */
2804
+ get hasBufferedAudio() {
2805
+ return this.stream.readableLength > 0;
2806
+ }
2796
2807
  /**
2797
2808
  * Create a DisTubeStream to play with {@link DisTubeVoice}
2798
2809
  * @param url - Stream URL
@@ -3489,7 +3500,7 @@ var QueueManager = class extends GuildIdManager {
3489
3500
  }
3490
3501
  queue._crossfadeWarmup = transitionStream;
3491
3502
  transitionStream.spawn();
3492
- const boundaryMs = Math.max(0, (remaining - fade) * 1e3);
3503
+ const boundaryMs = Math.max(0, (songDuration - queue.currentTime - fade) * 1e3);
3493
3504
  queue._crossfadeTimeout = setTimeout(() => {
3494
3505
  queue._crossfadeTimeout = void 0;
3495
3506
  void this.#crossfadeSwapTask(queue, transitionStream);
@@ -3527,6 +3538,10 @@ var QueueManager = class extends GuildIdManager {
3527
3538
  if (queue.stopped || queue.paused || queue.songs[0] !== song || queue._crossfadeWarmup !== transitionStream) {
3528
3539
  return abort();
3529
3540
  }
3541
+ if (!transitionStream.hasBufferedAudio) {
3542
+ this.debug(`[${queue.id}] Crossfade aborted: the transition stream is not ready`);
3543
+ return abort();
3544
+ }
3530
3545
  this.debug(`[${queue.id}] Starting crossfade: ${song} -> ${queue.songs.length > 1 ? queue.songs[1] : song}`);
3531
3546
  await queue.voice.play(transitionStream);
3532
3547
  queue._crossfadeWarmup = void 0;