Set URL data source for MediaPlayer
package app.test;
import java.io.IOException;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
public class Test extends Activity {
MediaPlayer mediaPlayer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource("http://yourHost.com/a.mp3");
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
Log.v("AUDIOHTTPPLAYER", e.getMessage());
}
}
}
Related examples in the same category