使用Android MediaPlayer播放音频之前添加延迟

时间:2016-10-01 17:46:32

标签: android

我想一次播放5个音频,但时间延迟不同。喜欢(a.mp3,时间延迟为2秒,b.mp3 = 4秒等),但我不知道该怎么做。

1 个答案:

答案 0 :(得分:4)

您可以使用处理程序。

Handler handler = new Handler();
final static int DELAY = 1000; // one second

public void playAudioWithDelay(){
  handler.postDelayed(new Runnable(){
    //your code start with delay in one second after calling this method
  }, DELAY);
  handler.postDelayed(new Runnable(){
    //your code start with delay in two seconds after calling this method
  }, DELAY * 2);
}
相关问题