soundplayer的使用

来源:互联网 发布:app软件需求说明书 编辑:程序博客网 时间:2024/05/17 01:37

          bool sound_status = false;
        SoundPlayer myplay = new SoundPlayer();

        private void play_sound_loop(string str) //循环播放     str存放wav文件的路径
        {
           
            myplay.SoundLocation = str;
            myplay.LoadAsync();
            if (sound_status)
                myplay.PlayLooping();
            else
                myplay.Stop();
       
       
        }

        private void play_sound_one(string str) //只播放一次
        {

            myplay.SoundLocation = str;
            myplay.LoadAsync();
            if (sound_status)
                myplay.Play();
            else
                myplay.Stop();


        }