c# 播放 mp3格式文件

        public static uint SND_ASYNC = 0x0001;
        public static uint SND_FILENAME = 0x00020000;
        [DllImport("winmm.dll")]
        public static extern uint mciSendString(string lpstrCommand,
        string lpstrReturnString, uint uReturnLength, uint hWndCallback);
        public static void SoundText(string paratext)
        {
            string temp = System.Environment.GetEnvironmentVariable("TEMP");
            DirectoryInfo info = new DirectoryInfo(temp);
            UserDefined.WebDownLoad("http://tts.baidu.com/text2audio?idx=1&tex=" + System.Web.HttpUtility.UrlEncode(paratext, System.Text.Encoding.GetEncoding("utf-8")) + "&cuid=baidu_speech_demo&cod=2&lan=zh&ctp=1&pdt=1&spd=6&per=0&vol=9&pit=5",
                info.FullName + "\\" + paratext + ".mp3");
            mciSendString(@"close temp_alias", null, 0, 0);
            mciSendString("open " + info.FullName + "\\" + paratext + ".mp3" + " alias temp_alias", null, 0, 0);
            mciSendString("play temp_alias", null, 0, 0);
        }

 

转载于:https://www.cnblogs.com/cxlater/p/6722306.html

你可能感兴趣的:(c# 播放 mp3格式文件)