编程语言
首页 > 编程语言> > C#实现播放Mp3音频

C#实现播放Mp3音频

作者:互联网

播放Mp3音频

 /// <summary>
        /// 播放音频,
        /// 1.添加新引用 COM组件的Microsoft Shell Controls And Automation
        /// 2.添加成功,引用中显示的为Shell32.dll,、
        /// 3.设置Shell32.dll的属性为嵌入互操作类型:FALSE
        /// </summary>
        IWavePlayer wavePlayer;
        AudioFileReader audioFileReader;
        private void Voice_MouseClick(object sender, MouseEventArgs e)
        {
            //通过tag取出音频文件路径
            RichTextBoxEx richBox = (RichTextBoxEx)sender;
            string vioce_file = richBox.Tag.ToString();

            Task.Factory.StartNew(() =>
            {
                wavePlayer = new WaveOut();
                audioFileReader = new AudioFileReader(vioce_file);
                wavePlayer.Init(audioFileReader);
                wavePlayer.Play();//播放
            });

        }

标签:richBox,C#,音频,audioFileReader,Mp3,file,播放,wavePlayer
来源: https://www.cnblogs.com/wml-it/p/16427573.html