zoukankan      html  css  js  c++  java
  • 播放声音

      //声音类型:  load:上料 switchs:换装, changes:换程
            private enum Sound
            {
                load, switchs, changes
            }
    
    
            SoundPlayer sp = new SoundPlayer();
    
    
            /// <summary>
            /// 音频播放
            /// </summary>
            /// <param name="m"></param>
            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;
                }
    
            }    
    
    
    
    
      /// <summary>
            /// 验证结果
            /// </summary>
            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;
                }
               
            }
            /// <summary>
            /// 停止播放
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {
                sp.Stop();//语音停止
            }                
    

      

  • 相关阅读:
    创建一个新的进程os.fork
    进程的特征
    进程的状态
    多进程概念
    IO多路复用
    Objective-C 和 C++中指针的格式和.方法 和内存分配
    生活需要奋斗的目标
    iOS 关于UITableView的dequeueReusableCellWithIdentifier
    哈哈,发现了刚毕业时发布的求职帖子
    iOS 和Android中的基本日期处理
  • 原文地址:https://www.cnblogs.com/x666066/p/11466368.html
Copyright © 2011-2022 走看看