To follow up on my last post about the animated kolam piece, I wanted to include some details on the AppleScript I used to launch the movie and full-screen it.  As I mentioned before, the script is admittedly a little hacky, but I certainly got the job done.  Here’s the AppleScript which was called in the last line of the loop in my shell script (from the last post):

tell application “QuickTime Player”

  quit

end tell

delay 1

do shell script “open -F ~/Documents/kolam-drawings/final.mpg”

tell application “QuickTime Player”

  activate

  delay 1

  tell application “System Events”

     keystroke “l” using {command down, option down}

     keystroke “f” using {command down, control down}

  end tell

  play document 1

end tell

 

So, here’s what’s going on.  We already have a new MPG generated from the shell script, so we first kill quicktime and explicitly open the file from the command line.  The do shell script “open -F ~/Documents/kolam-drawings/final.mpg” seemed to be the best way to open Quicktime without retaining any old preferences, specifically the -F flag opens it fresh.  The reason this is an issue is that in Lion, Quicktime (all Apple apps really) try to remember your previous settings, so if you previously had a video open, it will open it again, if you had the video set to loop, it will set it again.  So if you run a script that opens a file and turns on looping, the looping will be toggled on and off every time.  So opening it fresh forces a new state every time.

One the video is open, I literally send key commands to loop and fullscreen the video (the keystroke commands).  From what I can tell, Quicktime app is fully scriptable, but I was unable to reliably access the loop and full screen settings from the built-in scripts.  And finally the video is played & then is looped until the shell script calls to the AppleScript, which kills the video and starts the process all over again.  If anyone knows a better way to do this, please email me, I’d be happy to post variations on this page.