Here is the stack trace:
java.io.IOException: Resetting to invalid mark
at java.io.BufferedInputStream.reset(BufferedInputStream.java:433)
at org.tritonus.share.sampled.file.TAudioFileReader.getAudioInputStream(TAudioFileReader.java:324)
at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source)
at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1179)
at javazoom.jlgui.basicplayer.BasicPlayer.initAudioInputStream(Unknown Source)
at javazoom.jlgui.basicplayer.BasicPlayer.initAudioInputStream(Unknown Source)
at javazoom.jlgui.basicplayer.BasicPlayer.open(Unknown Source)
at BasicPlayerDemo.play(BasicPlayerDemo.java:49)
at BasicPlayerDemo.main(BasicPlayerDemo.java:24)
Seems that other people are also having this problem:
- Jukebox: no sound?
- Stack trace on player state update
Any reason for this? I am trying to make a simple Java Swing music player using JavaZoom classes.
There is a solution for this problem at (pelzkuh.de blog) It is in German but mainly says that the cause is an outdated library mp3spi1.9.4.jar. You have to replace it with the new one mp3spi1.9.5.jar. Links are provided in the pelzkuh blog entry.
The thread with answers alludes to something I have struck before.
- MP3 is hardly any sort of 'standard' - with many extensions to the basic format. Java Sound based apps. will generally only deal with some of those types, and even if that were not the case
- Media players generally go to considerable effort to play 'any rubbish file' (including invalid ones) thrown at them. It would be a major effort to replicate that ability.
So is there no simple solution to this? Should I just ignore such MP3s?
- No
- That sounds pretty easy (simple). Skip them & go to the next track. Pop a dialog or add it to a log if the user chooses 'high feedback' in the player options.
Actually I'm making a mini-project for my college, so it doesn't look good if this player doesn't play certain files.
I'd check that with the people marking it. If they are expecting you to provide support for 'any file thrown at it' in a college project, they need to pull their head out of the clouds. I'll bet I could make files that play on one 'major player' but cause the next to lock up & die (OK.. thinking more of some recent video attempts, but the same basic principle applies). 'Handling media' is tricky.
..the college isn't expecting anything, since I chose to create this myself. I didn't know that handling media is tricky. Now if they ask, I can tell them that!
I suggest supplying the player complete with a play list and media controlled by you (and sure to be compatible with your player). You can find 3 basic, distributable MP3 tracks at my media page. Those are:
(parsable by) the JMF MP3 codec
..so JavaZoom should be able to load them as well.