windows phone 8 - Best approach for playing a single tone audio file? -


can tell me best approach playing single-tone, audio (.mp3) files in windows phone 8 app? think of piano app, each key represent button, , each button play different tone.

i'm looking efficient way go - i've got 8 different buttons need play different tone when tapped.

i tried using mediaelement:

mediaelement me;  public mainpage() {     initializecomponent();      me = new mediaelement();     me.autoplay = false;     me.source = new uri("/sounds/sound1.mp3", urikind.relative);      btnplay.click += btnplay_click;  }  private void btnplay_click(object sender, eventargs e) {     me.play(); } 

but nothing happens, either in emulator or on device (testing w/ lumia 822). doing wrong here? seems should pretty simple. or using mediaelement best thing use scenario?

would fall under background audio category? i've read through example seems overkill want do.

i've read using xna's soundeffect job, i'd have convert .mp3 files .wav (which isn't problem, i'd rather not go through if don't need to).

can tell me either i'm doing wrong in example above or guide me better solution playing quick <1s audio tones?

i had problem before mediaelement not playing audio files. after many attempts found out plays if defined in xaml , autoplay set true.

try defining in xaml or can add layoutroot.

  var me = new mediaelement();   layoutroot.children.add(me);   me.autoplay = true;   me.source = new uri("sound/1.mp3", urikind.relative); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -