Is there anyway to play an mp3 file in java?

P.S I'm new here, hello world?

Recommended Answers

All 20 Replies

Java Media Framework (JMF) - although it's not as good as it shoul dbe.

It's all on the web - Google.

looked everywhere!!! I found JMStudio that got installed with JMF but I don't know how to use it still...

I simply do not believe you.

Oof, you really should believe me.

I searched How to use JMF instead of JMF Documentation.
Thanks for the references!!

I apologise for doubting your veracity.

JLayer can be used to play .mp3 files as well

Can you explain further please?

His comment was quite straightforward. Did you look up JLayer?

I did look it up with my best friend, google.
Didn't really find anything useful. Nothing about how to use it or anything.
Also I meant if he could explain how to use it.

Jeez guys you could give mango a lil' more help than that. S/he clearly isn't playing mp3 files for a school project or something so it's for personal edification -- just give a lil' more guidance...

Personally, I've always wondered how to play mp3 files but I have yet to figure it out, so I would appreciate a nudge in the right direction that's more than a hyperlink that I can find on google. If what I found on google was adequate, I wouldn't be wasting my time on a java forum posting my problem now would I? I'm sure the same is the case with mangopearapples. So stop being so disparaging and help a fellow programmer out.

Hi kvass
I don't think anyone here is being disparaging. Previous posts have given enough info for someone to get documentation and sample code that's relevant to the problem.
The original authors have already spent hours writing and checking those web pages, so it's unrealistic to expect someone here to duplicate that effort.
If the O/P came back with "I've tried the following program from the web and I have the following problem that I cant fix ..." then someone would help. But "I couldn't find anything on Google" points to a completely different kind of problem that's outside the scope of a Java forum.

ps. I just Googled "jlayer mp3 sample code" and the very first hit was this
http://www.cs.princeton.edu/introcs/faq/mp3/mp3.html
which has a simple sample program. Now how hard was that really?

Yay! Found out how to install JMF now. Some of the examples don't work though, something about restrictions on Eclipse but I suppose that's for the Eclipse forum.

James, thanks but I tried using the JLayer example in your link but Eclipse still gave restriction errors so I guess this was my real problem.

Thank you guys!

I personally wouldn't recommend JLayer. It's not been updated for many years, and I had a lot of problems when I tried to use it 5 or 6 years ago.
I think Eclipse "restriction errors" with Java code is well within the scope of this forum, so please do explain exactly what's happening.

OK.
It comes up with an error (red zig zag line underneath code)after I used Player player = new Player(); and this should work according to some examples.
The error is: "Access restriction: The type Player is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\ext
\jmf.jar"

I read somewhere, that you can make Eclipse ignore restrictions but I still fail at finding out how to do that :(

Also I am using JMF.

Thank you! It removed the error! I don't know whether it actually removes the error or hides it though so I'll see.

It's not really an error. Eclipse's default settings are configured for maximum safety, and sometimes you just have to tell it to chill out a bit.

I see, well thanks! Seems to be working. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.