@kattowo/distube 6.1.0 → 6.2.0
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 +177 -2
- package/dist/index.d.ts +177 -2
- package/dist/index.js +404 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +399 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -321,6 +321,29 @@ type PreloadOptions = {
|
|
|
321
321
|
*/
|
|
322
322
|
threshold: number;
|
|
323
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* The validated {@link DisTubeOptions.crossfade} options of a {@link DisTube}
|
|
326
|
+
* instance.
|
|
327
|
+
*/
|
|
328
|
+
type CrossfadeOptions = {
|
|
329
|
+
/**
|
|
330
|
+
* The default crossfade duration (in seconds) applied to new queues. `0`
|
|
331
|
+
* disables the crossfade. A {@link Queue} can override it at runtime through
|
|
332
|
+
* its `crossfade` property.
|
|
333
|
+
*/
|
|
334
|
+
duration: number;
|
|
335
|
+
/**
|
|
336
|
+
* The FFmpeg `acrossfade` fade curve applied to both sides of the transition.
|
|
337
|
+
* @default "qsin" (equal-power)
|
|
338
|
+
*/
|
|
339
|
+
curve: string;
|
|
340
|
+
/**
|
|
341
|
+
* How long (in seconds) before the fade window begins the merged transition
|
|
342
|
+
* stream is spawned, so its buffers are warm and the fade starts on time.
|
|
343
|
+
* @default 5
|
|
344
|
+
*/
|
|
345
|
+
warmup: number;
|
|
346
|
+
};
|
|
324
347
|
/**
|
|
325
348
|
* DisTube options
|
|
326
349
|
*/
|
|
@@ -407,6 +430,39 @@ type DisTubeOptions = {
|
|
|
407
430
|
*/
|
|
408
431
|
threshold?: number;
|
|
409
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Crossfade the end of the current song with the beginning of the next one,
|
|
435
|
+
* instead of a hard switch between two streams.
|
|
436
|
+
*
|
|
437
|
+
* The transition is a single FFmpeg process that mixes both songs with an
|
|
438
|
+
* `acrossfade` filter, so the fade is seamless (no gaps, no extra decode
|
|
439
|
+
* round-trips). Because the fade length must be prepared in advance, the
|
|
440
|
+
* next song's stream is resolved even when preloading is disabled.
|
|
441
|
+
*
|
|
442
|
+
* Can be an object to configure it:
|
|
443
|
+
* - `duration`: the default crossfade duration in seconds for new queues
|
|
444
|
+
* (@default 0). Each {@link Queue} can override it at runtime with its
|
|
445
|
+
* `crossfade` property, which is what bots typically bind to a guild
|
|
446
|
+
* setting.
|
|
447
|
+
* - `curve`: the FFmpeg `acrossfade` fade curve (@default "qsin")
|
|
448
|
+
* - `warmup`: seconds before the fade window when the transition stream is
|
|
449
|
+
* spawned to warm up its buffers (@default 5)
|
|
450
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
451
|
+
*/
|
|
452
|
+
crossfade?: {
|
|
453
|
+
/**
|
|
454
|
+
* The default crossfade duration (in seconds) for new queues (0 disables).
|
|
455
|
+
*/
|
|
456
|
+
duration?: number;
|
|
457
|
+
/**
|
|
458
|
+
* The FFmpeg `acrossfade` fade curve applied to both songs.
|
|
459
|
+
*/
|
|
460
|
+
curve?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Seconds before the fade window when the transition stream is spawned.
|
|
463
|
+
*/
|
|
464
|
+
warmup?: number;
|
|
465
|
+
};
|
|
410
466
|
/**
|
|
411
467
|
* FFmpeg options
|
|
412
468
|
*/
|
|
@@ -849,6 +905,32 @@ declare const defaultFilters: Filters;
|
|
|
849
905
|
* Default number of seconds remaining in the currently playing song before preloading starts.
|
|
850
906
|
*/
|
|
851
907
|
declare const DEFAULT_PRELOAD_THRESHOLD_SECS = 15;
|
|
908
|
+
/**
|
|
909
|
+
* Default crossfade duration in seconds for a {@link Queue} (0 disables the crossfade).
|
|
910
|
+
*/
|
|
911
|
+
declare const DEFAULT_CROSSFADE_DURATION_SECS = 0;
|
|
912
|
+
/**
|
|
913
|
+
* Maximum crossfade duration in seconds a {@link Queue} may request.
|
|
914
|
+
*/
|
|
915
|
+
declare const MAX_CROSSFADE_DURATION_SECS = 12;
|
|
916
|
+
/**
|
|
917
|
+
* Default FFmpeg `acrossfade` fade curve of the crossfade transition.
|
|
918
|
+
*
|
|
919
|
+
* `qsin` is an equal-power curve: the two songs mix without the -3dB dip of a
|
|
920
|
+
* linear (triangular) curve.
|
|
921
|
+
*/
|
|
922
|
+
declare const DEFAULT_CROSSFADE_CURVE = "qsin";
|
|
923
|
+
/**
|
|
924
|
+
* Default number of seconds before the fade window when the merged crossfade
|
|
925
|
+
* transition stream is spawned to warm up its buffers.
|
|
926
|
+
*/
|
|
927
|
+
declare const DEFAULT_CROSSFADE_WARMUP_SECS = 5;
|
|
928
|
+
/**
|
|
929
|
+
* How far (in seconds) the playback position may drift from the expected
|
|
930
|
+
* crossfade boundary before the transition is aborted and the regular
|
|
931
|
+
* song-switch takes over.
|
|
932
|
+
*/
|
|
933
|
+
declare const CROSSFADE_DRIFT_TOLERANCE_SECS = 0.75;
|
|
852
934
|
/**
|
|
853
935
|
* The default options of a {@link DisTube} instance.
|
|
854
936
|
*
|
|
@@ -866,6 +948,11 @@ declare const defaultOptions: {
|
|
|
866
948
|
unhandledError: "log";
|
|
867
949
|
stuckThreshold: number;
|
|
868
950
|
preload: false;
|
|
951
|
+
crossfade: {
|
|
952
|
+
duration: number;
|
|
953
|
+
curve: string;
|
|
954
|
+
warmup: number;
|
|
955
|
+
};
|
|
869
956
|
};
|
|
870
957
|
|
|
871
958
|
/**
|
|
@@ -1253,6 +1340,11 @@ declare class Options {
|
|
|
1253
1340
|
* @default { enabled: false, threshold: 15 }
|
|
1254
1341
|
*/
|
|
1255
1342
|
preload: PreloadOptions;
|
|
1343
|
+
/**
|
|
1344
|
+
* The crossfade options of the DisTube instance.
|
|
1345
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
1346
|
+
*/
|
|
1347
|
+
crossfade: CrossfadeOptions;
|
|
1256
1348
|
/**
|
|
1257
1349
|
* The FFmpeg options of the DisTube instance.
|
|
1258
1350
|
*/
|
|
@@ -1279,6 +1371,43 @@ interface StreamOptions {
|
|
|
1279
1371
|
* @default 0
|
|
1280
1372
|
*/
|
|
1281
1373
|
seek?: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Crossfade transition options.
|
|
1376
|
+
*
|
|
1377
|
+
* When set, the stream mixes the primary URL (the song that is fading out,
|
|
1378
|
+
* seeked to its final `duration` seconds) and the secondary URL (the song
|
|
1379
|
+
* that is fading in) with an FFmpeg `acrossfade` filter graph, so the two
|
|
1380
|
+
* songs crossfade seamlessly in a single FFmpeg process.
|
|
1381
|
+
*/
|
|
1382
|
+
crossfade?: CrossfadeStreamOptions;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Options describing a crossfade transition stream
|
|
1386
|
+
*/
|
|
1387
|
+
interface CrossfadeStreamOptions {
|
|
1388
|
+
/**
|
|
1389
|
+
* The fade duration in seconds.
|
|
1390
|
+
*/
|
|
1391
|
+
duration: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* The initial seek of the first (fading out) input, in seconds. It must be
|
|
1394
|
+
* the position where the fade window begins (`song duration - duration`).
|
|
1395
|
+
*/
|
|
1396
|
+
primarySeek: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The stream URL of the second (fading in) input.
|
|
1399
|
+
*/
|
|
1400
|
+
secondaryUrl: string;
|
|
1401
|
+
/**
|
|
1402
|
+
* The FFmpeg `acrossfade` fade curve of the first (fading out) input.
|
|
1403
|
+
* @default "qsin"
|
|
1404
|
+
*/
|
|
1405
|
+
outCurve?: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* The FFmpeg `acrossfade` fade curve of the second (fading in) input.
|
|
1408
|
+
* @default "qsin"
|
|
1409
|
+
*/
|
|
1410
|
+
inCurve?: string;
|
|
1282
1411
|
}
|
|
1283
1412
|
/**
|
|
1284
1413
|
* Check that FFmpeg is installed and can be spawned.
|
|
@@ -1628,6 +1757,16 @@ declare class QueueManager extends GuildIdManager<Queue> {
|
|
|
1628
1757
|
* @param queue - The guild queue
|
|
1629
1758
|
*/
|
|
1630
1759
|
preloadNextSong(queue: Queue): Promise<void>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Schedule the crossfade into the next song: a single FFmpeg process mixes
|
|
1762
|
+
* the current song (seeked to its final fade window) with the next song, and
|
|
1763
|
+
* replaces the playback stream exactly when the fade window begins.
|
|
1764
|
+
*
|
|
1765
|
+
* Canceled automatically whenever the preloaded state is invalidated
|
|
1766
|
+
* (pause, seek, stop...), as both schedulers share the same generation.
|
|
1767
|
+
* @param queue - The guild queue
|
|
1768
|
+
*/
|
|
1769
|
+
scheduleCrossfade(queue: Queue): void;
|
|
1631
1770
|
}
|
|
1632
1771
|
|
|
1633
1772
|
/**
|
|
@@ -2401,11 +2540,27 @@ declare class Queue extends DisTubeBase {
|
|
|
2401
2540
|
* @internal
|
|
2402
2541
|
*/
|
|
2403
2542
|
_preloadGeneration: number;
|
|
2543
|
+
/**
|
|
2544
|
+
* Crossfade boundary timer
|
|
2545
|
+
* @internal
|
|
2546
|
+
*/
|
|
2547
|
+
_crossfadeTimeout?: NodeJS.Timeout;
|
|
2548
|
+
/**
|
|
2549
|
+
* The merged transition stream that is warming up before the fade window
|
|
2550
|
+
* starts
|
|
2551
|
+
* @internal
|
|
2552
|
+
*/
|
|
2553
|
+
_crossfadeWarmup?: DisTubeStream;
|
|
2404
2554
|
/**
|
|
2405
2555
|
* Clear any preloaded song and cancel pending preload timer.
|
|
2406
2556
|
* @internal
|
|
2407
2557
|
*/
|
|
2408
2558
|
_clearPreload(): void;
|
|
2559
|
+
/**
|
|
2560
|
+
* Cancel a pending crossfade and kill its warming-up transition stream.
|
|
2561
|
+
* @internal
|
|
2562
|
+
*/
|
|
2563
|
+
_crossfadeCancel(): void;
|
|
2409
2564
|
/**
|
|
2410
2565
|
* Create a queue for the guild
|
|
2411
2566
|
* @param distube - DisTube
|
|
@@ -2440,6 +2595,17 @@ declare class Queue extends DisTubeBase {
|
|
|
2440
2595
|
* What time in the song is playing (in seconds).
|
|
2441
2596
|
*/
|
|
2442
2597
|
get currentTime(): number;
|
|
2598
|
+
/**
|
|
2599
|
+
* The crossfade duration (in seconds) between this song and the next one.
|
|
2600
|
+
*
|
|
2601
|
+
* `0` (the default) disables the crossfade. Changing it takes effect for the
|
|
2602
|
+
* next transition; call {@link Queue#scheduleCrossfade} to re-arm the
|
|
2603
|
+
* transition for the currently playing song immediately.
|
|
2604
|
+
* @throws {@link DisTubeError} When the value is not a number between `0`
|
|
2605
|
+
* and the maximum crossfade duration
|
|
2606
|
+
*/
|
|
2607
|
+
get crossfade(): number;
|
|
2608
|
+
set crossfade(value: number);
|
|
2443
2609
|
/**
|
|
2444
2610
|
* Formatted {@link Queue#currentTime} string.
|
|
2445
2611
|
*/
|
|
@@ -2598,6 +2764,15 @@ declare class Queue extends DisTubeBase {
|
|
|
2598
2764
|
* @throws {@link DisTubeError} When the queue has been stopped
|
|
2599
2765
|
*/
|
|
2600
2766
|
play(emitPlaySong?: boolean): Promise<void>;
|
|
2767
|
+
/**
|
|
2768
|
+
* Re-arm the crossfade into the next song for the currently playing one.
|
|
2769
|
+
*
|
|
2770
|
+
* Useful after changing {@link Queue#crossfade} while a song is playing: the
|
|
2771
|
+
* fade may still fit into the remaining time. This is called automatically
|
|
2772
|
+
* after every song switch.
|
|
2773
|
+
* @returns Nothing
|
|
2774
|
+
*/
|
|
2775
|
+
scheduleCrossfade(): void;
|
|
2601
2776
|
/**
|
|
2602
2777
|
* Restart the current stream with the current FFmpeg arguments, keeping the
|
|
2603
2778
|
* playback position.
|
|
@@ -3438,5 +3613,5 @@ declare function handleUnhandledError(error: Error, behavior?: UnhandledErrorBeh
|
|
|
3438
3613
|
*/
|
|
3439
3614
|
declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
3440
3615
|
|
|
3441
|
-
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3442
|
-
export type { Awaitable, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
|
3616
|
+
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, CROSSFADE_DRIFT_TOLERANCE_SECS, DEFAULT_CROSSFADE_CURVE, DEFAULT_CROSSFADE_DURATION_SECS, DEFAULT_CROSSFADE_WARMUP_SECS, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_CROSSFADE_DURATION_SECS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3617
|
+
export type { Awaitable, CrossfadeOptions, CrossfadeStreamOptions, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
package/dist/index.d.ts
CHANGED
|
@@ -321,6 +321,29 @@ type PreloadOptions = {
|
|
|
321
321
|
*/
|
|
322
322
|
threshold: number;
|
|
323
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* The validated {@link DisTubeOptions.crossfade} options of a {@link DisTube}
|
|
326
|
+
* instance.
|
|
327
|
+
*/
|
|
328
|
+
type CrossfadeOptions = {
|
|
329
|
+
/**
|
|
330
|
+
* The default crossfade duration (in seconds) applied to new queues. `0`
|
|
331
|
+
* disables the crossfade. A {@link Queue} can override it at runtime through
|
|
332
|
+
* its `crossfade` property.
|
|
333
|
+
*/
|
|
334
|
+
duration: number;
|
|
335
|
+
/**
|
|
336
|
+
* The FFmpeg `acrossfade` fade curve applied to both sides of the transition.
|
|
337
|
+
* @default "qsin" (equal-power)
|
|
338
|
+
*/
|
|
339
|
+
curve: string;
|
|
340
|
+
/**
|
|
341
|
+
* How long (in seconds) before the fade window begins the merged transition
|
|
342
|
+
* stream is spawned, so its buffers are warm and the fade starts on time.
|
|
343
|
+
* @default 5
|
|
344
|
+
*/
|
|
345
|
+
warmup: number;
|
|
346
|
+
};
|
|
324
347
|
/**
|
|
325
348
|
* DisTube options
|
|
326
349
|
*/
|
|
@@ -407,6 +430,39 @@ type DisTubeOptions = {
|
|
|
407
430
|
*/
|
|
408
431
|
threshold?: number;
|
|
409
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Crossfade the end of the current song with the beginning of the next one,
|
|
435
|
+
* instead of a hard switch between two streams.
|
|
436
|
+
*
|
|
437
|
+
* The transition is a single FFmpeg process that mixes both songs with an
|
|
438
|
+
* `acrossfade` filter, so the fade is seamless (no gaps, no extra decode
|
|
439
|
+
* round-trips). Because the fade length must be prepared in advance, the
|
|
440
|
+
* next song's stream is resolved even when preloading is disabled.
|
|
441
|
+
*
|
|
442
|
+
* Can be an object to configure it:
|
|
443
|
+
* - `duration`: the default crossfade duration in seconds for new queues
|
|
444
|
+
* (@default 0). Each {@link Queue} can override it at runtime with its
|
|
445
|
+
* `crossfade` property, which is what bots typically bind to a guild
|
|
446
|
+
* setting.
|
|
447
|
+
* - `curve`: the FFmpeg `acrossfade` fade curve (@default "qsin")
|
|
448
|
+
* - `warmup`: seconds before the fade window when the transition stream is
|
|
449
|
+
* spawned to warm up its buffers (@default 5)
|
|
450
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
451
|
+
*/
|
|
452
|
+
crossfade?: {
|
|
453
|
+
/**
|
|
454
|
+
* The default crossfade duration (in seconds) for new queues (0 disables).
|
|
455
|
+
*/
|
|
456
|
+
duration?: number;
|
|
457
|
+
/**
|
|
458
|
+
* The FFmpeg `acrossfade` fade curve applied to both songs.
|
|
459
|
+
*/
|
|
460
|
+
curve?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Seconds before the fade window when the transition stream is spawned.
|
|
463
|
+
*/
|
|
464
|
+
warmup?: number;
|
|
465
|
+
};
|
|
410
466
|
/**
|
|
411
467
|
* FFmpeg options
|
|
412
468
|
*/
|
|
@@ -849,6 +905,32 @@ declare const defaultFilters: Filters;
|
|
|
849
905
|
* Default number of seconds remaining in the currently playing song before preloading starts.
|
|
850
906
|
*/
|
|
851
907
|
declare const DEFAULT_PRELOAD_THRESHOLD_SECS = 15;
|
|
908
|
+
/**
|
|
909
|
+
* Default crossfade duration in seconds for a {@link Queue} (0 disables the crossfade).
|
|
910
|
+
*/
|
|
911
|
+
declare const DEFAULT_CROSSFADE_DURATION_SECS = 0;
|
|
912
|
+
/**
|
|
913
|
+
* Maximum crossfade duration in seconds a {@link Queue} may request.
|
|
914
|
+
*/
|
|
915
|
+
declare const MAX_CROSSFADE_DURATION_SECS = 12;
|
|
916
|
+
/**
|
|
917
|
+
* Default FFmpeg `acrossfade` fade curve of the crossfade transition.
|
|
918
|
+
*
|
|
919
|
+
* `qsin` is an equal-power curve: the two songs mix without the -3dB dip of a
|
|
920
|
+
* linear (triangular) curve.
|
|
921
|
+
*/
|
|
922
|
+
declare const DEFAULT_CROSSFADE_CURVE = "qsin";
|
|
923
|
+
/**
|
|
924
|
+
* Default number of seconds before the fade window when the merged crossfade
|
|
925
|
+
* transition stream is spawned to warm up its buffers.
|
|
926
|
+
*/
|
|
927
|
+
declare const DEFAULT_CROSSFADE_WARMUP_SECS = 5;
|
|
928
|
+
/**
|
|
929
|
+
* How far (in seconds) the playback position may drift from the expected
|
|
930
|
+
* crossfade boundary before the transition is aborted and the regular
|
|
931
|
+
* song-switch takes over.
|
|
932
|
+
*/
|
|
933
|
+
declare const CROSSFADE_DRIFT_TOLERANCE_SECS = 0.75;
|
|
852
934
|
/**
|
|
853
935
|
* The default options of a {@link DisTube} instance.
|
|
854
936
|
*
|
|
@@ -866,6 +948,11 @@ declare const defaultOptions: {
|
|
|
866
948
|
unhandledError: "log";
|
|
867
949
|
stuckThreshold: number;
|
|
868
950
|
preload: false;
|
|
951
|
+
crossfade: {
|
|
952
|
+
duration: number;
|
|
953
|
+
curve: string;
|
|
954
|
+
warmup: number;
|
|
955
|
+
};
|
|
869
956
|
};
|
|
870
957
|
|
|
871
958
|
/**
|
|
@@ -1253,6 +1340,11 @@ declare class Options {
|
|
|
1253
1340
|
* @default { enabled: false, threshold: 15 }
|
|
1254
1341
|
*/
|
|
1255
1342
|
preload: PreloadOptions;
|
|
1343
|
+
/**
|
|
1344
|
+
* The crossfade options of the DisTube instance.
|
|
1345
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
1346
|
+
*/
|
|
1347
|
+
crossfade: CrossfadeOptions;
|
|
1256
1348
|
/**
|
|
1257
1349
|
* The FFmpeg options of the DisTube instance.
|
|
1258
1350
|
*/
|
|
@@ -1279,6 +1371,43 @@ interface StreamOptions {
|
|
|
1279
1371
|
* @default 0
|
|
1280
1372
|
*/
|
|
1281
1373
|
seek?: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Crossfade transition options.
|
|
1376
|
+
*
|
|
1377
|
+
* When set, the stream mixes the primary URL (the song that is fading out,
|
|
1378
|
+
* seeked to its final `duration` seconds) and the secondary URL (the song
|
|
1379
|
+
* that is fading in) with an FFmpeg `acrossfade` filter graph, so the two
|
|
1380
|
+
* songs crossfade seamlessly in a single FFmpeg process.
|
|
1381
|
+
*/
|
|
1382
|
+
crossfade?: CrossfadeStreamOptions;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Options describing a crossfade transition stream
|
|
1386
|
+
*/
|
|
1387
|
+
interface CrossfadeStreamOptions {
|
|
1388
|
+
/**
|
|
1389
|
+
* The fade duration in seconds.
|
|
1390
|
+
*/
|
|
1391
|
+
duration: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* The initial seek of the first (fading out) input, in seconds. It must be
|
|
1394
|
+
* the position where the fade window begins (`song duration - duration`).
|
|
1395
|
+
*/
|
|
1396
|
+
primarySeek: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The stream URL of the second (fading in) input.
|
|
1399
|
+
*/
|
|
1400
|
+
secondaryUrl: string;
|
|
1401
|
+
/**
|
|
1402
|
+
* The FFmpeg `acrossfade` fade curve of the first (fading out) input.
|
|
1403
|
+
* @default "qsin"
|
|
1404
|
+
*/
|
|
1405
|
+
outCurve?: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* The FFmpeg `acrossfade` fade curve of the second (fading in) input.
|
|
1408
|
+
* @default "qsin"
|
|
1409
|
+
*/
|
|
1410
|
+
inCurve?: string;
|
|
1282
1411
|
}
|
|
1283
1412
|
/**
|
|
1284
1413
|
* Check that FFmpeg is installed and can be spawned.
|
|
@@ -1628,6 +1757,16 @@ declare class QueueManager extends GuildIdManager<Queue> {
|
|
|
1628
1757
|
* @param queue - The guild queue
|
|
1629
1758
|
*/
|
|
1630
1759
|
preloadNextSong(queue: Queue): Promise<void>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Schedule the crossfade into the next song: a single FFmpeg process mixes
|
|
1762
|
+
* the current song (seeked to its final fade window) with the next song, and
|
|
1763
|
+
* replaces the playback stream exactly when the fade window begins.
|
|
1764
|
+
*
|
|
1765
|
+
* Canceled automatically whenever the preloaded state is invalidated
|
|
1766
|
+
* (pause, seek, stop...), as both schedulers share the same generation.
|
|
1767
|
+
* @param queue - The guild queue
|
|
1768
|
+
*/
|
|
1769
|
+
scheduleCrossfade(queue: Queue): void;
|
|
1631
1770
|
}
|
|
1632
1771
|
|
|
1633
1772
|
/**
|
|
@@ -2401,11 +2540,27 @@ declare class Queue extends DisTubeBase {
|
|
|
2401
2540
|
* @internal
|
|
2402
2541
|
*/
|
|
2403
2542
|
_preloadGeneration: number;
|
|
2543
|
+
/**
|
|
2544
|
+
* Crossfade boundary timer
|
|
2545
|
+
* @internal
|
|
2546
|
+
*/
|
|
2547
|
+
_crossfadeTimeout?: NodeJS.Timeout;
|
|
2548
|
+
/**
|
|
2549
|
+
* The merged transition stream that is warming up before the fade window
|
|
2550
|
+
* starts
|
|
2551
|
+
* @internal
|
|
2552
|
+
*/
|
|
2553
|
+
_crossfadeWarmup?: DisTubeStream;
|
|
2404
2554
|
/**
|
|
2405
2555
|
* Clear any preloaded song and cancel pending preload timer.
|
|
2406
2556
|
* @internal
|
|
2407
2557
|
*/
|
|
2408
2558
|
_clearPreload(): void;
|
|
2559
|
+
/**
|
|
2560
|
+
* Cancel a pending crossfade and kill its warming-up transition stream.
|
|
2561
|
+
* @internal
|
|
2562
|
+
*/
|
|
2563
|
+
_crossfadeCancel(): void;
|
|
2409
2564
|
/**
|
|
2410
2565
|
* Create a queue for the guild
|
|
2411
2566
|
* @param distube - DisTube
|
|
@@ -2440,6 +2595,17 @@ declare class Queue extends DisTubeBase {
|
|
|
2440
2595
|
* What time in the song is playing (in seconds).
|
|
2441
2596
|
*/
|
|
2442
2597
|
get currentTime(): number;
|
|
2598
|
+
/**
|
|
2599
|
+
* The crossfade duration (in seconds) between this song and the next one.
|
|
2600
|
+
*
|
|
2601
|
+
* `0` (the default) disables the crossfade. Changing it takes effect for the
|
|
2602
|
+
* next transition; call {@link Queue#scheduleCrossfade} to re-arm the
|
|
2603
|
+
* transition for the currently playing song immediately.
|
|
2604
|
+
* @throws {@link DisTubeError} When the value is not a number between `0`
|
|
2605
|
+
* and the maximum crossfade duration
|
|
2606
|
+
*/
|
|
2607
|
+
get crossfade(): number;
|
|
2608
|
+
set crossfade(value: number);
|
|
2443
2609
|
/**
|
|
2444
2610
|
* Formatted {@link Queue#currentTime} string.
|
|
2445
2611
|
*/
|
|
@@ -2598,6 +2764,15 @@ declare class Queue extends DisTubeBase {
|
|
|
2598
2764
|
* @throws {@link DisTubeError} When the queue has been stopped
|
|
2599
2765
|
*/
|
|
2600
2766
|
play(emitPlaySong?: boolean): Promise<void>;
|
|
2767
|
+
/**
|
|
2768
|
+
* Re-arm the crossfade into the next song for the currently playing one.
|
|
2769
|
+
*
|
|
2770
|
+
* Useful after changing {@link Queue#crossfade} while a song is playing: the
|
|
2771
|
+
* fade may still fit into the remaining time. This is called automatically
|
|
2772
|
+
* after every song switch.
|
|
2773
|
+
* @returns Nothing
|
|
2774
|
+
*/
|
|
2775
|
+
scheduleCrossfade(): void;
|
|
2601
2776
|
/**
|
|
2602
2777
|
* Restart the current stream with the current FFmpeg arguments, keeping the
|
|
2603
2778
|
* playback position.
|
|
@@ -3440,5 +3615,5 @@ declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
|
3440
3615
|
|
|
3441
3616
|
// @ts-ignore
|
|
3442
3617
|
export = DisTube;
|
|
3443
|
-
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3444
|
-
export type { Awaitable, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
|
3618
|
+
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, CROSSFADE_DRIFT_TOLERANCE_SECS, DEFAULT_CROSSFADE_CURVE, DEFAULT_CROSSFADE_DURATION_SECS, DEFAULT_CROSSFADE_WARMUP_SECS, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_CROSSFADE_DURATION_SECS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3619
|
+
export type { Awaitable, CrossfadeOptions, CrossfadeStreamOptions, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|