Giter VIP home page Giter VIP logo

spotify-node-applescript's Introduction

spotify-node-applescript

Control Spotify on Mac OSX with NodeJS and AppleScript.

Installation

$ npm install spotify-node-applescript

Running unit tests

$ npm test

API

playTrack(uri, callback)

Play a track with Spotify URI uri.

var spotify = require('spotify-node-applescript');

spotify.playTrack('spotify:track:3AhXZa8sUQht0UEdBJgpGc', function(){
    // track is playing
});

playTrackInContext(uri, contextUri, callback)

Play a track in context of for example an album.

var spotify = require('spotify-node-applescript');

spotify.playTrackInContext('spotify:track:0R8P9KfGJCDULmlEoBagcO', 'spotify:album:6ZG5lRT77aJ3btmArcykra', function(){
    // Track is playing in context of an album
});

getTrack(callback)

Get the current track. callback is called with the current track as second argument.

var spotify = require('spotify-node-applescript');

spotify.getTrack(function(err, track){

    /*
    track = {
        artist: 'Bob Dylan',
        album: 'Highway 61 Revisited',
        disc_number: 1,
        duration: 370,
        played count: 0,
        track_number: 1,
        starred: false,
        popularity: 71,
        id: 'spotify:track:3AhXZa8sUQht0UEdBJgpGc',
        name: 'Like A Rolling Stone',
        album_artist: 'Bob Dylan',
        spotify_url: 'spotify:track:3AhXZa8sUQht0UEdBJgpGc' }
    }
    */

});

getState(callback)

Get player state.

var spotify = require('spotify-node-applescript');

spotify.getState(function(err, state){
    /*
    state = {
        volume: 99,
        position: 232,
        state: 'playing'
    }
    */
});

jumpTo(second, callback)

Jump to a specific second of the current song.

var spotify = require('spotify-node-applescript');

spotify.jumpTo(15, function() {
    console.log('Jumped 15th second of the song');
});

play(callback)

Resume playing current track.

pause(callback)

Pause playing track.

playPause(callback)

Toggle play.

next(callback)

Play next track.

previous(callback)

Play previous track.

volumeUp(callback)

Turn volume up.

volumeDown(callback)

Turn volume down.

setVolume(volume, callback)

Sets the volume.

var spotify = require('spotify-node-applescript');

spotify.setVolume(42, function() {
    spotify.getState(function(err, state) {
        console.log(state.volume);
    });
});

muteVolume(callback)

Reduces audio to 0, saving the previous volume.

unmuteVolume(callback)

Returns audio to original volume.

isRunning(callback)

Check if Spotify is running.

var spotify = require('spotify-node-applescript');

spotify.isRunning(function(err, isRunning){
    console.log(isRunning); // true
});

Contributors

License

MIT

spotify-node-applescript's People

Contributors

andrehaveman avatar rmehner avatar mrnugget avatar alanshaw avatar nicolasbrugneaux avatar fastfrwrd avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.