views:

31

answers:

1

I have some very simple code which just needs to play a sound with a specified volume, as follows :

var mp = new MediaPlayer();
mp.Open(uri);
mp.Volume = volume;
mp.Play();

The problem arises because this is part of a Prism module. I don't know where the executing assembly is going to be so I can't use a relative Uri or siteoforigin and MediaPlayer doesn't understand the pack Uri syntax.

I have a resource wav file at the root of my assembly called "notify.wav", but I have no way to pass it into MediaPlayer via a Uri and can't see any other way to load it.

How do I play the file?

A: 

Hi I’m afraid Media player does not support pack URI.

Have you tired Directory.GetCurrentDirectory or Environment.CurrentDirectory

Dan H
I don't think GetCurrentDirectory would help me because the resource is embedded in the assembly. I want to know how to pass such a resource to media player. It can't be loose in the file system somewhere.
adhocgeek