如何一次又一次地录制音频

问题描述:

当我打开它并尝试录制我的声音并听我的声音时,它完美地工作但我不能第二次录制我的声音。它播放我在最后一个之前录制的声音。

这是我的代码。我希望我可以告诉我的问题。

when i open it and try to record my voice and listen my voice it works perfectly but i cant record my voice second time.it plays the voice which i have recorded before the last one.
this is my code.i hope i could tell my problem.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("winmm.dll", EntryPoint = "mciSendStringA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern int record(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); 
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            record("open new Type waveaudio Alias recsound", "", 0, 0);
            record("record recsound", "", 0, 0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            record("save recsound C:\\Users\\oguzhan\\Desktop\\ddd.wav", "", 0, 0);
            record("close recsound", "", 0, 0);
            axWindowsMediaPlayer1.URL = "C:\\Users\\oguzhan\\Desktop\\ddd.wav";
            axWindowsMediaPlayer1.Ctlcontrols.play();    
        }              
    }
}

按照Zoltán的说法调用Close方法:

axWindowsMediaPlayer1.Close();



这应该以你的问题结束。



祝你好运 - 建行
Call the Close method as Zoltán said:
axWindowsMediaPlayer1.Close();

That should end with your problem.

Good Luck - CCB