AppleScript for playing Rifftrax

Anyone that knows me, knows that I am a huge fan of Mystery Science Theater 3000 and, an off-shoot of that, Rifftrax. One of the great things about Rifftrax is that they sell some MP3-only commentaries. Since they don’t need to license the movie, they can target summer blockbusters like Star Wars: Rogue One, Twilight, and Harry Potter. The only downside to this is that you have to sync up the audio of the MP3 to the movie’s audio. This isn’t too big a deal, especially with Rifftrax’s new auto-syncing application¬†for your phone. That said, sometimes I prefer to watch Rifftrax on my computer for the convenience of the audio coming from the single source (my laptop speakers).

At the beginning of a Rifftrax commentary, instructions are given for when to pause the MP3 and at what point in the movie to un-pause the MP3. That way, the jokes will line up with the movie audio. I will watch movies using VLC and listen to the commentary using QuickTime. Easy, right? But what happens when you need to pause the movie? You have two separate applications playing and, no matter how fast you are, you will not be able to hit the pause buttons of both applications at the same time.

To deal with this issue, I wrote up an AppleScript to hit pause on both applications when running the script. Compiling this script to an application, I can place it in the Dock of my Macintosh when playing a Rifftrax and click to stop and resume at any time. It is a really simple little script to handle this:

tell application "QuickTime Player"
    if document 1 is playing then
        pause document 1
    else
        play document 1
    end if
end tell
tell application "VLC"
    play
end tell

I think the code is pretty readable. QuickTime needs to be told to play or pause the audio if the file is actually being played or not. VLC will just toggle between the two so we don’t need to bother checking. To use this script, simply paste the code into Script Editor, which should have come with your Macintosh, and Export the script as an Application.

Export as Application

That is all there is to it. “It’s time for Rifftrax.”

Leave a Reply

Your email address will not be published. Required fields are marked *