C# Skype API Video Call

Anunay Inuganti picture Anunay Inuganti · Jan 30, 2012 · Viewed 10k times · Source

I was working on a security monitor application and the best approach i found was Skype.

when a possible intrusion occurs the application calls a specified Skype ID which is probably my android phone i am done with all the image processing stuff. But i am stuck with this Skype API i wrote this piece of code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SKYPE4COMLib;


namespace SkypeCall
{
    class Program
    {
        static void Main(string[] args)
        {
            Skype skype;
            skype = new Skype("Skype4COM.Skype", "Skype_");

            Call call = skype.PlaceCall(SkypeID);
            call.StartVideoSend();
        }
    }
}

This initiates a voice call but in the call.StartVideoSend(); shows an error

 An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SkypeCall.exe

Additional information:  CALL: Action failed

i even tried this but i guess that's old API and couldn't get anything out of it. And not even by sending commands .

if somebody would help me out i'll be grateful.

Answer

Matt picture Matt · Jan 30, 2012

I think you need to wait until the call is connected.

easiest way would be to test the call.Status

class Program
    {
        static void Main(string[] args)
        {
            Skype skype;
            skype = new SKYPE4COMLib.Skype();
            string SkypeID = args[1];
            Call call = skype.PlaceCall(SkypeID);
            do
            {
                System.Threading.Thread.Sleep(1);
            } while (call.Status != TCallStatus.clsInProgress);
            call.StartVideoSend();
        }
    }

You could also add an event, however I think this will fire on every call so unless you are only using it for this project it might be too much.

class Program
    {
        static string SkypeID = "";
        static void Main(string[] args)
        {
            Skype skype;
            skype = new SKYPE4COMLib.Skype();
            skype.CallStatus += new _ISkypeEvents_CallStatusEventHandler(skype_CallStatus);
            Call call = skype.PlaceCall(SkypeID);

            Console.ReadKey();
        }

        static void skype_CallStatus(Call pCall, TCallStatus Status)
        {
            if (Status == TCallStatus.clsInProgress && pCall.PartnerHandle == SkypeID) { pCall.StartVideoSend(); }
        }
    }