gpt4 book ai didi

c# - 无法在 wp7 应用程序中获取 mp3 文件流

转载 作者:行者123 更新时间:2023-11-30 22:32:25 25 4
gpt4 key购买 nike

我正在使用 silverlight 和 XNA 为游戏构建一个 wp7 应用程序 我有一个名为“Punch1.mp3”的 mp3 文件 (Build action : resource) 存储在项目文件夹内名为“SoundEffects” 的文件夹中

我想用这段代码播放文件

         StreamResourceInfo info;

Uri myuri = new Uri("/SoundEffects/Punch1.mp3", UriKind.Relative);
info = App.GetResourceStream (myuri);
punch1 = SoundEffect.FromStream(info.Stream ) ;

punch 在这里的代码中定义:

public static SoundEffect punch1;

问题是它在第三行中引发了一个 nullreference 异常,声称 info 为 null在 Debug模式下也是如此,我发现资源流信息为空
我认为这是因为它无法读取文件,尽管 uri 是正确的

enter image description here

最佳答案

你可以尝试两件事

- Clean and rebuild the project
- Try appending project name in URI "/PhoneApp1;component/SoundEffects/Punch.mp3"

关于c# - 无法在 wp7 应用程序中获取 mp3 文件流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8733029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com