怎么样在c#程序中放音乐

时间:2022-08-06 05:01:24

       下载最新版:http://www.cckan.net/forum.phpmod=viewthread&tid=41                                                                                                                                                                                   

一个类文章看了全明白

 

怎么样在c#程序中放音乐怎么样在c#程序中放音乐代码
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
using  System.Media;
using  System.Windows.Forms;

namespace  BaseFunction
{
    
///   <summary>
    
///  系统声音类文件
    
///   </summary>

    
public   class  SystemMusic
    {
        
///   <summary>
        
///  中国移动 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Mobile(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\中国移动.WAV " ;
            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  中国联通 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Unicom(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\中国联通.WAV " ;
            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  中国电信 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Telecom(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\中国电信.WAV " ;
            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  中国网通 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  CNC(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\中国网通.WAV " ;
            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  游戏币充值 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Game_Currency_Result(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\游戏币充值.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  中国电力 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  China_Electric_Power(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\中国电力.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  体育彩票 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Lottery(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\体育彩票.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  系统管理 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  System_Management(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\系统管理.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  信用卡 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Card(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\信用卡.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  删除 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Delete(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\删除.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  水费 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Water(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\水费.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  燃气费 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Gas_Fee(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\燃气费.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }


        
///   <summary>
        
///  全国手机充值 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  National_Mobile_Result(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\全国手机充值.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  暖气费 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Heating_costs(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\暖气费.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  火车票 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Train(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\火车票.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  公交卡充值 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Bus_Recharge_Your_Card(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\公交卡充值.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }


        
///   <summary>
        
///  福利彩票 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Welfare_Lottery(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\福利彩票.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  航空售票 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Airline_Ticket(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\航空售票.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  点 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Point(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\点.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }


        
///   <summary>
        
///  百姓生活信息 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Peoples_daily_life_information(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\百姓生活信息.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  9 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Nine(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\9.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  8 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void   Eight(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\8.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  7
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Seven(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\7.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  6 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  six(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\6.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  5 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  five(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\5.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  4 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  four(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\4.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  3 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  three(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\3.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  2
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  two(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\2.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  1 
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  One(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\1.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

        
///   <summary>
        
///  0
        
///   </summary>
        
///   <param name="ifTrue"> 是否循环播放是为True否则为False </param>
         public   static   void  Zone(Boolean ifTrue)
        {
            
// 声音播放的类
            SoundPlayer myplayer  =   new  SoundPlayer();
            myplayer.SoundLocation 
=  Application.StartupPath  +   @" \sound\0.WAV " ;

            
if  (ifTrue)
            {
                myplayer.PlayLooping();
            }
            
else
            {
                myplayer.Play();
            }
        }

    }
}