DV8FromTheWorld / JDA-Player

Extension library for JDA (or D4J) that provides an Java wrapping of Youtube-dl, FFmpeg and FFprobe for use as an AudioProvider.
Apache License 2.0
14 stars 5 forks source link

Calling stop() when a song is playing from a remote source throws an error #11

Closed FetchLeo closed 8 years ago

FetchLeo commented 8 years ago

Hi, it's me again. Sorry to bug you guys.

I've just run into another (minor) issue with the player. When I play a song from a remote source (e.g. Soundcloud), and then stop the player while the song is playing, I get an error in the console:

[Fatal] [JDAPlayer]: Encountered an exception:
[Fatal] [JDAPlayer]: java.io.IOException: Broken pipe
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:326)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
    at net.dv8tion.jda.player.source.RemoteStream$1.run(RemoteStream.java:76)

All I'm doing is calling player.stop(); nothing weird. I can't seem to figure out if this is just me not knowing how to properly use the library, or something wrong with my setup.

Note: The song does indeed stop, but I still get this error. This is the offending code (from net.dv8tion.jda.player.source.RemoteStream):

while(!this.isInterrupted() && (amountRead1 = fromYTDL.read(e)) > -1) {
    toFFmpeg.write(e, 0, amountRead1);
}

It seems like toFFmpeg.write() is what's causing the error.

Once again, sorry to bug you guys. I'm just really confused right now.

Thanks!

MinnDevelopment commented 8 years ago

This has been a known issue and is not planned to be fixed it seems.

DV8FromTheWorld commented 8 years ago

It isn't really an error, but currently the stack trace is being output. I thought I fixed that stuff. Hrm.

FetchLeo commented 8 years ago

I'd just like to know if there's any way to fix this.

By the way, I figured out why it's being logged (at least I think): This code in RemoteStream seems to be causing the exception to be logged:

} catch (IOException var17) {
    // HERE vvvvvvvvvvvvvvvvvv
    if(!var17.getMessage().contains("The pipe has been ended")) {
        // and here....
        AbstractMusicPlayer.LOG.log(var17);
    }
}

You're looking for "The pipe has been ended" in the message, when you should be looking for "Broken pipe". Because the message never contains "The pipe has been ended", it always logs the exception.

Not sure if this really matters (I know this has the "won't fix" label), but I figured I would update you guys just in case it gets fixed.

DV8FromTheWorld commented 8 years ago

uh. right. I thought i fixed this but instead I just changed how it was printing. I've fixed this in the latest commit. grab the latest version 0.2.2_17

FetchLeo commented 8 years ago

Thanks!