style: run format:apply
This commit is contained in:
+28
-16
@@ -1,8 +1,14 @@
|
||||
import { AudioPlayer, createAudioPlayer, createAudioResource, StreamType, VoiceConnection } from "@discordjs/voice";
|
||||
import { AudioMixer } from "node-audio-mixer";
|
||||
import { PassThrough, Readable } from "stream";
|
||||
import {
|
||||
AudioPlayer,
|
||||
createAudioPlayer,
|
||||
createAudioResource,
|
||||
StreamType,
|
||||
VoiceConnection
|
||||
} from '@discordjs/voice';
|
||||
import { AudioMixer } from 'node-audio-mixer';
|
||||
import { PassThrough, Readable } from 'stream';
|
||||
|
||||
import prism from "prism-media";
|
||||
import prism from 'prism-media';
|
||||
|
||||
export class StreamQueue {
|
||||
private queue: Readable[] = [];
|
||||
@@ -29,7 +35,7 @@ export class StreamQueue {
|
||||
await this.mixer.playStream(nextStream);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Queue error:", e);
|
||||
console.error('Queue error:', e);
|
||||
} finally {
|
||||
this.isPlaying = false;
|
||||
this.processQueue();
|
||||
@@ -65,7 +71,7 @@ export class MixedStream {
|
||||
sampleRate: 48000,
|
||||
bitDepth: 16,
|
||||
volume: 100
|
||||
})
|
||||
});
|
||||
|
||||
const chunk = Buffer.alloc(3840);
|
||||
this.silenceInterval = setInterval(() => {
|
||||
@@ -82,7 +88,7 @@ export class MixedStream {
|
||||
});
|
||||
|
||||
this.player.play(resource);
|
||||
this.player.on('error', error => {
|
||||
this.player.on('error', (error) => {
|
||||
console.error('Error: ', error.message);
|
||||
});
|
||||
}
|
||||
@@ -102,17 +108,22 @@ export class MixedStream {
|
||||
channels: 2,
|
||||
sampleRate: 48000,
|
||||
bitDepth: 16,
|
||||
volume: 100,
|
||||
volume: 100
|
||||
});
|
||||
|
||||
const transcoder = new prism.FFmpeg({
|
||||
args: [
|
||||
'-analyzeduration', '0',
|
||||
'-loglevel', '0',
|
||||
'-f', 's16le',
|
||||
'-ar', '48000',
|
||||
'-ac', '2',
|
||||
],
|
||||
'-analyzeduration',
|
||||
'0',
|
||||
'-loglevel',
|
||||
'0',
|
||||
'-f',
|
||||
's16le',
|
||||
'-ar',
|
||||
'48000',
|
||||
'-ac',
|
||||
'2'
|
||||
]
|
||||
});
|
||||
let totalBytes = 0;
|
||||
|
||||
@@ -130,7 +141,7 @@ export class MixedStream {
|
||||
transcoder.destroy();
|
||||
resolve();
|
||||
}, durationMs);
|
||||
})
|
||||
});
|
||||
|
||||
transcoder.on('error', () => {
|
||||
this.mixer.removeAudioinput(mixerInput);
|
||||
@@ -176,7 +187,8 @@ export class AudioStreamManager {
|
||||
static #instance: AudioStreamManager | null = null;
|
||||
|
||||
public static get get(): AudioStreamManager {
|
||||
if (!AudioStreamManager.#instance) AudioStreamManager.#instance = new AudioStreamManager();
|
||||
if (!AudioStreamManager.#instance)
|
||||
AudioStreamManager.#instance = new AudioStreamManager();
|
||||
return AudioStreamManager.#instance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user