views:

24

answers:

0

hi.

I have a problem about playback of some wav files. I'd like to execute some wav files in sequence. but cant work well. sometimes i can play back till last but sometimes it doesn't work on the way.

anyone knows something to solve this problem? pls Help !...

the following is my code and log of logcat.

--------------------------- code -----------------------------------------------------

private Integer hour = null;

private Integer min = null;

private ArrayList playList = new ArrayList();

private Iterator playListIte = null;

private MediaPlayer mp = new MediaPlayer();

private Context context = null;

private final String logTag = this.getClass().getName();

int i = 0;

public TimePostmanByMP(Integer hour, Integer min) {

this.hour = hour;

this.min = min;

}

public boolean config(Context context) {

this.context = context;

// playList.add(R.raw.notify);

playList.add(R.raw.tadaima);

setHour();

setMin();

playList.add(R.raw.desu);

playListIte = playList.iterator();

mp = MediaPlayer.create(this.context, playListIte.next());

return true;

}

public boolean play() {

try {

mp.setOnCompletionListener(this);

mp.start();

Log.d(logTag,"Execution_" + i++ + " TIMES");

} catch(Exception e) {

e.printStackTrace();

return false;

}

return true;

}

public void onCompletion(MediaPlayer mediaPlayer) {

mediaPlayer.release();

if (playListIte.hasNext()) {

try {

this.mp = MediaPlayer.create(this.context, playListIte.next());

this.play();

} catch (Exception e) {

Log.d(logTag,"err");

e.printStackTrace();

} } } --------------------------- code -----------------------------------------------------

and the following is log

----log--------------------------------------------------------------------------------

09-24 14:58:00.149: DEBUG/ddm-heap(7830): Got feature list request

09-24 14:58:02.119: DEBUG/com.appspot.yamachandatta.timePostman.Audio.TimePostmanByMP(7830): Execution_0 TIMES

09-24 14:58:02.220: WARN/AudioFlinger(51): write blocked for 95 msecs

09-24 14:58:02.269: WARN/SQLiteDirectCursorDriver(7830): Found SQL string that ends in ; -- select * from timer;

09-24 14:58:02.339: WARN/SQLiteDirectCursorDriver(7814): Found SQL string that ends in ; -- select * from timer;

09-24 14:58:02.559: DEBUG/updated(7814): onCheckedChanged_B_MIN = 58

09-24 14:58:02.579: INFO/ActivityManager(76): Process com.appspot.yamachandatta.timePostman:remote (pid 7830) has died.

09-24 14:58:02.689: DEBUG/updated(7814): onCheckedChanged_E_MIN = 58

09-24 14:58:02.749: DEBUG/updated(7814): onCheckedChanged_B_MIN = 58

----log--------------------------------------------------------------------------------