mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
handle string ffmpeg input (#2064)
* handle string ffmpeg input * rename stuff for new purpose * file prefix isn't needed * pass tests * remove dumb spaces in dispatcher docs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const { Readable: ReadableStream } = require('stream');
|
||||
const prism = require('prism-media');
|
||||
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
|
||||
|
||||
@@ -16,7 +17,7 @@ const FFMPEG_ARGUMENTS = [
|
||||
* @extends {EventEmitter}
|
||||
*/
|
||||
class BasePlayer extends EventEmitter {
|
||||
constructor(voiceConnection) {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.dispatcher = null;
|
||||
@@ -39,10 +40,14 @@ class BasePlayer extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
playUnknownStream(stream, options) {
|
||||
playUnknown(input, options) {
|
||||
this.destroyDispatcher();
|
||||
const ffmpeg = new prism.FFmpeg({ args: FFMPEG_ARGUMENTS });
|
||||
stream.pipe(ffmpeg);
|
||||
|
||||
const isStream = input instanceof ReadableStream;
|
||||
const args = isStream ? FFMPEG_ARGUMENTS : ['-i', input, ...FFMPEG_ARGUMENTS];
|
||||
const ffmpeg = new prism.FFmpeg({ args });
|
||||
if (isStream) input.pipe(ffmpeg);
|
||||
|
||||
return this.playPCMStream(ffmpeg, options, { ffmpeg });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const prism = require('prism-media');
|
||||
const BroadcastDispatcher = require('../dispatcher/BroadcastDispatcher');
|
||||
const BasePlayer = require('./BasePlayer');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user