c# - Playing an array of sounds, windows phone 7 -
my question following:
how set array of sounds, single button can play them? have 5 wavs (sounds1.wav, sounds2.wav .... sounds5.wav), , ideally them random instead of set order, have absolutely no idea if possible.
i using code basis:
var stream = titlecontainer.openstream("sounds/sound1.wav"); var effect = soundeffect.fromstream(stream); frameworkdispatcher.update(); effect.play(); any appreciated. thank you!
you store them in array of streams, it's idea if wav files aren't big may surpass 90mb memory usage limit if are.
stream[] mystreamarray = new stream[5]; mystreamarray[0] = titlecontainer.openstream("sounds/sound1.wav"); //etc.. (you use loop if sounds named in pattern) you can pick random number, using random class, 0 4 (inclusive). mean chosen sound random instead of playing in particular order. play, can use code above replace fromstream line this:
var effect = soundeffect.fromstream(mystreamarray[randomnumber]);
Comments
Post a Comment