标签:mes ESS over img ted 决定 注意 top 条件
https://files.cnblogs.com/files/xe2011/mciSendString2020111183816.rar
[DllImport("WinMm.dll",CharSet = CharSet.Auto,CallingConvention = CallingConvention.Cdecl)] public static extern int mciSendString(string lpstrCommand,string lpstrReturnString,int uReturnLength,IntPtr hwndCallback);
string path = Guid.NewGuid() + ".wav";
//开始录音 mciSendString("set wave bitpersample 8","",0,IntPtr.Zero); mciSendString("set wave samplespersec 20000","",0,IntPtr.Zero); mciSendString("set wave channels 2","",0,IntPtr.Zero); mciSendString("set wave format tag pcm","",0,IntPtr.Zero); mciSendString("open new type WAVEAudio alias movie","",0,IntPtr.Zero);//这个决定是wav文件 mciSendString("record movie","",0,IntPtr.Zero);
//保存录音 mciSendString("stop movie","",0,IntPtr.Zero); mciSendString($"save movie {path}","",0,IntPtr.Zero);//换成wav有效 换成mp3文件错误 mciSendString("close movie","",0,IntPtr.Zero);
播放.wav文件,.mp3文件格式也可以播放
//播放 string s = $"open \"{path}\" alias media";
mciSendString("close all",null,0,IntPtr.Zero);
mciSendString(s,null,0,IntPtr.Zero);
mciSendString("set media time format milliseconds",null,0,IntPtr.Zero);
mciSendString("play media",null,0,IntPtr.Zero);
mciSendString("play media notify",null,0,this.Handle);//必须加当前窗体句柄才能 触发 DefWndProc 的 条件 m.Msg == 0x3B9
//判断指令是不是MM_MCINOTIFY0x3B9 //当歌曲播完 mciSendString()向系统发送的MM_MCINOTIFY指令
protected override void DefWndProc(ref Message m) { base.DefWndProc(ref m); if (m.Msg == 0x3B9) { Text = "播放已完成..."; }
}
标签:mes ESS over img ted 决定 注意 top 条件
原文地址:https://www.cnblogs.com/xe2011/p/12180713.html