Java Media Framework - Won't Play MP3 - Codecs?

J

Jason Teagle

I just had a crack at using the JMF for the first time (never let it be said
I don't try new things!), and tried to play an MP3 file chosen at random
from my vast collection of drivel. The document at
http://java.sun.com/developer/JDCTechTips/2002/tt0219.html says:

"Playing multimedia files through the JMF libraries is simple. The key
classes are Manager and Player. The Manager has a series of createPlayer()
methods that each return a Player. After you create a Player, you tell the
Player to start playing. For basic audio playing, all you need to do is:

Player player = Manager.createPlayer(resource);
player.play();"

Well of course, we knew that was a lie, didn't we?

Dreaming that it might actually work, I did just that:

try
{
m_Player = Manager.createPlayer(new
File("c:\\temp\\testing\\test.mp3").toURL() );
m_Player.start();
}
catch (Exception e)
{
e.printStackTrace();
}

And it threw an exception:

Unable to handle format: mpeglayer3, 22050.0 Hz, 16-bit, Stereo,
LittleEndian, Signed, 8000.0 frame rate, FrameSize=32768 bits
Failed to realize: com.sun.media.PlaybackEngine@19ec4ed
Error: Unable to realize com.sun.media.PlaybackEngine@19ec4ed


Now, this was hardly a surprise. I'm assuming this is simply a codec issue -
my (3rd-party) MP3 playing program can of course handle it quite easily.

The trouble is, I don't have a clue what to do next... how do I go about
solving this? The codec must be there as far as my OS (Windows) is
concerned, otherwise the (other) MP3 player wouldn't be able to do it... so
how do I convince Java to play it? Do I have to install special JMF codecs?
Do I have to somehow tell the JMF where the native codecs are?

Note that I downloaded the cross-platform version of the JMF, since any
other version would be a mockery of the cross-platform promise of Java.
Maybe the Windows-specific version would have worked? But I don't want that,
I want it to work on all platforms. So I want to stick with this version if
possible. If it's not possible, then what is the point of JMF?

Any guidance would be appreciated.
 
A

Andrew Thompson

Jason said:
I just had a crack at using the JMF for the first time (never let it
be said I don't try new things!), and tried to play an MP3 file
chosen at random from my vast collection of drivel.

I have been waiting a long time for the JMF to
go cross platform in any useful way, but this..
http://java.sun.com/products/java-media/jmf/2.1.1/formats.html
...indicates to me that (hidden under the ACM
entry) the MP3 support is only available for
the Windows performance pack.

Looks like we have some more waiting
to do Jason. :-(

...And no, I could not be bothered downloading
it just for Windoze, for much the same reasons
you stated.

Come on Sun, get your act together!
 
J

Jason Teagle

I have been waiting a long time for the JMF to
go cross platform in any useful way, but this..
http://java.sun.com/products/java-media/jmf/2.1.1/formats.html
..indicates to me that (hidden under the ACM
entry) the MP3 support is only available for
the Windows performance pack.

Looks like we have some more waiting
to do Jason. :-(

*Bangs head on wall*

Only I could decide to strike out in a new direction and run straight into a
wall!!
..And no, I could not be bothered downloading
it just for Windoze, for much the same reasons
you stated.

Come on Sun, get your act together!

I second that!
 
J

Jason Teagle

Maybe try Javalayer?
I also found this page linked from Sun's JMF site:
http://www.tritonus.org/plugins.html

Thanks - that looks interesting. Sadly I feel the GNU public licence on it
may interfere with any future plans I might have had for a successful MP3
player {;v)

But it's worth checking how it performs under the platforms.
 
A

Andrew Thompson

Jason said:
....
But it's worth checking how it performs under the platforms.

If you go ahead with that, would you mind
reporting back? I'd be interested to know.
 
J

Jon A. Cruz

Jason said:
I have been waiting a long time for the JMF to
go cross platform in any useful way, but this.. [SNIP]

Looks like we have some more waiting
to do Jason. :-(


*Bangs head on wall*

Nope.

You've got the timeline backwards there.


It used to have MP3 playback in the pure java version, and pretty decent
at that. I think I'd get about 6% CPU usage on my PIII 500.

Then after quite a long while, Sun took it out. IIRC it was due to
patent issues with MP3's.

So it turns out you waited too long. :)
 
A

Andrew Thompson

Jon said:
Jason said:
I have been waiting a long time for the JMF to
go cross platform in any useful way, but this.. [SNIP]

Looks like we have some more waiting
to do Jason. :-(
....
....
It used to have MP3 playback in the pure java version, ....
Then after quite a long while, Sun took it out. IIRC it was due to
patent issues with MP3's.

I vaguely recall that now. The thing is, for a
long while thay were saying it would be back
as soon as the patent issue was resolved 'real
soon now'.

When I noticed it was in the Windows
Performance Pack, I came to believe
those patent issues had been resolved.

So, if they have not, why is MP3 supported
in the W.P.P.?
 
J

Jon A. Cruz

Andrew said:
When I noticed it was in the Windows
Performance Pack, I came to believe
those patent issues had been resolved.

So, if they have not, why is MP3 supported
in the W.P.P.?

My guess is that for the WPP they are just hooking into the native media
support of the platform, and thus are leveraging Microsoft's MP3 playback.

So Sun themselves are not distributing any code to do decoding of MP3s.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top