Wednesday, April 16, 2008

Tiny AppleScript: play iTunes video in QuickTime

I really dislike viewing videos in iTunes. It's clunky, there's no support for multiple displays, I'm picky.

I wrote this little script to open and play the selected item in QuickTime, increase its played count by 1 (which marks podcasts as played in iTunes), and pause any music you might be listening to.

tell application "iTunes"
set theTrack to item 1 of selection
set theFile to (get location of theTrack)
set theCount to get (played count of theTrack)
set played count of theTrack to theCount + 1
end tell
tell application "iTunes"
if player state is playing then
playpause
end if
end tell
tell application "QuickTime Player"
open theFile
activate
play document 1
end tell


Ahh, that's better. I set this up with a Quicksilver trigger and am no longer grouchy. Ever. Download the script. For some reason, the playpause (or play, or stop, or anything else I tried) wouldn't work if I put all of the iTunes stuff in one tell block...so that's why there're two of them.