Thank you, I solved it. But...how could I minimize this repetition
(this is with "depth" = 3, but what with for ex. "depth" = 10)?
mMediaPlayer.setOnCompletionListener(new
OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer
arg0) {
sviraj(upper_left, up,
upper_right, left, right, lower_left,
down, lower_right, kombinacija_Array_String, 1);
mMediaPlayer.setOnCompletionListener(new OnCompletionListener(){
@Override
public void
onCompletion(MediaPlayer arg0)
{
sviraj(upper_left, up, upper_right, left, right, lower_left,
down, lower_right, kombinacija_Array_String, 2);
mMediaPlayer.setOnCompletionListener(new OnCompletionListener()
{
@Override
public
void onCompletion(MediaPlayer arg0)
{
Context context = getApplicationContext();
CharSequence text = "Please repeat.";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
});
}
});
}
});
On Sep 26, 7:34 pm, YuviDroid <[email protected]> wrote:
> Hi,
>
> I've never used the MediaPlayer API, but by reading the docs I see this
> method that might be interesting to you: setOnCompletionListener (
> MediaPlayer.OnCompletionListener<http://developer.android.com/reference/android/media/MediaPlayer.OnCo...>
> listener)
>
> probably you can simply add and implement this listener, and when the method
> gets called you know the current mp3 has finished playing, then you can play
> the next (or wait 1 sec and then play..).
>
> Hope it helps!
> Yuvi
>
>
>
> On Sun, Sep 26, 2010 at 4:59 PM, svebee <[email protected]> wrote:
> > 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 [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> YuviDroid
> Check out Launch-X <http://android.yuvalsharon.net/launchx.php> (a widget to
> quickly access your favorite apps and contacts!)http://android.yuvalsharon.net
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en