我正在创建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;
}
}发布于 2010-11-28 04:49:43
将文件上的Build Action设置为Content。
https://stackoverflow.com/questions/4293721
复制相似问题