Esempio n. 1
0
        // 播放录音
        private void button3_Play_Click(object sender, EventArgs e)
        {
            try
            {
                if (recorder.Starting)
                {
                    throw new Exception("请先结束录音");
                }

                // 如果当前未播放,则播放
                if (!playAudio.IsPlaying())
                {
                    if (!File.Exists(FileName))
                    {
                        throw new Exception("文件不存在");
                    }
                    playAudio.PlayAsync(FileName);
                }
                else
                {
                    playAudio.CancelPlay();
                }
            }
            catch (Exception ex)
            {
                label3.Text = ex.Message;
            }
        }