2012-01-22 3 views
1
dogIntroSound = MediaPlayer.create(AnimalPiker1.this, R.raw.introdog); 
dogIntroSound.start(); 

Thread timer = new Thread(){ 
    public void run(){ 
     try{ 
      sleep(5000); 
     } catch (InterruptedException e){ 
      e.printStackTrace(); 
     }finally{ 
      dogSound = MediaPlayer.create(AnimalPiker1.this, R.raw.dog); 
      dogSound.start(); 

     } 
    } 
}; 

timer.start(); 

다른 후 배경 하나에 두 개의 소리를 재생하려면 그러나 이것은 가장 최근의 것입니다 그러나 이것은 심지어나는 많은 것들을 시도 안드로이드

답변

1

사용 setOnCompletionListener 작동하지 않습니다 :

dogIntroSound = MediaPlayer.create(AnimalPiker1.this, R.raw.introdog); 
dogIntroSound.setOnCompletionListener(new OnCompletionListener() { 

    public void onCompletion(MediaPlayer mp) { 
    dogSound = MediaPlayer.create(AnimalPiker1.this, R.raw.dog); 
    dogSound.start(); 
    } 

}); 

dogIntroSound.start(); 
+0

대단히 유용합니다. 감사합니다. :) –

관련 문제