Apple and I had a deal: I would devote my free time to mastering technology rather than relating to my fellow human beings, and Apple would keep churning out cool new technologies for me to use. Then Apple goes and introduces software that not only installs and configures itself but also requires an ample storehouse of social skills that I don’t have!
Fortunately, I was able to take the company’s groundbreaking tool for fostering human communication and pervert it into a clever way to watch more television. And along the way, I learned some object lessons about just how capricious AppleScript can be.
The Mission: Remote iChat Control
Your mission is a simple one: with a little hardware and a little AppleScript, you can iChat with your TV.
Why would you want to do this? In 2003, millions of baseball fans were forced to watch afternoon post-season championship games on tape, for heaven’s sake. You’re in an office with a Mac and a broadband connection, and you’ve got a Mac at home with a broadband connection. What if you could open a video chat with your TV from any iChat AV–equipped Mac in the world, to watch and hear, in real time, what your TV was receiving?
I’ll admit under duress that my plan has some mainstream uses, too. The script, once complete, will allow you to activate a video chat on a remote Mac — so it’s useful for surveillance, for example.
Any device with video and audio outputs — from a VCR to a cable box to a TiVo — will do just fine for this project. And while Apple always uses the hypermegasuperginchy-looking iSight camera when demonstrating iChat, any FireWire-based video source should also work fine. What you need is a bridge to digitize the analog video and audio signals.
You may already have such a bridge in your closet. Most digital camcorders have analog inputs for copying VHS to DV. Many of them will also pass this analog signal to your Mac when they are plugged into a Mac’s FireWire port. The camera needs to be turned on and ready 24-7, though. If you don’t have (or want to use) a camcorder, you can use a stand-alone analog-to-digital video bridge, such as Formac’s $239 Studio DV (www.formac.com).
The Mac you’ll use for this project must be in the same room as your video source, obviously. And it can’t be shared while you’re away — the AppleScript that makes all this work exacts a toll on performance. You will also need to change the Mac’s Energy Saver settings so that the CPU never sleeps.
Your TV Mac will need its own iChat account (they’re free). For convenience, give this setup its own user account on your Mac, with iChat set to launch automatically at startup. Add yourself to the TV Mac’s buddy list, and iChat is officially configured. You’ve done all you can do with conventional weapons: now it’s time to summon AppleScript down from the heavens — or up from hell, depending on its mood.
How It Works
The script works by constantly checking the video Mac’s buddy list. If it spots you online and your Status is set to Watching TV, it invites you to a video chat.
It’s secure (the script will open a chat only for you), and it’ll work from anywhere — as long as your iChat account matches the one in the TiVo Mac’s script. Change your Status to Watching TV; within a minute or so, your TV Mac will pop in and invite you to watch today’s rerun of Columbo, or, if you’ve hooked up an iSight camera, show you what your cat’s been up to since you left the house.
How It Doesn’t Work
Head on over to www.macworld.com/downloads/2004/06/ichatscripts.sit to download the finished script, including annotations. The script is useful, makes for an impressive demo, and runs like a charm — until that random moment seconds or days later when iChat suddenly quits for no adequately explored reason.
I discovered late in the game that the act of telling iChat set status to “Serving Video” would sometimes cause it to crash, but that set status message to “Serving Video” didn’t.
The lesson here is that when you script, the community of AppleScripters is an essential resource for the new or ongoing script author. Join the AppleScript-Users mailing list at www.lists.apple.com, and don’t be afraid to ask questions or beg for a workaround.
Where to Go from Here
Wouldn’t it be great if your TV Mac’s iChat Buddy icon were actually a live view of what was currently showing? Yes, it would — and you can do it via GUI Scripting, a Panther innovation that lets you script almost anything. (A version of this script that includes the code needed to update the buddy icon is part of the downloadable script package on Macworld.com)
My dream of TV mastery is becoming reality. My TV Mac remains on duty, attached to my TiVo. I keep its buddy icon visible, and when I see a postage-stamp image of something more interesting than what I’m writing up there in the office, it’s time for a break.
Come Out of Your Shell
1 The on run block runs only when you first launch the app; it contains all the code necessary to get the script up and running.
2 This section of code finds all your available buddies, creates a list of buddies and their iChat IDs, and then asks you to pick (using choose from list) which buddy you want to use as the target for sending videos.
3 The idle block contains code that runs every so often (in this case every 60 seconds). This is the section of code that looks for the proper status from your iChat video buddy, at which point it initiates a video-chat connection.
4 This if statement checks to see whether the TV Mac is currently serving video. If not, and if your TV buddy’s status is set to Watching TV, then the script tells iChat to send the video invitation.
5 If your buddy has changed his or her status to something that isn’t Watching TV, this closes the current chat and puts the script back into standby mode.