android - Soundpool not working -
i'm doing simple game , since need short sound effects, thought soundpool appropriate. it's not working! don't sounds! have checked code on , on again , compared several other examples, still not working! i'm confused , need work.
here code. have missed or in way? preciated help! thanks!
soundpool = new soundpool(4,audiomanager.stream_music, 0); soundpoolmap = new hashmap<integer, integer>(); soundpoolmap.put(0, soundpool.load(this, r.raw.bonk2, 1)); soundpool.play(0, 1f, 1f, 1, 0, 1f); soundpool.release();
in case, have mentioned sound id 0, instead should mention sound id of loaded sound using load()
method.
for example:
soundpool = new soundpool(10, audiomanager.stream_music, 0); soundpool.setonloadcompletelistener(new onloadcompletelistener() { @override public void onloadcomplete(soundpool soundpool, int sampleid, int status) { loaded = true; } }); soundid = soundpool.load(this, r.raw.sound1, 1); soundpool.play(soundid, volume, volume, 1, 0, 1f);
check example: tutorial: play sounds via soundpool
Comments
Post a Comment