Search code examples
androidaudio-streaminginternet-radio

Radio Station using Android is that possible?


I got a project where i need to use my Android phone as a radio station.It means,i need to produce sound or song from my android phone and upload those to a server and from server; users can hear those sounds and songs live;almost,like an internet radio.

Is that possible in Android phones?If so how can i implement that?


Solution

  • You can use MediaPlayer class to play radio station. You need to pass radio station's url init.

    for example This is one radio station's url http://shoutcast2.omroep.nl:8104/

    So, Now initialise Media Player's object with it as follows,

    MediaPlayer player = new MediaPlayer();
    player.setDataSource(“http://shoutcast2.omroep.nl:8104/”); 
    player.prepareAsync();
    player.setOnPreparedListener(new OnPreparedListener(){
    
                public void onPrepared(MediaPlayer mp) {
                         player.start();
                } 
    
    });
    

    You can download example code from here