From 1cdee7b48a13f571f563e7d8fe474908b64c4a5b Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Wed, 13 Jun 2018 21:16:14 +0100 Subject: [PATCH] voice: reimplement seek option (#2572) --- src/client/voice/player/BasePlayer.js | 3 +++ src/client/voice/util/PlayInterface.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/voice/player/BasePlayer.js b/src/client/voice/player/BasePlayer.js index cb2198ea5..400f4bcef 100644 --- a/src/client/voice/player/BasePlayer.js +++ b/src/client/voice/player/BasePlayer.js @@ -44,7 +44,10 @@ class BasePlayer extends EventEmitter { this.destroyDispatcher(); const isStream = input instanceof ReadableStream; + const args = isStream ? FFMPEG_ARGUMENTS : ['-i', input, ...FFMPEG_ARGUMENTS]; + if (options.seek) args.push('-ss', String(options.seek)); + const ffmpeg = new prism.FFmpeg({ args }); const streams = { ffmpeg }; if (isStream) { diff --git a/src/client/voice/util/PlayInterface.js b/src/client/voice/util/PlayInterface.js index c2285c241..17318253b 100644 --- a/src/client/voice/util/PlayInterface.js +++ b/src/client/voice/util/PlayInterface.js @@ -6,7 +6,7 @@ const { Error } = require('../../../errors'); * Options that can be passed to stream-playing methods: * @typedef {Object} StreamOptions * @property {StreamType} [type='unknown'] The type of stream. - * @property {number} [seek=0] The time to seek to + * @property {number} [seek=0] The time to seek to, will be ignored when playing `ogg/opus` or `webm/opus` streams * @property {number|boolean} [volume=1] The volume to play at. Set this to false to disable volume transforms for * this stream to improve performance. * @property {number} [passes=1] How many times to send the voice packet to reduce packet loss