zoukankan      html  css  js  c++  java
  • vs2010把项目资源打包成系统资源

     
    把wav格式的音频做成系统资源,根据条件播放相应的音频
     System.Media.SoundPlayer spOne = new System.Media.SoundPlayer();
            System.Media.SoundPlayer spTwo = new System.Media.SoundPlayer();
            System.Media.SoundPlayer spFour = new System.Media.SoundPlayer();
            System.Media.SoundPlayer spFive = new System.Media.SoundPlayer();
            //不同的声音用来标注不同的optiontype有数据,但是如果同一公司下有多个type下都有值,需要一定的延时来避免嘈杂
            public static MemoryStream msOptionTypeOne;
            public static MemoryStream msOptionTypeTwo;
            public static MemoryStream msOptionTypeFour;
            public static MemoryStream msOptionTypeFive;
            public void TimerForReadJsonDataByProviderCode()
            {           
                foreach (Provider_Option provider_Option in this.Config_Provider.ProviderOptions)
                {
                    if (ByProvidersGetJsonDictionaryArray(provider_Option.OptionType)!="")
                    {
                        //System.Media.SystemSounds.Beep.Play();
                        switch (provider_Option.OptionType)
                        {
                            case "1":
                                if (msOptionTypeOne == null)
                                {
                                       byte[] a1 = new byte[(int)CSBrowserHelperObject.Properties.Resources._1.Length];
                                       CSBrowserHelperObject.Properties.Resources._1.Read(a1, 0, (int)CSBrowserHelperObject.Properties.Resources._1.Length);
                                       msOptionTypeOne = new MemoryStream(a1);
                                 }
                                spOne.Stream = msOptionTypeOne;
                                spOne.Play();
                                break;
                            case "2":
                                //sp.SoundLocation = CSBrowserHelperObject.Properties.Resources._18; sp.Load(); sp.Play();
                                if (msOptionTypeTwo == null)
                                {
                                   
                                    byte[] a2 = new byte[(int)CSBrowserHelperObject.Properties.Resources._2.Length];
                                    CSBrowserHelperObject.Properties.Resources._2.Read(a2, 0, (int)CSBrowserHelperObject.Properties.Resources._2.Length);
                                    msOptionTypeTwo = new MemoryStream(a2);
                                }                           
                                 spTwo.Stream = msOptionTypeTwo;                            
                                 spTwo.Play();                           
                                break;
                            case "4":
                                if (msOptionTypeFour == null)
                                     {
                                       byte[] a4 = new byte[(int)CSBrowserHelperObject.Properties.Resources._4.Length];
                                       CSBrowserHelperObject.Properties.Resources._4.Read(a4, 0, (int)CSBrowserHelperObject.Properties.Resources._4.Length);
                                       msOptionTypeFour = new MemoryStream(a4);
                                     }
                                spFour.Stream = msOptionTypeFour;
                                spFour.Play();
                                break;
                            case "5":
                                if (msOptionTypeFive == null)
                                     {
                                       byte[] a5 = new byte[(int)CSBrowserHelperObject.Properties.Resources._5.Length];
                                       CSBrowserHelperObject.Properties.Resources._5.Read(a5, 0, (int)CSBrowserHelperObject.Properties.Resources._5.Length);
                                       msOptionTypeFive = new MemoryStream(a5);
                                     }
                                spFive.Stream = msOptionTypeFive;
                                spFive.Play();
                                break;
                        }
                    }
                    Thread.Sleep(1000);//用以避免一个公司页面下有好几个type都有值,给点延时,不至于吵成一团
                }
            }
     
     
     
  • 相关阅读:
    关于ArcGis for javascrept查询ArcGis server图层信息的方式
    Elasticsearch教程之基础概念
    C# 将日期转换成中文格式
    .Net 自定义Excel模板导出数据
    JavaScript判断浏览器类型
    简单的json传送数据
    Oracle替换临时表空间
    Python多线程循环
    crontab执行不生效-【问题篇】
    Python将MySQL表数据写入excel
  • 原文地址:https://www.cnblogs.com/woshare/p/4505336.html
Copyright © 2011-2022 走看看