JavaScript automator workflow to controll Spotify via Launchbar
I just wrote this snippet to control Spotify using an automator workflow written in JavaScript!
function run(input, parameters) {
// commands for play/pause
var playpauseCommands = new Array("play", "pause", "stop");
// commands for next track
var nextCommands = new Array("next", "n");
// commands for previous track
var prevCommands = new Array("previous", "prev", "p");
var inputString = input[0].toLowerCase();
var Spotify = Application('com.spotify.client');
if(playpauseCommands.indexOf(inputString) != -1) {
Spotify.playpause();
} else if(nextCommands.indexOf(inputString) != -1) {
Spotify.nextTrack();
} else if(prevCommands.indexOf(inputString) != -1) {
Spotify.previousTrack();
}
//return input;
}
Written by Jody Foo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Automator
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#