我的代码如下所示,一切正常
public void ibutton_play_stop_click(View v)
{
switch(sharedPrefs.getInt("quality", 1))
{
case 0:
{
uriStationURL = Uri.parse(StaticVars.RadioStations[0]);
break;
}
case 1:
{
uriStationURL = Uri.parse(StaticVars.RadioStations[1]);
break;
}
case 2:
{
uriStationURL = Uri.parse(StaticVars.RadioStations[2]);
break;
}
case 3:
{
uriStationURL = Uri.parse(StaticVars.RadioStations[3]);
break;
}
}
try
{
if((player == null) || (!player.isPlaying()))
{
this.player = new MediaPlayer();
prgBrBuffer.setVisibility(android.view.View.VISIBLE);
player.stop();
player.reset();
player.setDataSource(this, uriStationURL);
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setOnPreparedListener(this);
player.setOnBufferingUpdateListener(this);
player.setOnErrorListener(this);
player.prepareAsync();
ibttnPlayStop.setEnabled(false);
}
else if((player != null) && (player.isPlaying()))
{
player.stop();
player.reset();
player = null;
}
}
catch(IOException e)
{
Log.e("Media Player Error: ", e.toString());
}
}
但无论每次播放相同的流时都选择“?sid =”。
我现在的问题是:如何从我的媒体播放器中选择从我的shoutcast2服务器中播放哪个给定的sid?
答案 0 :(得分:1)
不要使用server.address /?sid = x,而只是使用server.address / x