Implement Java fm radio

can someone tell me how to implement a standalone java client to play FM radio. I searched the net, could not find anything useful. What is the whole API that we need to implement, and once the implementation is complete, how to check it?

+1
source share
2 answers

There are many radio websites that you can access using the web services API

I post a link to the most popular radio api online.

http://www.last.fm/api/radio

Use Java web services that you can easily integrate with your application.

+5
source

In addition to AurA's answer ...

You can use the JLayer library to easily read and play most Internet radio stations. This library is also cross-platform and, in addition, allows you to play any mp3 file.

Here is an example of a small thread:

import javazoom.jl.decoder.JavaLayerException; import javazoom.jl.player.Player; import java.io.IOException; import java.net.URL; import java.net.URLConnection; public class RadioConnector { public static void main ( String[] args ) { try { playRadioStream ( "http://radio.flex.ru:8000/radionami" ); } catch ( IOException e ) { e.printStackTrace (); } catch ( JavaLayerException e ) { e.printStackTrace (); } } private static void playRadioStream ( String spec ) throws IOException, JavaLayerException { // Connection URLConnection urlConnection = new URL ( spec ).openConnection (); // If you have proxy // Properties systemSettings = System.getProperties (); // systemSettings.put ( "proxySet", true ); // systemSettings.put ( "http.proxyHost", "host" ); // systemSettings.put ( "http.proxyPort", "port" ); // If you have proxy auth // BASE64Encoder encoder = new BASE64Encoder (); // String encoded = encoder.encode ( ( "login:pass" ).getBytes () ); // urlConnection.setRequestProperty ( "Proxy-Authorization", "Basic " + encoded ); // Connecting urlConnection.connect (); // Playing Player player = new Player ( urlConnection.getInputStream () ); player.play (); } } 

Please note that the playRadioStream method will process the stream that it calls until something happens (for example, the connection to the radio server is disconnected or you stop the stream).

PS Yes, I included the working URL as an example - you can try to start it and your computer will start playing the radio stream.

+6
source

All Articles