博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
播放声音
阅读量:4656 次
发布时间:2019-06-09

本文共 1906 字,大约阅读时间需要 6 分钟。

//声音类型:  load:上料 switchs:换装, changes:换程        private enum Sound        {            load, switchs, changes        }        SoundPlayer sp = new SoundPlayer();        ///         /// 音频播放        ///         ///         private void Player(Sound m)        {    //声音文件路径            string path = ConfigurationManager.AppSettings["path"];            switch (m)            {                case Sound.load:                    sp.SoundLocation = path + "load.wav";//请准备上料                    sp.Play();                    sp.PlayLooping(); //循环播放模式                    break;                case Sound.switchs:                    sp.SoundLocation = path + "load.wav"; //请准备上料                    sp.Play();                    sp.PlayLooping(); //循环播放模式                    break;                case Sound.changes:                    sp.SoundLocation = path + "switchs.wav";//请准备换装                    sp.Play();                    sp.PlayLooping(); //循环播放模式                    break;            }        }      ///         /// 验证结果        ///         private void VerificationResult()        {            if (relust1.jiHua == relust2.jiHua && relust1.QiShu == relust2.QiShu && relust1.JieGuo == relust2.JieGuo && relust1.JieGuo2 == relust2.JieGuo2)            {                return;            }            else            {                if (relust1.JieGuo2=="挂")                {                    //播放                    Player(Sound.load);                }                relust1.jiHua = relust2.jiHua;                relust1.QiShu = relust2.QiShu;                relust1.JieGuo = relust2.JieGuo;                relust1.JieGuo2 = relust2.JieGuo2;            }                   }        ///         /// 停止播放        ///         ///         ///         private void button2_Click(object sender, EventArgs e)        {            sp.Stop();//语音停止        }

  

转载于:https://www.cnblogs.com/x666066/p/11466368.html

你可能感兴趣的文章