diff --git a/docs/docs_voiceconnection.rst b/docs/docs_voiceconnection.rst index 6c99f5430..8a5b9f5cb 100644 --- a/docs/docs_voiceconnection.rst +++ b/docs/docs_voiceconnection.rst @@ -64,7 +64,7 @@ Plays a file to the voice channel. The file can be in practically any format; if In addition to a file path local to your computer, it can also accept a URL, however this is not recommended as the entire content of the URL will be read before any playback starts. This can cause delays from seconds to minutes - you can use `playRawStream` with a Stream obtained from the URL instead. -The `options` object can be used to control playback properties, currently, it only allows setting the volume using the `volume` property, which can be in any of the following formats: +The `options` object can be used to control playback properties, currently, it currently allows setting the seek (in seconds) using the `seek` property, and the volume using the `volume` property, which can be in any of the following formats: - A number representing the linear change in volume; 1 is equal to no change, 0 is completely silent, 0.5 is half the regular volume and 2 is double the regular volume. - A string representing the linear change in volume, if this is more convenient for you. diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index 3bb45e95b..f6d21804c 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -81,7 +81,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeStream = function encodeStream(stream, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); stream.pipe(enc.stdin); @@ -107,7 +107,7 @@ var AudioEncoder = (function () { AudioEncoder.prototype.encodeFile = function encodeFile(file, options) { var self = this; return new Promise(function (resolve, reject) { - var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); + var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), '-ss', (options.seek || 0), '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] }); enc.stdout.once("readable", function () { resolve({ diff --git a/src/Voice/AudioEncoder.js b/src/Voice/AudioEncoder.js index 6c74d7423..0ec6202aa 100644 --- a/src/Voice/AudioEncoder.js +++ b/src/Voice/AudioEncoder.js @@ -66,6 +66,7 @@ export default class AudioEncoder { '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), + '-ss', (options.seek || 0), '-ac', 2, 'pipe:1' ], {stdio: ['pipe', 'pipe', 'ignore']}); @@ -100,6 +101,7 @@ export default class AudioEncoder { '-f', 's16le', '-ar', '48000', '-af', 'volume=' + (options.volume || 1), + '-ss', (options.seek || 0), '-ac', 2, 'pipe:1' ], { stdio: ['pipe', 'pipe', 'ignore'] });