Playing an Online mp3

2

I have a problem with playing online mp3s. I'm using latest version of javazoom's jlayer and basicplayer. Here is the exception:

Caused by: javazoom.jlgui.basicplayer.BasicPlayerException: java.io.EOFException
    at javazoom.jlgui.basicplayer.BasicPlayer.initAudioInputStream(Unknown Source)
    at javazoom.jlgui.basicplayer.BasicPlayer.open(Unknown Source)
    ... 12 more
Caused by: java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:375)
    at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:244)
    at com.sun.media.sound.WaveFileReader.getAudioFileFormat(WaveFileReader.java:85)
    at javax.sound.sampled.AudioSystem.getAudioFileFormat(AudioSystem.java:985)
    at javazoom.jlgui.basicplayer.BasicPlayer.initAudioInputStream(Unknown Source)
    ... 15 more

My java is 1.6.0_16.

Certain files cannot be player through the Internet. I have a set of mp3s, playing one after the other. Randomly one mp3 doesn't work throwing above exception. Some mp3s can be played by calling again play() method if javazoom's basicplayer, but others can never be played online.

I was able to find this post but I doubt if this really relates to my directx version or something.

Mohsen

Mohsen

Posted 2009-10-26T20:39:03.797

Reputation: 121

Answers

0

If you are streaming over HTTP, the web server seem to be closing the connection immediately without delivering any data. Some servers delivering MP3 over HTTP evaluate the request headers in an attempt to prevent tools from grabbing the media stream and will e.g. only deliver content if the request headers match a known media player. If you have a network sniffing tool and know a media player, which is working with the server you are trying to get content from, you can of course set the HTTP request headers in your Java program, so that the server thinks that you are using the regular media player.

jarnbjo

Posted 2009-10-26T20:39:03.797

Reputation:

The server is apache2, but request header cannot be the source of the problem, since a certain mp3 randomly works and doesn't work. – None – 2009-10-26T20:52:12.100

0

Can you download the file at that URL?

EOF is "end of file". It's losing the stream, or there's just no file there to get.

Dean J

Posted 2009-10-26T20:39:03.797

Reputation: 201

Yes I can, and the player works well when playing offline the same file. – None – 2009-10-26T20:54:36.777

-1

I have had similar issues when the input or output streams are not managed properly... are you wrapping everything in try/catch/finally and closing all of the streams properly?

Some might work if you luck out and the buffer gets all of the content.

You might also try flushing (.flush()) the input stream.

Hope this helps.

cjstehno

Posted 2009-10-26T20:39:03.797

Reputation: 99

-1: This isn't a program he made himself. – Wuffers – 2011-02-11T21:29:11.387