Sound System Sound Windows Phone 7

I am creating a Windows Phone 7 application and trying to play sound.

I have code for this, but it cannot find the file when I try to run it on an emulator.

I added a sound file as a resource (think)

here is the code if this is a problem

PlaySound(@"Sounds\show.wav");

And 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;
        }
    }
+3
source share
1 answer

Install Build Actionin the file Content.

+6
source

Source: https://habr.com/ru/post/1777225/


All Articles