我希望在我的自定义音乐播放器完成播放后调用新网址,但它不会调用并向我的播放器发送新网址。请帮帮我,谢谢你。
public void onCompletion(MediaPlayer arg0)
{
playing = "Stopped";
new Thread(new Runnable()
{
@Override
public void run()
{
now++;
try
{
onCompleteURL = new URL(musicUrl[now]);
onCompleteURLConnection = onCompleteURL.openConnection();
onCompleteReadIn = new BufferedReader(new InputStreamReader(onCompleteURLConnection.getInputStream()));
onCompleteUrl = onCompleteReadIn.readLine();
onCompleteReadIn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
waitingGetNextDataHandler1.sendEmptyMessage(0);
}
}).start();
waitingGetNextDataHandler1 = new Handler()
{
public void handleMessage(Message msg)
{
super.handleMessage(msg);
try
{
/*mMediaPlayer.reset();
sendHTTPRequest();
startPlayer();*/
mMediaPlayer.reset();
mMediaPlayer.setDataSource(onCompleteUrl);
mMediaPlayer.prepare();
mMediaPlayer.start();
playing = "Started";
running = mMediaPlayer.isPlaying();
playPauseImageButton.setBackgroundResource(R.drawable.pause_button);
}
catch (Exception e)
{
e.printStackTrace();
}
if(mMediaPlayer != null)
{
if(mMediaPlayer.isPlaying() == true)
{
playPauseImageButton.setBackgroundResource(R.drawable.pause_button);
}
else
{
playPauseImageButton.setBackgroundResource(R.drawable.play_button);
}
setValue();
}
}
};
}