discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
328 stars 112 forks source link

Arbitrary stream randomly ends at the middle of the track #141

Closed skick1234 closed 3 years ago

skick1234 commented 3 years ago

Please describe the problem you are having in as much detail as possible:

Arbitrary stream randomly ends at the middle of the track. I cannot reproduce it but sometimes it happened with the same URL. I check the URL after the stream ended. It is still downloadable and plays the full track after downloading on my PC.

Further details:

twlite commented 3 years ago

might be related to #124

amishshah commented 3 years ago

Can you share your code? And also whether or not any errors are emitted from the player

skick1234 commented 3 years ago

Can you share your code? And also whether or not any errors are emitted from the player

The stream stop and AudioPlayer change the state to Idle. Error event is not emitted.

I don't think it is due to my code

<AudioPlayer>.play(createAudioResource("stream url", {
  inputType: StreamType.Arbitrary,
  inlineVolume: true,
})).on("stateChange", (oldState, newState) => {
  if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
    // Finish song
  }
}).on("error", console.error);

It randomly happens, not every time play.

amishshah commented 3 years ago

Can you see if the suggestions in this thread fix your issue:

https://github.com/discordjs/voice/issues/117

skick1234 commented 3 years ago

Can you see if the suggestions in this thread fix your issue:

https://github.com/discordjs/voice/issues/117

I created this issue because of arbitrary stream .-. So it is not recommended to use this?

amishshah commented 3 years ago

I think your issue is due to using FFmpeg, by default we don't provide any reconnect parameters since that would be opinionated.

I am looking into a way to make this easier to customise, but for now, you'd have to create your own FFmpeg with reconnect parameters as shown in the issue above (your issue has the same symptoms as the issue above, so I'm assuming it's due to that)

skick1234 commented 3 years ago

I think your issue is due to using FFmpeg, by default we don't provide any reconnect parameters since that would be opinionated.

Yes, my bot uses raw stream with reconnect params doesn't have that problem.

I am looking into a way to make this easier to customise

Sounds promising, should I open the issue till you solve this?

amishshah commented 3 years ago

Sure, opening an issue would be useful 👍

skick1234 commented 3 years ago

I mean open this issue :v anyway, hope you find out a good solution soon. I have no idea :>

amishshah commented 3 years ago

Closing this issue since it seems to be resolved using the above steps, and is a duplicate of https://github.com/discordjs/voice/issues/117.

Will track the overall issue in a new separate issue.