discord-player 5.3.2-dev.0 → 5.3.2-dev.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/Player.js +3 -2
- package/dist/Structures/Queue.js +12 -0
- package/dist/VoiceInterface/StreamDispatcher.js +3 -2
- package/dist/VoiceInterface/VolumeTransformer.js +1 -1
- package/dist/index.d.ts +41 -2
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/smoothVolume.js +10 -8
- package/package.json +1 -1
package/dist/Player.js
CHANGED
|
@@ -32,7 +32,8 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
32
32
|
ytdlOptions: {
|
|
33
33
|
highWaterMark: 1 << 25
|
|
34
34
|
},
|
|
35
|
-
connectionTimeout: 20000
|
|
35
|
+
connectionTimeout: 20000,
|
|
36
|
+
smoothVolume: true
|
|
36
37
|
};
|
|
37
38
|
this.queues = new discord_js_1.Collection();
|
|
38
39
|
this.voiceUtils = new VoiceUtils_1.VoiceUtils();
|
|
@@ -164,7 +165,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
164
165
|
return this.queues.get(guild.id);
|
|
165
166
|
const _meta = queueInitOptions.metadata;
|
|
166
167
|
delete queueInitOptions["metadata"];
|
|
167
|
-
queueInitOptions.volumeSmoothness ?? (queueInitOptions.volumeSmoothness = 0.08);
|
|
168
|
+
queueInitOptions.volumeSmoothness ?? (queueInitOptions.volumeSmoothness = this.options.smoothVolume ? 0.08 : 0);
|
|
168
169
|
queueInitOptions.ytdlOptions ?? (queueInitOptions.ytdlOptions = this.options.ytdlOptions);
|
|
169
170
|
const queue = new Queue_1.Queue(this, guild, queueInitOptions);
|
|
170
171
|
queue.metadata = _meta;
|
package/dist/Structures/Queue.js
CHANGED
|
@@ -101,6 +101,18 @@ class Queue {
|
|
|
101
101
|
this.onBeforeCreateStream = this.options.onBeforeCreateStream;
|
|
102
102
|
this.player.emit("debug", this, `Queue initialized:\n\n${this.player.scanDeps()}`);
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Forces next play
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*/
|
|
108
|
+
async forceNext() {
|
|
109
|
+
if (this.connection.audioResource) {
|
|
110
|
+
this.connection.emit("finish", this.connection.audioResource);
|
|
111
|
+
}
|
|
112
|
+
else if (this.tracks.length) {
|
|
113
|
+
await this.play();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
104
116
|
/**
|
|
105
117
|
* Returns current track
|
|
106
118
|
* @type {Track}
|
|
@@ -171,8 +171,9 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
171
171
|
async playStream(resource = this.audioResource) {
|
|
172
172
|
if (!resource)
|
|
173
173
|
throw new PlayerError_1.PlayerError("Audio resource is not available!", PlayerError_1.ErrorStatusCode.NO_AUDIO_RESOURCE);
|
|
174
|
-
if (resource.ended)
|
|
175
|
-
return void this.emit("
|
|
174
|
+
if (resource.ended) {
|
|
175
|
+
return void this.emit("finish", resource);
|
|
176
|
+
}
|
|
176
177
|
if (!this.audioResource)
|
|
177
178
|
this.audioResource = resource;
|
|
178
179
|
if (this.voiceConnection.state.status !== voice_1.VoiceConnectionStatus.Ready) {
|
|
@@ -108,7 +108,7 @@ class VolumeTransformer extends stream_1.Transform {
|
|
|
108
108
|
this._smoothing = smoothness;
|
|
109
109
|
}
|
|
110
110
|
smoothingEnabled() {
|
|
111
|
-
return Number.isFinite(this._smoothing) && this._smoothing > 0;
|
|
111
|
+
return typeof this._smoothing === "number" && !Number.isNaN(this._smoothing) && Number.isFinite(this._smoothing) && this._smoothing > 0;
|
|
112
112
|
}
|
|
113
113
|
get hasSmoothness() {
|
|
114
114
|
return true;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { User, VoiceChannel, StageChannel, Collection, Snowflake, Client, GuildResolvable, Guild, GuildChannelResolvable, UserResolvable } from 'discord.js';
|
|
3
|
-
import { Readable, Duplex } from 'stream';
|
|
3
|
+
import { Readable, Duplex, TransformOptions, Transform } from 'stream';
|
|
4
4
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
5
5
|
import { AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, StreamType, AudioPlayerStatus } from '@discordjs/voice';
|
|
6
6
|
import { downloadOptions } from 'ytdl-core';
|
|
@@ -345,6 +345,11 @@ declare class Queue<T = unknown> {
|
|
|
345
345
|
* @param {PlayerOptions} [options] Player options for the queue
|
|
346
346
|
*/
|
|
347
347
|
constructor(player: Player, guild: Guild, options?: PlayerOptions);
|
|
348
|
+
/**
|
|
349
|
+
* Forces next play
|
|
350
|
+
* @returns {Promise<void>}
|
|
351
|
+
*/
|
|
352
|
+
forceNext(): Promise<void>;
|
|
348
353
|
/**
|
|
349
354
|
* Returns current track
|
|
350
355
|
* @type {Track}
|
|
@@ -999,11 +1004,13 @@ interface PlaylistJSON {
|
|
|
999
1004
|
* @property {boolean} [autoRegisterExtractor=true] If it should automatically register `@discord-player/extractor`
|
|
1000
1005
|
* @property {YTDLDownloadOptions} [ytdlOptions] The options passed to `ytdl-core`
|
|
1001
1006
|
* @property {number} [connectionTimeout=20000] The voice connection timeout
|
|
1007
|
+
* @property {boolean} [smoothVolume=true] Toggle smooth volume transition
|
|
1002
1008
|
*/
|
|
1003
1009
|
interface PlayerInitOptions {
|
|
1004
1010
|
autoRegisterExtractor?: boolean;
|
|
1005
1011
|
ytdlOptions?: downloadOptions;
|
|
1006
1012
|
connectionTimeout?: number;
|
|
1013
|
+
smoothVolume?: boolean;
|
|
1007
1014
|
}
|
|
1008
1015
|
|
|
1009
1016
|
declare class AudioFilters {
|
|
@@ -1091,6 +1098,38 @@ declare class QueryResolver {
|
|
|
1091
1098
|
static getVimeoID(query: string): string;
|
|
1092
1099
|
}
|
|
1093
1100
|
|
|
1101
|
+
interface VolumeTransformerOptions extends TransformOptions {
|
|
1102
|
+
type?: "s16le" | "s16be" | "s32le" | "s32be";
|
|
1103
|
+
smoothness?: number;
|
|
1104
|
+
volume?: number;
|
|
1105
|
+
}
|
|
1106
|
+
declare class VolumeTransformer extends Transform {
|
|
1107
|
+
private _bits;
|
|
1108
|
+
private _smoothing;
|
|
1109
|
+
private _bytes;
|
|
1110
|
+
private _extremum;
|
|
1111
|
+
private _chunk;
|
|
1112
|
+
volume: number;
|
|
1113
|
+
private _targetVolume;
|
|
1114
|
+
type: "s16le" | "s32le" | "s16be" | "s32be";
|
|
1115
|
+
constructor(options?: VolumeTransformerOptions);
|
|
1116
|
+
_readInt(buffer: Buffer, index: number): number;
|
|
1117
|
+
_writeInt(buffer: Buffer, int: number, index: number): number;
|
|
1118
|
+
_applySmoothness(): void;
|
|
1119
|
+
_transform(chunk: Buffer, encoding: BufferEncoding, done: () => unknown): unknown;
|
|
1120
|
+
_destroy(err: Error, cb: (error: Error) => void): void;
|
|
1121
|
+
setVolume(volume: number): void;
|
|
1122
|
+
setVolumeDecibels(db: number): void;
|
|
1123
|
+
setVolumeLogarithmic(value: number): void;
|
|
1124
|
+
get volumeDecibels(): number;
|
|
1125
|
+
get volumeLogarithmic(): number;
|
|
1126
|
+
get smoothness(): number;
|
|
1127
|
+
setSmoothness(smoothness: number): void;
|
|
1128
|
+
smoothingEnabled(): boolean;
|
|
1129
|
+
get hasSmoothness(): boolean;
|
|
1130
|
+
static get hasSmoothing(): boolean;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1094
1133
|
declare class Util {
|
|
1095
1134
|
/**
|
|
1096
1135
|
* Utils
|
|
@@ -1159,4 +1198,4 @@ declare function createFFmpegStream(stream: Readable | Duplex | string, options?
|
|
|
1159
1198
|
|
|
1160
1199
|
declare const version: string;
|
|
1161
1200
|
|
|
1162
|
-
export { AudioFilters, ErrorStatusCode, ExtractorModel, ExtractorModelData, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFmpegStreamOptions, FiltersName, PlayOptions, Player, PlayerError, PlayerEvents, PlayerInitOptions, PlayerOptions, PlayerProgressbarOptions, PlayerSearchResult, Playlist, PlaylistInitData, PlaylistJSON, QueryResolver, QueryType, Queue, QueueFilters, QueueRepeatMode, RawTrackData, SearchOptions, StreamDispatcher, TimeData, Track, TrackJSON, TrackSource, Util, VoiceEvents, VoiceUtils, createFFmpegStream, version };
|
|
1201
|
+
export { AudioFilters, ErrorStatusCode, ExtractorModel, ExtractorModelData, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFmpegStreamOptions, FiltersName, PlayOptions, Player, PlayerError, PlayerEvents, PlayerInitOptions, PlayerOptions, PlayerProgressbarOptions, PlayerSearchResult, Playlist, PlaylistInitData, PlaylistJSON, QueryResolver, QueryType, Queue, QueueFilters, QueueRepeatMode, RawTrackData, SearchOptions, StreamDispatcher, TimeData, Track, TrackJSON, TrackSource, Util, VoiceEvents, VoiceUtils, VolumeTransformer, VolumeTransformerOptions, createFFmpegStream, version };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
|
|
|
25
25
|
Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } });
|
|
26
26
|
var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
|
|
27
27
|
Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
|
|
28
|
+
tslib_1.__exportStar(require("./VoiceInterface/VolumeTransformer"), exports);
|
|
28
29
|
var Util_1 = require("./utils/Util");
|
|
29
30
|
Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
|
|
30
31
|
tslib_1.__exportStar(require("./types/types"), exports);
|
package/dist/index.mjs
CHANGED
|
@@ -17,5 +17,6 @@ export const StreamDispatcher = mod.StreamDispatcher;
|
|
|
17
17
|
export const Track = mod.Track;
|
|
18
18
|
export const Util = mod.Util;
|
|
19
19
|
export const VoiceUtils = mod.VoiceUtils;
|
|
20
|
+
export const VolumeTransformer = mod.VolumeTransformer;
|
|
20
21
|
export const createFFmpegStream = mod.createFFmpegStream;
|
|
21
22
|
export const version = mod.version;
|
package/dist/smoothVolume.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
if (!("DISABLE_DISCORD_PLAYER_SMOOTH_VOLUME" in process.env)) {
|
|
5
|
+
try {
|
|
6
|
+
// eslint-disable-next-line
|
|
7
|
+
const mod = require("prism-media");
|
|
8
|
+
if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
|
|
9
|
+
Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
/* do nothing */
|
|
9
14
|
}
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
/* do nothing */
|
|
13
15
|
}
|