title: Silverlight 4 MediaElement play sound
body: <p>I converted a local sound file to a resource, which built this in my XAML: </p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;my:Uri x:Key="SoundFiles"&gt;file:///c:/Audio/HebrewDemo/Shalom.wav&lt;/my:Uri&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>I did this by pasting a local disk mp3 filename into source, then clicked on the "dot" by source and chose "Extract Value to Resource". </p>
  
  <p>When I run, it tells me that "Uri" is not valid, and sure enough, in the Intellisense, I see other elements that start with "uri" but not just URI by itself. </p>
  
  <p>In the real world I want to specify a dynamic mp3 file name.  For example, I might have a database of foreign language words used for flashcards, I want to play a sound file on a URL.  But I thought I would try to walk before running... </p>
  
  <p>Now I'm trying this: </p>
  
  <pre><code>    mediaElement1.Source = new Uri(
                       "http://HebrewResources.com/SoundFiles/Shalom.mp3", 
                        UriKind.Absolute); 
      mediaElement1.Play(); 
  </code></pre>
  
  <p>The status bar in the FireFox browser indicates some data being transferred from the website.  However, I never hear any sound. Could it just be an encoding issue?  If it is not encoded properly, would I get an error? </p>
  
  <p>Also, can I put the Uri statement in the load or make it run in the background, so the user can read the screen, at the same time the sound file is downloading?  In other words, when he clicks the button to hear the soundfile, ideally it would already be preloaded for him.  In this language-learning app, the user will see a word in a foreign language, and try to pronounce it himself, then he will click the "Play" button to hear the sound to check his results. </p>