Doing a Skype video call with C# / .Net

Introduction and premise

If you’re using ActiveS to control Skype, it’s easy. If not, you should check if you can migrate to ActiveS – which is really recommended! ActiveS is a nice .NET library that supports most of the Skype API – for free (BSD licence – you can even use it for commercial applications).
Skype supports video calls since Skype version 2.0.

Example – doing a Skype video call

With ActiveS it’s easy: you do just a normal call and than switch on the video support:

This example assume’s that m_objAccess is an instance of the SKYPEAPILib.AccessClass which is the ActiveX stub that connects .NET to Skype. skypeId is a string containing the username of the skype user you’re calling. The next to lines enable the sending of video messages (START_VIDEO_SEND) and the receiving of video messages (START_VIDEO_RECEIVE).

Call call = this.m_objAccess.PlaceCall(skypeId); m_objAccess.SendCommand("ALTER CALL " + call.ID + " START_VIDEO_SEND"); m_objAccess.SendCommand("ALTER CALL " + call.ID + " START_VIDEO_RECEIVE");

You can find more information about the video support at the description of the updated Skype protocol – video section

Skype video calls and conference conversations

The Skype conference calls doesn’t support video conversations. Even the Skype window doesn’t support it, the API seems to behave the same.

You can try to do a conference call and than switch on the video support – but it still doesn’t work. So maybe Skype checks the network load and the usage of the video calls – and then maybe enables the conference calls or makes it a payed service. But – nobody knows execept the Skype developer, we’ll see.

Register incomming Skype calls with ActiveS in C# .NET

Description of the problem – register incomming Skype calls

Skype allows you to register for incomming calls – you can decide if you wanna take the call or not. ActiveS is a wrapper that allows you to control Skype through an easy API.

Solution: register incomming Skype calls ( C# and .NET )

The solution for Visual Basic is similar.

try {
// initialize Skype / ActiveS
ConversionClass m_objConversion = new ConversionClass();
AccessClass m_objAccess = new AccessClass();
// register event handler that listens on status changes of calls
m_objAccess.CallStatusChanged += new _IAccessEvents_CallStatusChangedEventHandler(Skype_CallStatusChanged);
// connect to Skype
m_objAccess.Connect();
} catch (Exception e) {
Console.WriteLine(e.Message);
}

// our event handler
void Skype_CallStatusChanged(SKYPEAPILib.Call call, SKYPEAPILib.SkypeCallProgress callProgress)
{
if (callProgress.Equals(SKYPEAPILib.SkypeCallProgress.prgRinging) && call.Type.Equals(SkypeCallType.ctypIncomingP2P))
{
// display message box to ask user
MessageBox.Show("Do you wanna take that call from " + call.PartnerDisplayName + "?",
"Incomming Skype-call from " + call.PartnerDisplayName,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);

// if user answered no, hang up call
if(res.Equals(DialogResult.No))
{
call.Status = SKYPEAPILib.SkypeCallProgress.prgFinished;
}
else
{
call.Status = SKYPEAPILib.SkypeCallProgress.prgInProgress;
}
}
}

Hang up a Skype call with C#

Description of the problem: hang up a call with Skype

If you’re using ActiveS to control Skype, it’s easy. If not, you should check if you can migrate to ActiveS – which is really recommended!

Solution – hang up the call

Assuming that the current Call object is called call, you can hang up a call with just changing the status to prgFinished.

call.Status = SKYPEAPILib.SkypeCallProgress.prgFinished;

You can get this Call object with placing an outgoing call (AccessClass.PlaceCall(string username)), taking a call for a call id (AccessClass.GetCall(int callId)) or walking through the list of calls (AccessClass.GetCallList(), returns a list of Call objects).

See also register incomming Skype calls with ActiveS in C#