Using Qlab to control Spotify and house music
TL;DR:
If you’re using Spotify for house music, here is how to control it using Qlab. Especially helpful for random little shows & presentations.
The Story:
Spotify has become a dominant player in how we discover and consume music. With almost 150 million active users and almost 20% of Americans using it every month, it’s the service that more and more people turn to for music listening.
As such, more and more creative people who come up with audio mood boards/playlists and house music are using it. And sometimes those playlists are requested to be used during productions. Not your big professional shows, mind you – I can’t imagine any Broadway designer or FoH tour guy streaming their house music every night. But there is a huge section of the entertainment industry below that level, where someone like the director might say “here is my playlist, use this for the show.”
This of course breaks a few standard practices, particularly the idea of keeping your computer offline during the show and having all of your content local. But, in the real world, where budgets and time can be limited and the resulting productions are a bit more of a collaborative affair than the silo-ed departmental approach, you might need to use Spotify to play back some music in the house while the audience is waiting for the show to begin. Here is how you can control Spotify using Qlab, so that you can keep working in a singular interface for your show playback and sync with the rest of your cues. The last thing you want to do is have to toggle between different applications.
There is a case, however, where I might choose to use Spotify as my preshow music. Plenty of times I am running small, one-off shows and presentations, and having music in the room before the event starts is needed. I may not have my library with me, or even be on my own computer. In this scenario, I might call up a playlist appropriate for the event and run that. It’s not about designing an experience as much as just setting the atmosphere a little.
NOTE #1: As mentioned in an earlier post, this does not cover licensing of music used in public performance. I probably should get around to covering that soon.
NOTE #2: The Spotify application can sometimes be a bit system intensive. I will address how to optimize its performance.
The Esoteric Bit:
You will need the following applications:
- Qlab, with at least a Pro License – either purchased or a daily rental. (See my post on licenses here: https://www.rocktzar.com/qlab-licensing-costs-means/)
- Spotify, the standalone application. My scripts will not work with the web browser version. It is available for free at www.spotify.com.
- A paid Spotify account. You can use a free account for testing, but without a paid account, you’re going to get ads through your PA system!
We will create a few cues as we step through the production:
- Launching Spotify so that it is ready and waiting.
- Telling it to Play the currently paused track (for those random pickup gigs that aren’t designed)
- Telling it to Play a particular playlist
- Fading out the music, and Pausing at the end of the Fade
- Restoring music and skipping to the next track
- Quitting Spotify at the end of our show.
Let’s start with Step One. Start up Qlab, and create a script cue in your preset, which is your list of cues you run before the house opens to prep for the show. (If you don’t already do this, you should check out our script on presetting your computer level – https://www.rocktzar.com/setting-computer-system-volume/)
1) Open Spotify
tell application “Spotify”activateend tell–restore focus to Qlabtell application “QLab”activateend tell
Click “Compile Script” at the bottom of the screen. You will end up with this:
The “restore focus” part keeps Qlab front-and-center, so that if you hit spacebar to GO, it will work as expected.
2) Play Spotify (Plays current track)
Create a new script cue where you want the music to start playing. Paste in the following code:
tell application “Spotify”
set sound volume to 100
play
end tell
This will tell Spotify to play whatever you were just listening to. Again, this is great for when you just need to play music quickly, and have auditioned a playlist or an album that works well enough for the event on hand. But, if you want to play a particular playlist, regardless of what you might have recently played, here is the script cue for that:
3) Play Spotify Playlist
tell application “Spotify”
set sound volume to 100
set houseTrack to “spotify:user:talkingtobrian:playlist:5mJhD1y4EvEyJp9LzOSOaq”
play track houseTrack
end tell
This one looks pretty weird! That long list of jibberish is the Playlist ID within Spotify. Every song, album, and playlist has a URI – a “unique resource identifier.” So this script can target, in theory, any of those things. (Please don’t use this as a way to play all of your show’s songs using Spotify – even if you use the API hooks to begin playing at a particular second, the lag is gonna kill your timing. RESIST!)
Anyway, how do we get this ID number thingy? Right click on the playlist and choose “Share > Copy Spotify URI”. Paste into your script, between quotes, and you get that entire string “spotify:user:…”
4) Fade and pause Spotify music
This script will fade out the volume of the Spotify player, and then pause the song playing at the end. It will then reset the volume back to 100.
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 “Spotify”
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
5) Resume Spotify music, restore volume
tell application “Spotify”
set sound volume to 100
play (next track)
end tell
This might seem redundant, resetting the volume in more than one place. However, I feel that during tech, with all of the jumping around that can happen, I would rather reset the volume like this each time just to make sure that things are working when I want them to. (However, if you change the value from 100, make sure you do it everywhere else as well!)
6) Quit Spotify
tell application “Spotify”
quit
end tell
Use this script at the end of your show to clean up your computer.
Now, the last thing I want to cover is a little trick to use if your Spotify application is sluggish, even after you’ve tried uninstalling the application (and trashed all of the preference files, etc…a FULL uninstall). The program can get really bogged down if you have a LOT of playlists. I was able to get a lot of performance back at one point when I was faced with hundreds of playlists every time the program opened. I created a New Playlist Folder (under the File menu) and put EVERYTHING into that. It eliminated the application’s need to cache everything on load, or seemed to. Kind of like how your computer slows down if you have dozens of files on your desktop – putting everything into a folder will remove the computer’s need to cache those items.
If I am not mistaken, this trick also helped regain some speed in the mobile app for this user as well. So, something to try if you have a lot of playlists and getting a performance hit.
Cheers!
-brian