mirror of
https://github.com/danbulant/discord.js
synced 2026-06-04 23:31:04 +00:00
Merge branch 'voice-rewrite' of https://github.com/hydrabolt/discord.js into voice-rewrite
This commit is contained in:
commit
5879cd7c8e
5 changed files with 17 additions and 12 deletions
|
|
@ -41,7 +41,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
playFile(file, options) {
|
playFile(file, options) {
|
||||||
return this.player.playUnknownStream(`file:${file}`, options);
|
return this.player.playUnknown(file, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,7 +51,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||||
* @returns {StreamDispatcher}
|
* @returns {StreamDispatcher}
|
||||||
*/
|
*/
|
||||||
playArbitraryInput(input, options) {
|
playArbitraryInput(input, options) {
|
||||||
return this.player.playUnknownStream(input, options);
|
return this.player.playUnknown(input, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,7 +71,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
playStream(stream, options) {
|
playStream(stream, options) {
|
||||||
return this.player.playUnknownStream(stream, options);
|
return this.player.playUnknown(stream, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -457,7 +457,7 @@ class VoiceConnection extends EventEmitter {
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
playFile(file, options) {
|
playFile(file, options) {
|
||||||
return this.player.playUnknownStream(`file:${file}`, options);
|
return this.player.playUnknown(file, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -467,7 +467,7 @@ class VoiceConnection extends EventEmitter {
|
||||||
* @returns {StreamDispatcher}
|
* @returns {StreamDispatcher}
|
||||||
*/
|
*/
|
||||||
playArbitraryInput(input, options) {
|
playArbitraryInput(input, options) {
|
||||||
return this.player.playUnknownStream(input, options);
|
return this.player.playUnknown(input, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -487,7 +487,7 @@ class VoiceConnection extends EventEmitter {
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
playStream(stream, options) {
|
playStream(stream, options) {
|
||||||
return this.player.playUnknownStream(stream, options);
|
return this.player.playUnknown(stream, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
const { Readable: ReadableStream } = require('stream');
|
||||||
const prism = require('prism-media');
|
const prism = require('prism-media');
|
||||||
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
|
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
|
||||||
|
|
||||||
|
|
@ -39,10 +40,14 @@ class BasePlayer extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playUnknownStream(stream, options) {
|
playUnknown(input, options) {
|
||||||
this.destroyDispatcher();
|
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 });
|
return this.playPCMStream(ffmpeg, options, { ffmpeg });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
typings
2
typings
|
|
@ -1 +1 @@
|
||||||
Subproject commit 697fc933de90209b81b69bd0fe87883e3c7a217d
|
Subproject commit 5131e88ffe0b61c2f69318e53e54a3e3edec6f1e
|
||||||
Loading…
Reference in a new issue