@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.mjs CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/constant.ts
5
- var version = "6.2.0";
5
+ var version = "6.2.1";
6
6
  var AUDIO_SAMPLE_RATE = 48e3;
7
7
  var AUDIO_CHANNELS = 2;
8
8
  var DEFAULT_VOLUME = 50;
@@ -2700,6 +2700,17 @@ var DisTubeStream = class extends TypedEmitter2 {
2700
2700
  * The seek time in seconds that this stream started from
2701
2701
  */
2702
2702
  seekTime;
2703
+ /**
2704
+ * Whether FFmpeg has already produced audio that is waiting to be read.
2705
+ *
2706
+ * The stream is spawned ahead of the playback (crossfade warmup) and the
2707
+ * pipe backs up once its buffers are full, so this is `true` as soon as the
2708
+ * first frame exists. A stream that is still `false` at playback time would
2709
+ * leave the audio player buffering until FFmpeg catches up.
2710
+ */
2711
+ get hasBufferedAudio() {
2712
+ return this.stream.readableLength > 0;
2713
+ }
2703
2714
  /**
2704
2715
  * Create a DisTubeStream to play with {@link DisTubeVoice}
2705
2716
  * @param url - Stream URL
@@ -3396,7 +3407,7 @@ var QueueManager = class extends GuildIdManager {
3396
3407
  }
3397
3408
  queue._crossfadeWarmup = transitionStream;
3398
3409
  transitionStream.spawn();
3399
- const boundaryMs = Math.max(0, (remaining - fade) * 1e3);
3410
+ const boundaryMs = Math.max(0, (songDuration - queue.currentTime - fade) * 1e3);
3400
3411
  queue._crossfadeTimeout = setTimeout(() => {
3401
3412
  queue._crossfadeTimeout = void 0;
3402
3413
  void this.#crossfadeSwapTask(queue, transitionStream);
@@ -3434,6 +3445,10 @@ var QueueManager = class extends GuildIdManager {
3434
3445
  if (queue.stopped || queue.paused || queue.songs[0] !== song || queue._crossfadeWarmup !== transitionStream) {
3435
3446
  return abort();
3436
3447
  }
3448
+ if (!transitionStream.hasBufferedAudio) {
3449
+ this.debug(`[${queue.id}] Crossfade aborted: the transition stream is not ready`);
3450
+ return abort();
3451
+ }
3437
3452
  this.debug(`[${queue.id}] Starting crossfade: ${song} -> ${queue.songs.length > 1 ? queue.songs[1] : song}`);
3438
3453
  await queue.voice.play(transitionStream);
3439
3454
  queue._crossfadeWarmup = void 0;