node.js - Discord.js 语音机器人在播放本地 mp3 文件时中断
问题描述
我的机器人播放 mp3 声音,但在接近尾声时会中断,尤其是对于短 (<2s) 文件。
多次重装ffmpeg
client.on('message', message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '!sound') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join()
.then(connection => { // Connection is an instance of VoiceConnection
const dispatcher = connection.playFile('C:/Users/X/Desktop/my-bot/Sounds/SJW2.mp3');
dispatcher.on("end", end => {connection.disconnect});
})
.catch(console.log);
client.on('end', () => {
// The song has finished
});
没有错误,声音只是在文件末尾附近被删掉。
解决方案
尝试使用作品的声音。此外,您的主机的互联网速度会影响它。这可能是由于高延迟
推荐阅读
- php - moodle 3.6 如何使用网络服务功能获取学习者的进度
- google-cloud-platform - 安排 gcloud 命令
- php - How to add a user based link in WordPress admin menu
- ios - 当一个对象的属性同时由其他两个对象设置时,CPU 命中 %100
- sql - 如何检查表中存在的确切行?
- angular - Angular - 无法将值设置为变量
- python-3.x - Why are some attributes in .xlsx sheet not showing up in my dataframe created in Python?
- vue.js - 未知的自定义元素:
- angular - 如何使用 formcontrol 在选择框内添加占位符?
- tensorflow - Where are the images read in this classification python program?