I converted a local sound file to a resource, which built this in my XAML:
<UserControl.Resources>
<my:Uri x:Key="SoundFiles">file:///c:/Audio/HebrewDemo/Shalom.wav</my:Uri>
</UserControl.Resources>
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".
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.
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...
Now I'm trying this:
mediaElement1.Source = new Uri(
"http://HebrewResources.com/SoundFiles/Shalom.mp3",
UriKind.Absolute);
mediaElement1.Play();
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?
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.