audio record on web application using C#

63 Views Asked by At

Below is my code.I want a web application that I can access my local microphone and record. Then save it to my local files.I tried to run this code on visual studio 2017. The interface works fine. But it doesn't return me a .wav file. May I know if there's any problem with my code?

public partial class _Default : System.Web.UI.Page
{

    [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
    public static extern int mciSendString(
    string lpstrCommand,
    string lpstrReturnString,
    int uReturnLength,
    int hwndCallback
    );
    protected void Button1_Click(object sender, EventArgs e)
    {
        mciSendString("set wave bitpersample 8", "", 0, 0);

        mciSendString("set wave samplespersec 20000", "", 0, 0);
        mciSendString("set wave channels 2", "", 0, 0);
        mciSendString("set wave format tag pcm", "", 0, 0);
        mciSendString("open new type WAVEAudio alias movie", "", 0, 0);

        mciSendString("record movie", "", 0, 0);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        mciSendString("stop movie", "", 0, 0);
        mciSendString("save movie 1.wav", "", 0, 0);
        mciSendString("close movie", "", 0, 0);
    }
}

0

There are 0 best solutions below