Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Oct 26 '09 at 21:20

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

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.

share|improve this answer
    
The server is apache2, but request header cannot be the source of the problem, since a certain mp3 randomly works and doesn't work. –  Mohsen Oct 26 '09 at 20:52
add comment

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.

share|improve this answer
    
Yes I can, and the player works well when playing offline the same file. –  Mohsen Oct 26 '09 at 20:54
add comment

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.

share|improve this answer
    
-1: This isn't a program he made himself. –  Wuffers Feb 11 '11 at 21:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.