mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 04:00:42 +00:00
docs update to topics/voice playFile example (#1716)
* Update voice.md * Update voice.md * fixed my grammar * added requested spaces
This commit is contained in:
parent
b2ab947180
commit
27196c2f9f
1 changed files with 8 additions and 3 deletions
|
|
@ -46,11 +46,17 @@ have obtained a voice connection, we can start streaming audio to it. The follow
|
||||||
file:
|
file:
|
||||||
|
|
||||||
**Playing a file:**
|
**Playing a file:**
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// To play a file, we need to give an absolute path to it
|
// Use an absolute path
|
||||||
const dispatcher = connection.playFile('C:/Users/Discord/Desktop/myfile.mp3');
|
const dispatcher = connection.playFile('C:/Users/Discord/Desktop/myfile.mp3');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Or an dynamic path
|
||||||
|
const dispatcher = connection.playFile('./myfile.mp3');
|
||||||
|
```
|
||||||
|
|
||||||
Your file doesn't have to be just an mp3; ffmpeg can convert videos and audios of many formats.
|
Your file doesn't have to be just an mp3; ffmpeg can convert videos and audios of many formats.
|
||||||
|
|
||||||
The `dispatcher` variable is an instance of a `StreamDispatcher`, which manages streaming a specific resource to a voice
|
The `dispatcher` variable is an instance of a `StreamDispatcher`, which manages streaming a specific resource to a voice
|
||||||
|
|
@ -84,8 +90,7 @@ this can also be used:
|
||||||
```js
|
```js
|
||||||
connection.playStream(myReadableStream);
|
connection.playStream(myReadableStream);
|
||||||
|
|
||||||
// If you don't want to use absolute paths, you can use
|
// You can use fs.createReadStream to create an ReadableStream
|
||||||
// fs.createReadStream to circumvent it
|
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const stream = fs.createReadStream('./test.mp3');
|
const stream = fs.createReadStream('./test.mp3');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue