Sunday, December 23, 2007

ASP.NET

Record Sound in ASP.NET

Steps:

Add the below API
[DllImport(”winmm.dll”, EntryPoint = “mciSendStringA”, CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);

Create three Buttons and given the below name and text for the buttons.

1. Record
2. SaveStop
3. Read

1. Under Record Button Click paste the below Code:

// record from microphone
mciSendString(”open new Type waveaudio Alias recsound”, “”, 0, 0);
mciSendString(”record recsound”, “”, 0, 0);

2. Under Save / Stop button Click,

// stop and save
mciSendString(”save recsound c:\\record.wav”, “”, 0, 0);
mciSendString(”close recsound “, “”, 0, 0);
Computer c = new Computer();
c.Audio.Stop();

3. Under Read Button Click

Computer computer = new Computer();
computer.Audio.Play(”c:\\record.wav”, AudioPlayMode.Background);

Save option is only access the Root Folder

No comments: