How to play Audio file Mp3 from the server

M.ArslanKhan picture M.ArslanKhan · Dec 17, 2013 · Viewed 33k times · Source

I want to play audio from the live server. I don't want to download these audio files. Format of these files are mp3.working on android java.

Answer

dipali picture dipali · Dec 17, 2013
try {
    MediaPlayer player = new MediaPlayer();
    player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    player.setDataSource("http://xty/MRESC/images/test/xy.mp3");
    player.prepare();
    player.start();    
} catch (Exception e) {
    // TODO: handle exception
}