私は私のデバイス Android 2.2 で、Shoutcast オーディオ ファイルをストリーミングしようとしています...この Shoutcast は、Android 2.2 では動作しないと聞きました。だから、私はAndroidエミュレータ2.3を試してみましたが、曲も再生されませんでした。なぜ私がどこで間違っているのか教えていただけますか...そしてコードは以下のとおりです...
public class AudioDemo extends Activity {
final String song_uris="http://stream.radiosai.net:8004/";
private MediaPlayer mediaplayer;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button play = (Button) findViewById(R.id.play);
Button pause = (Button) findViewById(R.id.pause);
Button Previous = (Button) findViewById(R.id.Previous);
Button Next = (Button) findViewById(R.id.Next);
mediaplayer = new MediaPlayer();
mediaplayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
mediaplayer.setDataSource(song_uris);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mediaplayer.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // might take long! (for buffering, etc)
mediaplayer.start();
}
});
}
}