問題描述
所以基本上我有 這個(gè)問題,我得到了一個(gè)解決方案";但它沒有用,所以我找到了一個(gè)修復(fù)程序,將 highWaterMark 添加到我的代碼中,以便流保持打開更長(zhǎng)時(shí)間或任何 idk,所以這就是我的代碼目前的樣子
So basically i had this issue and i got given a "solution" but it didn't work, so i found a fix and that was adding highWaterMark to my code so the stream stays open longer or whatever idk, so this is what my code looks like currently
const dispatcher = serverQueue.connection.play(ytdl(song.url, {
filter:"audioonly",
highWaterMark: 1<<25 })
.on("finish", () => {
const shiffed = serverQueue.songs.shift();
if (serverQueue.loop === true) {
serverQueue.songs.push(shiffed);
};
play(guild, serverQueue.songs[0]);
})
.on("error", error => console.error(error)));
dispatcher.setVolume(serverQueue.volume / 100);
但是現(xiàn)在我的問題是這首歌會(huì)播放大約 10 秒然后就停止了,我不知道為什么這只會(huì)讓我的問題變得更糟,因?yàn)閷?duì)于我看到的每個(gè)使用此解決方案的人來說,它都非常有效.
but now my issue is that the song will play for like 10 seconds then just stop, i have no idea why this just made my issue worse because for everyone i seen that used this solution it worked perfectly.
推薦答案
您可能想嘗試將流的類型更改為 opus :
You might want to try to change the type of the stream to opus :
serverQueue.connection.play(ytdl(song.url, { filter:"audioonly", type: 'opus' });
這篇關(guān)于Discord Music bot - 我播放的歌曲在結(jié)束前 10-20 秒停止,所以我添加了 highWaterMark,現(xiàn)在這首歌幾乎沒有播放的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!