好的,我的切换按钮工作正常,但我的 mp3 停止后没有启动。这是我的代码,请告诉我停止并重新开始 mp3 声音的正确方法。这是我的代码和调试日志。
public void toggleclick(View v) throws IllegalStateException, IOException{
if(tg.isChecked())
{
if( mp_tick.isPlaying())
mp_tick.stop();
//mp_tick.release();
Toast.makeText(this, "ON", Toast.LENGTH_SHORT).show();
}
else
mp_tick.prepare();
mp_tick.start();
// mp_tick.start();
Toast.makeText(this, "OFF", Toast.LENGTH_SHORT).show();
}
这是我的日志:
02-07 16:21:43.651: D/MediaPlayer(24554): start() in
02-07 16:21:43.651: E/MediaPlayer(24554): start called in state 0
02-07 16:21:43.651: E/MediaPlayer(24554): error (-38, 0)
02-07 16:21:43.651: D/MediaPlayer(24554): start() out
02-07 16:21:44.652: D/MediaPlayer(24554): start() in
02-07 16:21:44.652: E/MediaPlayer(24554): start called in state 0
02-07 16:21:44.652: E/MediaPlayer(24554): error (-38, 0)
02-07 16:21:44.652: D/MediaPlayer(24554): start() out