The BusyLight and Skype

posted on 12/06/12 at 06:02:38 pm by Joel Ross

BusylightA few months back, I came across a post by Scott Hanselman about the BusyLight. I thought it was pretty cool, and I wished it worked with Skype, since I don't use Lync, but I do use Skype on a nearly daily basis, and I work from home so it's not at all uncommon for The Wife or my kids to pop into my office. Having a visual indicator would definitely help limit the interruptions when I'm a call.

But alas, there was no Skype support, so I didn't think too much about it until I saw a post about hacking the BusyLight and figuring out how to get it to work without Lync driving it. I was intrigued, so of course, I tweeted about it.

Shortly after that, I was contacted by Plenom, the company behind BusyLight. I discussed a few ideas with them, both about my plans and about theirs (an SDK!). As a result, I decided to build SkypeLight. It marries Skype and BusyLight, so whenever I get a call on Skype, the BusyLight turns red.

I first started with the Skype API to determine how I could detect when a call started, ended, or is in progress. The simplest way to do this is to register and reference the Skype4COM dll. From there, you can handle an event called CallStatus.

   1: var callStatus = CallStatus.NotOnCall;
   2: foreach (var item in skype.ActiveCalls)
   3: {
   4:   if (item is Call)
   5:   {
   6:     var call = item as Call;
   7:  
   8:     if (call.Status == TCallStatus.clsInProgress 
   9:         && (callStatus != CallStatus.OnVideoCall && callStatus != CallStatus.Ringing ))
  10:     {
  11:       callStatus = CallStatus.OnAudioCall;
  12:       if (call.VideoStatus == TCallVideoStatus.cvsBothEnabled 
  13:           || call.VideoStatus == TCallVideoStatus.cvsReceiveEnabled 
  14:           || call.VideoStatus == TCallVideoStatus.cvsSendEnabled)
  15:       {
  16:         callStatus = CallStatus.OnVideoCall;
  17:       }
  18:     }
  19:     if (call.Status == TCallStatus.clsRinging || call.Status == TCallStatus.clsRouting)
  20:     {
  21:       callStatus = CallStatus.Ringing;
  22:       break;
  23:     }
  24:   }
  25: }
  26:  
  27: DomainEvents.Raise(new CallStatusChanged(callStatus));

When the application starts up, I get a reference to Skype, and when the call status changes, I check each call to determine which kind of call it is. Once that's determined, I use eventing to let any interested parties know that the call status has changed.

Once I proved that I could get call status changes through Skype, I started working on the BusyLight side. As of right now, BusyLight does not have a published / documented SDK, so I don't have what I would consider to be a full implementation. Right now, it shows Green (not on a call), Red (on a call), or Yellow (incoming our outgoing call attempt). The BusyLight supports audio as well as pulsing lights, but I couldn't get any of that working through my hacking. Once an SDK is published, I'll go back and put some finishing touches on it.

The code to actually change the BusyLight isn't really all that interesting. It's basically the same code Tom wrote in his post on hacking it. Once I get audio working, or a pulsating light, then maybe the code will get a little more interesting. If you're interested in the BusyLight adapter I wrote, it's available here. This code is pretty portable. I used it as-is when I added it as a build indicator for Traffic Light.

If you've got a BusyLight and want to use it with Skype, check out the GitHub repo for instructions to set it up. I've been using it for a few weeks now, and it's working great.

One last note: Plenom was nice enough to send me a BusyLight free of charge that I could use. I probably would have ordered one anyway, but in the interest of full disclosure, I figured I'd share that info as well.

Discuss this post

Categories: Development, Software, C#