Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stream mp3 using pure Java

Tags:

java

stream

mp3

Is it possible to stream mp3s using pure Java? If so, what are the best resources to implement this.

If not, are any other music formats streamable using Java only?

like image 349
npellow Avatar asked Mar 18 '09 11:03

npellow


People also ask

How do I stream mp3 files?

To stream an mp3 file, upload your mp3 file to your public-html directory (or to a subdirectory of your public-html directory) preferably in MP3 format. OGG is also supported in Chrome and Firefox, but not in Safari and Internet Explorer. For example: Create a subdirectory (e.g., media) in your public-html directory.

Can you play mp3 in Java?

It turned out that Java 7 has support for mp3 files: String bip = "example. mp3"; Media hit = new Media(bip); MediaPlayer mediaPlayer = new MediaPlayer(hit); mediaPlayer. play();


1 Answers

As Mario says, JMF - Java Media Framework is a good starting point.

What Mario does not say is that Sun killed MP3 support since 2.1.1b as detailed in the "My Lost Streaming MP3 Article" blog entry.

So you need to add a plugin to support MP3:
the JMF Formats list does mention MP3 (under the ACM -- Window's Audio Compression Manager support -- section), but only for Windows, and not with JMF alone.

like image 98
VonC Avatar answered Oct 11 '22 04:10

VonC