SoundPool problem (1.5)

All your problems with Audio, Video and Images.

SoundPool problem (1.5)

Postby kokmok » Thu Jul 02, 2009 12:05 pm

I all,
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.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package jona.button;
  3.  
  4.  
  5.  
  6. import java.io.IOException;
  7.  
  8.  
  9.  
  10. import android.content.Context;
  11.  
  12. import android.media.MediaPlayer;
  13.  
  14. import android.media.SoundPool;
  15.  
  16. import android.view.View;
  17.  
  18.  
  19.  
  20. public class Sounds extends View{
  21.  
  22.        
  23.  
  24.         public int MySoundId;
  25.  
  26.         public MediaPlayer mp;
  27.  
  28.         public SoundPool MySound;
  29.  
  30.        
  31.  
  32.         public Sounds (Context contexte){
  33.  
  34.                 super(contexte);
  35.  
  36.                
  37.  
  38.                 MySound = new SoundPool(1,3,0);
  39.  
  40.         MySoundId = MySound.load(contexte, R.raw.clic, 2);
  41.  
  42.        
  43.  
  44.                
  45.  
  46.                  mp = MediaPlayer.create(contexte, R.raw.clic);
  47.  
  48.                 try {
  49.  
  50.                                 mp.prepare();
  51.  
  52.                         } catch (IllegalStateException e) {
  53.  
  54.                                 // TODO Auto-generated catch block
  55.  
  56.                                 e.printStackTrace();
  57.  
  58.                         } catch (IOException e) {
  59.  
  60.                                 // TODO Auto-generated catch block
  61.  
  62.                                 e.printStackTrace();
  63.  
  64.                         }
  65.  
  66.                
  67.  
  68.         }
  69.  
  70.        
  71.  
  72.  
  73.  
  74. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

in the parent class i call
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. int debu = sons.MySound.play(sons.MySoundId, 1, 1, 100, -1, 2);
  3.  
  4.  
Parsed in 0.030 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.
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Top

Postby kokmok » Thu Jul 02, 2009 1:23 pm

ok, i found someone who had the same problem and fixed it here The Fix
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests