2010-11-27 124 views
3

我正在创建Windows Phone 7应用程序,并试图播放声音。Visual Studio Windows Phone 7播放声音

我有代码来做到这一点,但当我试图在模拟器上运行它时找不到文件。

我已经添加了声音文件作为资源(我认为)

这里是在情况下,它的问题是

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

而且功能

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; 
     } 
    } 

回答

6

设置代码Build ActionContent

+0

克里斯? – Seva 2010-11-27 21:10:24