我想播放这个流媒体网址:
http://www.mediacorpradio.sg/radioliveplayer/asx/class95/fm950.asx
我尝试了什么:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
// player
player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mp.start();
button.setImageResource(R.drawable.pause);
}
});
try {
player.setDataSource(radio_url);
} catch (Exception e) {
toast("Unable to play this radio. Please email us if you see this constantly.");
return;
}
player.prepareAsync();
}
private void toggleState(){
if (player.isPlaying()) {
player.pause();
button.setImageResource(R.drawable.play);
}else{
player.prepareAsync();
}
}
@Override
public void onDestroy() {
super.onDestroy();
player.release();
}
我得到的错误:(1,-1004)