[android-developers] Sound loop - with pause in between
Hi,
I have String Array with some strings in it [UP,L,R,R...] and I have
some sounds (audio_up.mp3, audio_l.mp3 and so on). I want go through
all the strings in the array and play sounds accordingly with pause in
between (let's say 1 second).
for (int a = 0; a < string_Array_String.length; a++) {
MediaPlayer mp = null;
if (string_Array_String[a].equals("UPL")) {
mp = MediaPlayer.create(Game.this, R.raw.audio_upl);
} else if (string_Array_String[a].equals("UP")) {
mp = MediaPlayer.create(Game.this, R.raw.audio_up);
}
try {
mp.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.start();
}
This is OK but loop is faster than sound fields so I get overlaping -
not good.
I tried to put
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
on the end of the loop but only first and second audio file are OK,
the rest are "cut" too soon.
Solution?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home