From f14193b93a881d4c5bb383419d0f57fbecb6451b Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Sat, 20 Jan 2018 12:48:28 +0000 Subject: [PATCH] Document examples --- src/client/voice/util/PlayInterface.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/voice/util/PlayInterface.js b/src/client/voice/util/PlayInterface.js index 1c3eaeef1..07130c31b 100644 --- a/src/client/voice/util/PlayInterface.js +++ b/src/client/voice/util/PlayInterface.js @@ -27,10 +27,19 @@ class PlayInterface { * Play an audio resource. * @param {ReadableStream|string} resource The resource 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} */ play(resource, options = {}) { - const type = options.type || 'unknown'; + const type = resource instanceof Broadcast ? options.type || 'unknown' : 'broadcast'; if (type === 'unknown') { return this.player.playUnknown(resource, options); } else if (type === 'converted') { @@ -53,3 +62,5 @@ class PlayInterface { } module.exports = PlayInterface; + +const Broadcast = require('../VoiceBroadcast');