Java game mp3 and ogg

After countless hours of searching and reading through a lot of source code, I am at a dead end and I need your help. As the name implies, I'm trying to create a (yet another) Java music player. I came across a Javazoom project, and it kind of works, but it doesn't. My goal is to play mp3 and ogg files. Playing mp3 files works without problems: I can get all the information (ID3 tags and general information of the audio file), and I can perform all the necessary actions (play, pause, resume, search, etc.). But when I try to play ogg files, I can only get one of two things: either I can play the file but not get the file information, or get all the information, but I can’t play the file. My code is basically an updated version of the BasicPlayer class, I tried to look at the jlGui player to see how it manages to be compatible with all formats, but I just got completely lost in this code.

My MediaPlayer Code

Here is the command I use to compile the program:

javac -cp lib\jl1.0.1.jar;lib\jogg-0.0.7.jar;lib\jorbis-0.0.15.jar;liblog4j-1.2.16.jar;lib\mp3spi1.9.5.jar;lib\tritonus_share-0.3.6.jar;libvorbisspi1.0.3.jar MediaPlayer.java

When I execute it with

java -cp .;lib\jl1.0.1.jar;lib\jogg-0.0.7.jar;lib\jorbis-0.0.15.jar;liblog4j-1.2.16.jar;lib\mp3spi1.9.5.jar;libtritonus_jorbis-0.3.6.jar;libtritonus_share-0.3.6.jar;libvorbisspi1.0.3.jar MediaPlayer d:/foo.mp3

, d:/foo.ogg, :

167 [main] DEBUG MediaPlayer  - Target format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
Exception in thread "main" java.lang.RuntimeException: Error initializing stream: java.lang.IllegalArgumentException: Unsupported conversion: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, stereo, 1 bytes/frame, 16000.0 frames/second,
    at MediaPlayer.initAudioStream(MediaPlayer.java:302)
    at MediaPlayer.open(MediaPlayer.java:663)
    at MediaPlayer.main(MediaPlayer.java:772)

262 ( createLine() initAudioStream()) , ,

170 [main] DEBUG MediaPlayer  - Target format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported conversion: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, stereo, 1 bytes/frame, 16000.0 frames/second,
    at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
    at MediaPlayer.createLine(MediaPlayer.java:362)
    at MediaPlayer.initLine(MediaPlayer.java:392)
    at MediaPlayer.startPlayback(MediaPlayer.java:483)
    at MediaPlayer.play(MediaPlayer.java:672)
    at MediaPlayer.main(MediaPlayer.java:773)

lib\tritonus_jorbis-0.3.6.jar , ogg, .

, ... .

+5
4

, . , , .

, . , .

0

, javax.sound.sampled jogg . , FFsampledSP . FFmpeg Win OSX, javax.sound.sampled.

0

, mp3spi 1.9.5-1 vorbisspi 1.0.3-1. -share 0.3.7-2 0.3.7-1 , vorbisspi .

I used Maven dependencies. The full working solution is here: http://odoepner.wordpress.com/2013/07/19/play-mp3-or-ogg-using-javax-sound-sampled-mp3spi-vorbisspi/

0
source

All Articles