discord.js 不播放音频文件
- 作者: 冰封的烦恼
- 来源: 51数据库
- 2022-10-21
问题描述
我正在尝试播放音频文件,但由于某种原因它没有播放任何内容,它在机器人连接后立即触发 end 事件而不是 start 事件到语音频道.
I am trying to play an audio file but, for some reason it's not playing anything, it's firing end event instead of start event, right after the bot is connected to voice channel.
client.on('message', message => {
if(message.content.startsWith('!play')) {
if(!message.member.voiceChannel) return message.channel.send('connect to voice channel first');
message.member.voiceChannel.join()
.then(connection => {
console.log("Joined voice channel!");
const dispatcher = connection.playFile(require("path").join(__dirname, './myfile.mp3'));
dispatcher.on('start', () => { //not working
dispatcher.setVolume(0.70);
console.log("Playing");
});
dispatcher.on('error', (err) => console.log(err)); //no errors
dispatcher.on('end', end => { //working fine
console.log("Finished");
console.log("End: " + end);
message.member.voiceChannel.leave()
});
});
}});
推荐答案
我从 node-modules 中删除了 ffmpeg-binaries 并安装了 ffmpeg使用 sudo apt 现在工作正常.问题是,我安装了这两个库.
I removed ffmpeg-binaries from node-modules and installed ffmpeg using sudo apt and it's working fine now. The problem was that, i had both of these libraries installed.
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
