C# winform - 从嵌入式资源播放 wav 文件
我有 15 个 1 秒的 wav 文件,需要每秒播放一个,持续 2 分钟。是在应用程序加载时将 wav 文件读入内存并从那里播放,还是每秒从 Properties.Resources 动态加载更好?
I have 15 1-second wav files, that need to play one every second, for 2 minutes. Is it better to read the wav files into memory at application load and play from there, or load on the fly from Properties.Resources each second?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是否可能会继续添加额外的 WAV 文件?如果没有,我强烈建议将它们加载到内存容器中,您可以为每次执行分派新线程。
would this be something that potentially keep adding additional WAV files down the line? If not, i would strongly recommend loading them up into a memory container that you can spin off new threads for each execution.
也许混合动力。看一下它是否在内存中,如果没有(第一次需要)将其加载到内存中(可能使用
Dictionary
)并从那里使用它。因此,一开始您不会遇到大的加载问题,您只将这些文件放入真正需要的内存中,而不是将可能存在但不需要的文件放入内存中。Maybe doing it hybrid. Take a look, if it is in memory and if not (first time needed) load it into it (maybe with a
Dictionary<string, Stream>
) and use it from there. So you don't have a big load issue at the beginning and you only take these files into memory that really needed and not the maybe existing but not needed ones.