1. Are you ready for the Galaxy S20? Here is everything we know so far!

Problems with SoundPool

Discussion in 'Android Development' started by Thest, May 15, 2011.

  1. Thest

    Thest Lurker
    Thread Starter

    I have the following code
    Code (Text):
    1.  
    2. public SoundPool sounds;
    3.     public HashMap<Integer, Integer> soundmap = new HashMap<Integer, Integer>();
    4.     static final public int BEACH=1;
    5.  
    6. public void onCreate(Bundle savedInstanceState) {
    7.         super.onCreate(savedInstanceState);
    8.         //....
    9.         sounds = new SoundPool(3,AudioManager.STREAM_MUSIC,0);
    10.         soundmap.put(BEACH,sounds.load(this, R.raw.jungle_bgloop, 1));
    11.        
    12.         sounds.play(soundmap.get(BEACH),0.8F,0.8F,1,-1, 1);
    13.  
    14.  
    But this is not working. No ogg file is playing.. If I use MediaPlayer if works
    Code (Text):
    1.  
    2.         MediaPlayer mp = MediaPlayer.create(this, R.raw.jungle_bgloop);
    3.         mp.start();
    4.  
    Can anyone see what Im doing wrong?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...