title: Loading and playing with soundpool from assets
body: <p>I have a bunch of sounds, assigned to a group of buttons, which i need to play. All my sounds are in asset folder. However, it does not work. <strong>The purpose is:</strong> <em>to load from assetFodler and play that sounds</em>. I will come out with code examples from my project:</p>
  
  <pre><code>//set up  audio player
      mSoundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0);
      mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
      streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
      streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
  
   //getting files lists from asset folder
      aMan = this.getAssets();
      try {
          filelist = aMan.list("");
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>For the purpose of do not having a lot of code lines, I created a basic procedure for <em>loading</em> and <em>playing</em> sounds:</p>
  
  <pre><code>public void loadSound (String strSound, int stream) {
  
      try {
          stream= mSoundPool.load(aMan.openFd(strSound), 1);
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
       mSoundPool.play(stream, streamVolume, streamVolume, 1, LOOP_1_TIME, 1f);
  }
  </code></pre>
  
  <p>As you can see I pass file(stringName) and streamID.</p>
  
  <p>Finally, here is how i use it:</p>
  
  <pre><code>     case R.id.button1:
          //if button was clicked two or more times, when play is still on im doing stop
      mSoundPool.stop(mStream1);
      loadSound(filelist[0],mStream1);
          break;
  </code></pre>
  
  <p>When I run project, nothing happens and logcat says:</p>
  
  <pre><code>12-09 10:38:34.851: W/SoundPool(17331):   sample 2 not READY
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p>UPD1:
  When I do it this way, without having loadSound procedure it works fine
  the following code is onCreate:</p>
  
  <pre><code>//load fx
      try {
          mSoundPoolMap.put(RAW_1_1, mSoundPool.load(aMan.openFd(filelist[0]), 1));
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>and Onclick button:</p>
  
  <pre><code>  //resourcePlayer.stop();
          mSoundPool.stop(mStream1);
          mStream1= mSoundPool.play(mSoundPoolMap.get(RAW_1_1), streamVolume, streamVolume, 1, LOOP_1_TIME, 1f);
  </code></pre>
  
  <p>I just dont want to have so much code lines, i wanted to make it look nice</p>