c# - How can I play audio async using MediaElement? -
i believe i'm looking play audio asynchronously. i'm coding app windows 8 requires audio file played everytime button pressed. problem i'm running that, file play, if has not finished playing , hit button, not sound again.
xaml <mediaelement x:name="kickbasicaudio" source="assets/drums/dance/kickbasic.wav" autoplay="false" /> <button content="kick" clickmode="press" click="kickbasicplay"/> c# private void kickbasicplay(object sender, routedeventargs e) { kickbasicaudio.play(); }
perhaps soundplayer
may better option in case, allows asyc playing
using system.media; //the reference needed. private soundplayer _player = new soundplayer("file"); private void kickbasicplay(object sender, routedeventargs e) { _player.play(); }
Comments
Post a Comment