AudioPlayerState randomly turns to Idle after a while
Question was too long for discord, I made a stack overflow question and here's the link: https://stackoverflow.com/questions/77960972/discord-bot-player-state-randomly-changing-to-idle-and-therefore-stopping-playba
Stack Overflow
Discord bot player state randomly changing to idle and therefore st...
I know this has been asked before, under different titles. But yet none of the questions could answer my specific problem
Okay, so this is a stupid problem. My discord.js bot randomly leaves the vo...
67 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!dJs v14.14.1
nodeJS v20.11.0
i'm starting to think the problem is in the track itself
i removed the connection.destroy() line and it just stops playing now
and all logs say that the track is finished
even though it's not
Well, it finished in some way
what way
the track wasnt done
There's no more packets to be read, at least Discord.js can't find any more
and i don't suppose this is a network issue because i tried it on an online host but it just increased the time before cutting off
Have you tried to play the downloaded audio directly into your PC?
umm no
because the audio isn't the same all the time
You should give a try to playing it as a local file
So it may be the actual end for the downloaded stream
sorry for getting religion in, but the audio plays a different surah (chapter) of the quran depending on what the user chooses. I use a cdn made for that and the url is formatted like this:
https://cdn.islamic.network/quran/audio-surah/128/${readerName}/${surahNumber}.mp3
It downloads an mp3 so i'm sure it's correctly formattedIt shouldn't matter what chapter it is. I'm mostly talking about downloading the mp3 that cuts into your PC and see the actual end with some player
and no because i actually memorized the surahs that i play, it's not the end. And i open https://quran.com/36 (36 is the chapter i usually test on) and follow along with it to see when it cuts off
Quran.com
Surah Ya-Sin - 1-83 - Quran.com
Read and listen to Surah Ya-Sin. The Surah was revealed in Mecca, ordered 36 in the Quran. The Surah title means "Ya Sin" in English and consists of 8...
all of them cut
if theyre longer than 2 minutes or something
exactly
129400ms
is the time where none of them cut before
all of them cut after or on that time (from my assumptions), probably because a few-second mp3 doesn't take too much resourcesIf you download them, and play as a local file, does it work or still cut?
Seems more like a network issue
.
sure let me try
At least on my PC it took several seconds for it even start to play, so I suppose this could be happening while playing
yeah that happens
Not necessarily from your side, but the website's part
but it's not music so people wait for it to load and then they listen
The website take long to send data, and all the data be read may be confused as an end by djs
Well, if it is or not, it's an issue here as it may be confused with an end
well actually, it seems like the website (CDN) i'm using is segmentationally getting the audio, because the loading bar gets longer, and the second stopwatch increases as i listen
I got the entire stream when I got the url from the website
17m of audio
what url did you try?
https://cdn.islamic.network/quran/audio-surah/128/ar.ahmedalajmi/36.mp3 is what i tried on so far
oh you have the code from stack overflow
Nah
ah yes nvm
I got from the network tab
same for me, when i opened that link it loaded the whole thing
but not with the website i use
That's from the website you sent
no, the website i sent is https://cdn.islamic.network/quran/audio-surah/128/whatever
I mean this one: https://quran.com/36
Quran.com
Surah Ya-Sin - 1-83 - Quran.com
Read and listen to Surah Ya-Sin. The Surah was revealed in Mecca, ordered 36 in the Quran. The Surah title means "Ya Sin" in English and consists of 8...
oh yes, this website also offers audio
maybe i should change providers and see?
Uhm, I thought you were using that one ๐คฃ
You can either load all those segments into a master stream and send to djs
Or use that website that loads the entire thing
the website doesnt load the entire thing
that's the issue
I mean, the quran.com one
yes
17m isn't the entire stream?
i meant "oh alr"
17m is the entire one for the quran.com stream
Let me rephrase
ill have to wait the length of the entire chapter i suppose? some can reach 2 hours...
1. You can create a Node.js stream, and create multiple http requests filling up the stream (make it synchronous, in order)
2. You can use another source
Nope
ill have to recode the url logic because quran.com's url works differently
You'll be loading while it plays, just like your browser do
i'm not sure how to do that
Let me do an example
cuz i prefer the https://cdn.islamic.network/quran/audio-surah/128/whatever CDN because it has more and better readers
thanks
what should arr of links be?
The url of the segments
I have a working example if you want to see: https://github.com/PerformanC/NodeLink/blob/main/src/sources/soundcloud.js#L254-L294
GitHub
NodeLink/src/sources/soundcloud.js at main ยท PerformanC/NodeLink
Performant LavaLink alternative written with Node.Js - PerformanC/NodeLink
it's only one url, but it looks like it uses segments
It loads HLS, which is also segmented
let me try the network tab
You need to discover what's the url of the segments for that
oh my
same url
Take a better look
anyways i'll have to go now, 1:08 AM, thank you for helping
It may not be the same
i checked
Sure, no problem!
will you be available tmrw?
Yep