Call using Skype and Record the Call in Wave File using .NET
In this article, I will explain how to make a call in Skype and record the call in wave file. Using SkypeControl dll we can connect our windows application to Skype and make a call using Skype. Using Interop.SKYPE4COMlib dll helps to record the SKYPE call in wave file.
Call using Skype and Record the Call in Wave file.
Nowadays connecting Skype for business use widely spread all over the world.Here I used two controls to Connect , Call Skype and Record Skype call in wave file. The controls are as follows:
SkypeControl dll is third party control is used to connect skype and call phone no to Skype.
Interop.SKYPE4COMlib dll is also third party control used to record skype call in wave file format.
Step as follows:
First Connect Widows Application to Skype using SkypeControl dll and then Skype will prompt for allow or deny access of third party connection. If you click allow access then the Skype will connect to the Application. Make Call by passing phone no and record Call in wave file format. Using SkypeControl dll we can connect Widows Application to Skype and make a Call in Skype. Using Interop.SKYPE4COMlib dll helps to record the SKYPE Call in Wave file.
Full code as Follows
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 SKYPE4COMLib;
using SkypeControl;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Intialize SkypeProxy aSkype of SkypeControl which is used to
connect and call Skype Call.
SkypeProxy aSkype = new SkypeProxy();
private void Form1_Load(object sender, EventArgs e)
{
//connect method will connect application to the Skype software and it will prompt for allow or deny access
aSkype.Conect();
}
[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);
private void btncall_Click(object sender, EventArgs e)
{
//Assign Phone No to value variable in which call has to be made.
string value = "11111110011";
//connecting skype
value = "#abc CALL " + value;
//Following Command method will call the Phone no of the value string variable
aSkype.Command(value);
//using SKYPE4COMLib interface is used to track the call status wheather it is InProgress or Finished in order to save it in wave file
Skype skype = new Skype();
skype.CallStatus += new _ISkypeEvents_CallStatusEventHandler(Skype_CallStatus);
}
public void Skype_CallStatus(Call call, TCallStatus status)
{ //check for the condition callstatus is InProgress
if (status == TCallStatus.clsInProgress)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}//check for the condition callstatus is finished
else if (status == TCallStatus.clsFinished)
{
DateTime currdate = DateTime.Now;
string datetime = currdate.ToString();
//declaring wave filename as current datetime with specified path c
string wavfilename = @"C:\" + datetime + @".wav";
//Passing wave filename with path inside mciSendString method to save the preferred location
mciSendString("save recsound " + wavfilename, "", 0, 0);
//close the recording
mciSendString("close recsound ", "", 0, 0);
}
}
}
}
Below image shows the when aSkype.Conect() inside form load event, connect method raises it will prompt user in Skype to allow or deny access to the third party application.
Note: I had attached Interop.SKYPE4COMlib dll and SkypeControl dll for reference and also full sample code.