android - How to make Soundpool load lots of short sounds? -


i got advice should use soundpool instead of mediaplayer lot of short sounds on button click don't understand how make work. here code:

protected void oncreate(bundle buttons) {     super.oncreate(buttons);     setcontentview(r.layout.activity_main);     setvolumecontrolstream(audiomanager.stream_music);      //soundpool initialization somewhere     soundpool pool = new soundpool(10, audiomanager.stream_music, 0);      //load sound effect pool     int soundid = pool.load(this, r.raw.sound, 1); (how load more sounds?)      list<integer> streams = new arraylist<integer>();      button play= (button)findviewbyid(r.id.play);     play.setonclicklistener(new view.onclicklistener() {         public void onclick(view view) {             int streamid = pool.play(sound, 1.0f, 1.0f, 1, 0, 1.0f);             streams.add(streamid);         }     });      button stop = (button)findviewbyid(r.id.stop);     stop.setonclicklistener(new view.onclicklistener() {         public void onclick(view view) {             (integer stream : streams) {                  pool.stop(stream);             }             streams.clear();         }     }); } 
  1. my code doesn't work. please edit code , post answers.
  2. i want load more sounds. how?
  3. is there explanation video on youtube?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -