我正在研究安全监控应用程序,我找到的最佳方法是Skype.
当一个可能的入侵发生时,应用程序调用一个指定的Skype ID,这可能是我的Android手机我完成了所有图像处理的东西.但我坚持使用这个Skype API,我写了这段代码:
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这会在call.StartVideoSend();中启动语音呼叫.显示错误
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SkypeCall.exe
Additional information: CALL: Action failed
Run Code Online (Sandbox Code Playgroud)
我甚至试过这个,但我猜这是旧的API,无法从中得到任何东西.甚至不发送命令.
如果有人会帮助我,我会感激不尽.
我想你需要等到呼叫连接起来.
最简单的方法是测试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();
}
}
Run Code Online (Sandbox Code Playgroud)
你也可以添加一个事件,但是我认为这会在每次调用时触发,所以除非你只是为这个项目使用它,否则它可能太多了.
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(); }
}
}
Run Code Online (Sandbox Code Playgroud)