mirror of
https://github.com/danbulant/discord.js
synced 2026-06-09 09:42:22 +00:00
Document examples
This commit is contained in:
parent
ef02bd2935
commit
f14193b93a
1 changed files with 12 additions and 1 deletions
|
|
@ -27,10 +27,19 @@ class PlayInterface {
|
||||||
* Play an audio resource.
|
* Play an audio resource.
|
||||||
* @param {ReadableStream|string} resource The resource to play.
|
* @param {ReadableStream|string} resource The resource to play.
|
||||||
* @param {StreamOptions} [options] The options to play.
|
* @param {StreamOptions} [options] The options to play.
|
||||||
|
* @example
|
||||||
|
* // Play a local audio file
|
||||||
|
* connection.play('/home/hydrabolt/audio.mp3', { volume: 0.5 });
|
||||||
|
*
|
||||||
|
* // Play a ReadableStream
|
||||||
|
* connection.play(ytdl('https://www.youtube.com/watch?v=ZlAU_w7-Xp8', { filter: 'audioonly' }));
|
||||||
|
*
|
||||||
|
* // Using different protocols: https://ffmpeg.org/ffmpeg-protocols.html
|
||||||
|
* connection.play('http://www.sample-videos.com/audio/mp3/wave.mp3');
|
||||||
* @returns {StreamDispatcher}
|
* @returns {StreamDispatcher}
|
||||||
*/
|
*/
|
||||||
play(resource, options = {}) {
|
play(resource, options = {}) {
|
||||||
const type = options.type || 'unknown';
|
const type = resource instanceof Broadcast ? options.type || 'unknown' : 'broadcast';
|
||||||
if (type === 'unknown') {
|
if (type === 'unknown') {
|
||||||
return this.player.playUnknown(resource, options);
|
return this.player.playUnknown(resource, options);
|
||||||
} else if (type === 'converted') {
|
} else if (type === 'converted') {
|
||||||
|
|
@ -53,3 +62,5 @@ class PlayInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PlayInterface;
|
module.exports = PlayInterface;
|
||||||
|
|
||||||
|
const Broadcast = require('../VoiceBroadcast');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue