Using Qlab to control iTunes and house music

TL;DR:
If you are using iTunes to play your house music, here is how to control it using Qlab.

The Story:
Ah, iTunes. That old workhorse of a music player that has bloated with responsibility for all kinds of media and syncing. Consumer music listening habits may have moved on from local libraries, but iTunes is still hanging in there. It also works like Spotify, with the ability to stream music on demand. Like with Spotify, the idea of streaming music during your show sounds like a bad idea waiting to crash.

But whether you are streaming or working with local files, I’d like to share some scripting that allows you to control your music playback from within Qlab, where the rest of your show lives. You don’t have to switch between applications or pull a manual fade on the board to switch over from house music and start the show.

I will add this – there are plenty of times where you are working on a less formal event, and need to put up some house music quickly just to kill dead air while the audience files in. In this scenario, I have definitely used streaming music or long YouTube videos for house music (though YouTube inserts more and more ads, so this is no longer a safe option.) These scripts will definitely help you in those situations.

NOTE: I have found that this script’s method of fading, as written, is not always as smooth as what you would find in a regular Qlab audio cue fade.

The Esoteric Bit:
In the examples here, I will assume the use of a local playlist, with MP3s on your hard drive. But the API hooks are all the same for iTunes, you’re just telling it to play and pause.

In iTunes, create a playlist that you want to use.

In Qlab, we are going to set up a series of scripts:

  1. Opening the application (during your show preset)
  2. Start playing a specific playlist
  3. Fade out and pause the track
  4. Restore volume and start playing the next track
  5. Quit the application (show cleanup)

So create a new script cue for each of these, and enter the following AppleScripts:

1) Open iTunes

tell application “iTunes”
    activate
end tell
–restore focus to Qlab
tell application “QLab”
    activate
end tell

The “restore focus” part keeps Qlab front-and-center, so that if you hit spacebar to GO, it will work as expected.

2) Play Playlist

tell application “iTunes”
    set sound volume to 100
    play playlist “NAME OF PLAYLIST”
end tell

3) Fade out and Pause

property tick : 5 — change volume level by this many each loop
property thismany : 0.25 — seconds to wait before making next change to volume
tell application “iTunes”
    repeat
        set snd to sound volume
        if snd is less than or equal to tick then
            set sound volume to 0
            exit repeat
        end if
        set sound volume to (snd – tick)
        delay thismany
    end repeat
    pause
    set sound volume to 100
end tell

4) Restore Music (and start playing the next track)

tell application “iTunes”
    set sound volume to 100
    play (next track)
end tell

If you don’t want to skip to the next track, omit “(next track).”

5) Quit iTunes (cleaning up your show)

Instead of tabbing through my applications that I might be using at the end of the show, I prefer to use Qlab to shut them down as part of my last cue.

tell application “iTunes”
    quit
end tell

Put these cues into your show where ever you need them. Simple as that. Now you don’t have to focus on multiple applications.

NOTE: Eagle-eyed readers will notice that I restore the volume TWICE in these scripts. I do that because, in my experience, the amount of jumping around that happens in production can leave you skipping cues as you work on parts, and you can end up with iTunes at minimum volume at the wrong time. I also had planned to write a “fade in” script but never put enough time into it – so the extra restoring of volume was also a part of that possible move.

Cheers!
-brian