Reputation: 3076
I'm creating a Windows Phone 7 App and am trying to play a sound.
I have the code to do it but it cannot find the file when I try to run it on the emulator.
I have added the sound file as a resource (I think)
here is the code in case it is the problem
PlaySound(@"Sounds\show.wav");
And the function
private void PlaySound(string path)
{
try
{
if (!string.IsNullOrEmpty(path))
{
using (var stream = TitleContainer.OpenStream(path))
{
if (stream != null)
{
var effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();
}
}
}
}catch(Exception e){
timerCount.Text = path;
}
}
Upvotes: 3
Views: 3560