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(); } }); }
- my code doesn't work. please edit code , post answers.
- i want load more sounds. how?
- is there explanation video on youtube?
Comments
Post a Comment