playFile/playStream fails to play short (<1 sec) files
See original GitHub issueMy bot has a soundboard command where the bot joins a voice channel, plays a simple mp3 file, then leaves.
On 8.x I had no trouble but I couldn’t figure out why some mp3s weren’t launching on 9.x and I narrowed it down to the ones that were that short(less than 1 second long).
I’ve tested it on 3 different mp3s and none of them work, however other mp3s longer than this seem to work correctly.
vc
.join()
.then(conn => {
console.log(fileName);
const intent = conn.playFile(fileName, {volume: Config.AudioVolume});
intent.on('debug', i => {
console.log(i);
});
intent.on('start', () => {
console.log("playing " + fileName);
});
intent.once('end', () => {
//intent usually ends before it's acutally done outputting to the websocket
setTimeout(function() {
message
.delete()
.catch(merr => {
console.log("Deleted message after voice: " + merr);
}
);
conn.channel.leave();
}, 800);
});
intent.once('error', errWithFile => {
console.log("err with file: " + errWithFile);
util.botReply(message, "There was an error playing your soundbite.");
conn.channel
.leave()
.catch(function(e) {
console.log("err leaving voice channel: " + e);
}
);
});
})
.catch(e => {
console.log("err joining voice: " + e);
}
);
In this code example, normal mp3s play and then the bot leaves the channel. Printing out something like
/some/path/potg.mp3 playing /some/path/potg.mp3 Triggered terminal state end - stream is now dead
However with <1s mp3, I get only
/some/path/short.mp3
And nothing follows, the music intent never fires “start”.
I can’t upload mp3s here, I can gladly link the ones that I have tested(with permission to do so).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:20 (16 by maintainers)
Really happy to announced this is finally fixed on the
indev-prism
branch! 🎉While this isn’t completely ready for release, it’s fairly stable and it simplifies a lot of voice internals. It uses
prism-media
which moves a lot of the audio transcoding code that used to exist in discord.js into a separate module. It has a significant performance improvement when streaming from files, and should also allow streaming from URLs!Anyway, I’ll close this issue once the fix is released 😃
Taking another look at voice soon, should have this fixed soon 😃