Here in this example i will show how to record and play your voice
Take control in .aspx page
<asp:Button ID="BtnRecord" runat="server" Text="Record" onclick="BtnRecord_Click" />
<br />
<asp:Button ID="Btnsavestop" runat="server" Text="SaveStop"
onclick="Btnsavestop_Click" />
<br />
<asp:Button ID="Btnread" runat="server" Text="Read" onclick="Btnread_Click" />
Now in code behind file .cs
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;
public partial class _Default : System.Web.UI.Page
{
[DllImport("winmm.dll",EntryPoint="mciSendStringA")]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
protected void Page_Load(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\Mere Bina.mp3", AudioPlayMode.WaitToComplete);
}
protected void BtnRecord_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
protected void Btnsavestop_Click(object sender, EventArgs e)
{
mciSendString("save recsound c:\\record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer();
c.Audio.Stop();
}
protected void Btnread_Click(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\record.wav", AudioPlayMode.WaitToComplete);
}
}
Take control in .aspx page
<asp:Button ID="BtnRecord" runat="server" Text="Record" onclick="BtnRecord_Click" />
<br />
<asp:Button ID="Btnsavestop" runat="server" Text="SaveStop"
onclick="Btnsavestop_Click" />
<br />
<asp:Button ID="Btnread" runat="server" Text="Read" onclick="Btnread_Click" />
Now in code behind file .cs
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;
public partial class _Default : System.Web.UI.Page
{
[DllImport("winmm.dll",EntryPoint="mciSendStringA")]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
protected void Page_Load(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\Mere Bina.mp3", AudioPlayMode.WaitToComplete);
}
protected void BtnRecord_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
protected void Btnsavestop_Click(object sender, EventArgs e)
{
mciSendString("save recsound c:\\record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer();
c.Audio.Stop();
}
protected void Btnread_Click(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\record.wav", AudioPlayMode.WaitToComplete);
}
}
to get better result use microphone
Hi it is working fine, but the problem is even though i use the microphone, the sound of recorded audio is very low , will you plz help me with this.
ReplyDeleteRegards,
Bhanuprakash
hi please provide the running code
ReplyDeleteHi , Mozila firefox this code is not working pls help me.
ReplyDeletecant add substring c:\\record.wav in "save recsound c:\\record.wav". also not working in server based
ReplyDelete