c#使用System.Media.SoundPlayer播放資源文件中的wav文件
c#使用System.Media.SoundPlayer播放資源文件中的wav文件
using System.Reflection;
using System.IO;
using System.Resources;
using System.Media;
using System.Diagnostics;
namespace CN.OutOfMemory.Csharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Assembly assembly;
Stream soundStream;
SoundPlayer sp;
assembly = Assembly.GetExecutingAssembly();
sp = new SoundPlayer(assembly.GetManifestResourceStream("Yournamespace.Dreamer.wav"));
sp.Play();
}
}
}
/*SoundPlayer sp = new SoundPlayer(global::WindowsApplication1.Properties.Resources.yoursoundfilename); */
本文由用戶 afm_dw 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!