I have a problem with SoundPool,..
I don't know why it plays nothing, but the play method returns ints != 0.
there's my code.
Using java Syntax Highlighting
- package jona.button;
- import java.io.IOException;
- import android.content.Context;
- import android.media.MediaPlayer;
- import android.media.SoundPool;
- import android.view.View;
- public class Sounds extends View{
- public int MySoundId;
- public MediaPlayer mp;
- public SoundPool MySound;
- public Sounds (Context contexte){
- super(contexte);
- MySound = new SoundPool(1,3,0);
- MySoundId = MySound.load(contexte, R.raw.clic, 2);
- mp = MediaPlayer.create(contexte, R.raw.clic);
- try {
- mp.prepare();
- } catch (IllegalStateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
in the parent class i call
Using java Syntax Highlighting
- int debu = sons.MySound.play(sons.MySoundId, 1, 1, 100, -1, 2);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
where sons is the instance of Sounds.
the debu var is always differant than 0 but the SoundPool never plays.
Does anyone can help me??
EDIT : the MediaPlayer was just there to test the sound.

