2

I'm trying to play mp3-files using the JLayer Class Player. After starting the Thread containing myPlayer.play() you can hear some hundred milliseconds of the beginning of the song and then the player interrupts and I get the following error messages:

> javazoom.jl.decoder.BitstreamException: Bitstream errorcode 102   at
> javazoom.jl.decoder.Bitstream.newBitstreamException(Unknown Source)
>   at javazoom.jl.decoder.Bitstream.readFrame(Unknown Source)  at
> javazoom.jl.player.Player.decodeFrame(Unknown Source)     at
> javazoom.jl.player.Player.play(Unknown Source)    at
> javazoom.jl.player.Player.play(Unknown Source)    at
> controller.PlayController.run(PlayController.java:51)     at
> java.lang.Thread.run(Thread.java:724)

I've searched the internet for solutions and I've read that this error could occur due to problems with certain .mp3-files, but .wav- or .wma-files weren't either accepted. Does anyone know how I can get the player working? Thanks in advance

  • JLayer works with almost any mp3 file - exceptions would be "free bitrate" (never seen such a file). Error code 102 indicates a read error from the stream. You probably started the player (which runs in its own thread) and then closed the input stream from the main thread. Simple coding error. – Durandal Nov 22 '13 at 18:17
  • I have a `BufferedInputStream bis` in my code and when I comment out `bis.close()` the player works as it should. Can you explain why closing the input stream produces an error? Furthermore it's not possible the close the player JFrame, although i've put the `myPlayer.play()` assignment in a seperate thread. how can i get the application to be able to be closed? – user3021755 Nov 22 '13 at 18:35
  • Once you call close() on an InputStream you can't read any more from it. JLayer reads the mp3 *while* playing it, so the stream must not be closed before it finished playing (closing it is like someone pulling the book you're reading from your hands). As for why your Frame does not close, show some code. You either do not handle the close event properly or you block the Swing thread. – Durandal Nov 22 '13 at 18:40
  • Okay, I found the error. Simple coding error with the thread ;-) – user3021755 Nov 22 '13 at 18:50

1 Answers1

0

I've gotten some distortion using Javazoom on Linux. a comment above about interrupting the input stream prompted me to keep the Player class instantiated and close the buffered input stream before opening every time, That seemed to help, but I'm not sure. It came back but less often and now goes away if I close Firefox.

Thanks for the insight about the input streams getting interrupted.