Silverlight 4 MediaElement play sound

Posted by NealWalters on Stack Overflow See other posts from Stack Overflow or by NealWalters
Published on 2010-04-11T21:00:23Z Indexed on 2010/04/11 21:03 UTC
Read the original article Hit count: 962

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...

© Stack Overflow or respective owner

Related posts about silverlight-4.0

Related posts about mediaelement