problems with an icecast audio client

646 views Asked by At

not sure if this is possible, I have an icecast server configured and streaming music, and I want to create a web player using Java (or grails). I managed to get the java web app playing the music icecast is streaming, using something like this:

AudioInputStream stream = AudioSystem.getAudioInputStream(new URL("http://localhost:8000/musicstation"))    

and after a few more lines the music is playing, the problem is that if I close the tab with the web app the music keeps playing, I have to stop the application to stop playing, but when I start it again and try to play again, it's like the icecast server continued playing the song in the background, I mean, it didn't stop or paused, because of this I cannot implement a pause action, since if I pause, what it actually be paused will be the web app playing the song, but in the background icecast will continue transmitting the song, so that when I play again after paused, the song won't continue from the point it was paused.

Is using AudioInputStream the correct way to implement an icecast audio client? I hope I could explain myself. thanks

1

There are 1 answers

5
ePirat On

Icecast obviously continues to "play", since it is a live streaming server. If you want to implement a pause mechanism, you need to buffer what you get from Icecast and play the buffer.