Sai Stuff to Developers

September 14, 2007

THis code sample shows how you can allow visitors to download a file from the webpage without exposing the path or hyperlink of the file.

Filed under: DotNet — tosaik @ 6:53 am
Tags:

Do you want to record your voice from Microphone? If yes, you can use the Microsoft APIs to solve this issue. It’s a very simple approach to record your voice from Mic. I provided C#.net code to solve this issue.

1. Open C#.net web applications. And added the blow namespace.

using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;

2. 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);

3. 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 and Execute it.

Advertisements

7 Comments »

  1. Sir, This Code is excelence and please post like this intreasting codes…

    Comment by Rajender — September 14, 2007 @ 6:55 am | Reply

  2. yeh this is very good but it should also have a functionality of Pause button. If possible, please do add to it.

    Comment by sheikh shoaib — October 26, 2007 @ 7:27 am | Reply

  3. This Code is excelence and please post like this intreasting code.but the problem for this coding are not save the wav file and pls solution this problem

    Comment by randhir — February 27, 2008 @ 6:48 pm | Reply

  4. Looks as though the Microsoft.VisualBasic.Devices namespace has been depricated from use with web apps. Getting an error in my C# web app saying the name space reference not availabe. Does accept Microsoft.VisualBasic.

    Anywho, any ideas?

    k.

    Comment by Sevil Natas — April 19, 2008 @ 9:47 am | Reply

  5. My bad, added the Microsoft.VisualBasic reference to the project and the using statement went in swimmingly.

    Sorry about that….Great sample code.

    Comment by Sevil Natas — April 19, 2008 @ 9:58 am | Reply

  6. minyan plerotic kilp manlikeness reaffusion telegraphic benzoylformic baddishly
    Santiago’s Magic
    http://www.ezlink.ca/~thebrowns/HawkCliff/

    Comment by Emilio Lucas — June 14, 2008 @ 11:41 pm | Reply

  7. will you please add the steps of Ajax implementation using code….

    Comment by Raju — October 4, 2008 @ 9:18 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: