如何从资源播放WAV音频文件? [英] How to play WAV audio file from Resources?
本文介绍了如何从资源播放WAV音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能从我的项目的资源发挥WAV音频文件?我的项目是一个Windows在C#窗体应用程序。
How can I play a WAV audio file in from my project's Resources? My project is a Windows Forms application in C#.
推荐答案
由于 mySoundFile
是流
,你可以利用声音播放
的重载的构造函数,它接受一个流
的对象:
Because mySoundFile
is a Stream
, you can take advantage of SoundPlayer
's overloaded constructor, which accepts a Stream
object:
Stream str = Properties.Resources.mySoundFile;
SoundPlayer snd = new SoundPlayer(str);
snd.Play();
这篇关于如何从资源播放WAV音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文