I am using JLayer to stream online radio music so a simple code for this is here:(Where StreamPlayer is a special implementation of JLayer)
//Radio Station URL example is http://radio.flex.ru:8000/radionami
/**
* Plays the Given Online Stream
*
* @param url
* <b> The Specified url you want to connect </b>
* @throws IOException
* @throws JavaLayerException
*/
public void playRadioStream(URL spec) {
try {
// Connection
URLConnection urlConnection = spec.openConnection();
// Connecting
urlConnection.connect();
// Try to play it
StreamPlayer player = new StreamPlayer();
player.open((urlConnection.getInputStream()));
player.play();
} catch (StreamPlayerException | IOException e) {
e.printStackTrace();
}
}
The problem:
I can't figure out how to retrieve information from this connection like the song is playing now from this Radio Station or the name of Station etc...The help is really appreciated!!
Edit:
If you want you can use JLayer instead of StreamPlayer it will work ,although you have to run it on different Thread from the main app Thread.