ibcadmin 发表于 2017-1-13 09:41:20

winform播放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"));//wav文件路径
            sp.Play();

      }

    }
}

/*SoundPlayer sp = new SoundPlayer(global::WindowsApplication1.Properties.Resources.yoursoundfilename); */


ibcadmin 发表于 2017-1-13 09:41:55

叶子
页: [1]
查看完整版本: winform播放wav文件代码分享