2012-01-30 102 views
10

我正在開發一個安全監視器應用程序,我發現的最佳方法是Skype。C#Skype API視頻通話

當一個可能的入侵發生時,應用程序調用一個指定的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(); 
     } 
    } 
} 

此發起語音呼叫,但在call.StartVideoSend();顯示錯誤

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

Additional information: CALL: Action failed 

我甚至試過this但我想這是舊的API,並不能得到什麼的吧。 甚至沒有發送commands

如果有人能幫助我,我將不勝感激。

回答

5

我認爲你需要等到通話連接。

最簡單的方法是測試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(); 
     } 
    } 

你也可以添加事件,但我認爲這會所以除非你只使用它的這個項目可能是每一個電話開槍太多了。

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(); } 
     } 
    } 
+0

感謝百萬@Matt – 2012-01-31 11:58:55