Skip to main content
gamedev.net
🔒 Locked

[java] Getting OGG/Mp3 playback...

Started by H_o_p_s 5 replies 950+ views
Original Post
H_o_p_s
H_o_p_s
I've been trying for the last couple of days to get OGG playback working in Java without success... I'm trying to use JOrbis, but frankly the documentation stinks. I've also tried jsresources.org's Audio Player but can't get the triton plugins installed... I'm trying to make a simple commandline driven ogg player. 'java someplayer someclip.ogg' And for the life of me I can not get this to work. If there are any good examples/tutorials/advice please let me know about them! H_o_p_s
BRING BACK THE BLACK (or at least something darker)
Marianne
Marianne
well it'd help us solve this problem if you told us what doesn't work! do you get any error messages?
H_o_p_s
H_o_p_s
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:786)
at DecodingAudioPlayer.main(DecodingAudioPlayer.java:115)
### cannot read input file: /Users/Hops/Desktop/mp3Test.mp3
Exception in thread "main" java.lang.NullPointerException
at DecodingAudioPlayer.main(DecodingAudioPlayer.java:125)
Process java exited with code 1

And I have the triton plugins in the class path...
BRING BACK THE BLACK (or at least something darker)
Darragh
Darragh
I don't know anything about JOrbis- so I can't really help you there, but if you want to get some MP3s up and running then I can provide you with some source code which shows how to use another API- 'JSmooth'. I'm using this API at the moment for playing some MP3s in the game i'm working on- and it does the job pretty well. Let me know if you're interested..
H_o_p_s
H_o_p_s
I am very interested! Anything to get me away from midi and wav files...
BRING BACK THE BLACK (or at least something darker)
Darragh
Darragh
No problem, i'll send you on the source code so..

Just a few short steps and you should have it working ( hopefully ! )

1 - Download the JLayer API from: http://www.javazoom.net/javalayer/sources.html
2 - Unzip the download file and place the folder called 'javazoom' in your main class directory.
3 - Call the 'init()' method in the MP3Sound class, from somewhere in your main program This sets up the MP3Player and gets it ready for playing. It also scans a chosen directory for a list of MP3s which you can use for random playback.
4 - Call the 'playSongRandom()' method then to begin playing a random song from the list of MP3s available, there is also another method playSong(String songName) if you want to be more specific and not have a random track play.

That should be it.. The source itself should be mostly self explanatory, but if you have any questions then just let me know.

Regards,
Darragh


H_o_p_s
H_o_p_s
Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you!

I've got it working!

If I could rate you higher I would!
BRING BACK THE BLACK (or at least something darker)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.