Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cody-music

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cody-music

mac osx spotify and itunes music player controller

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

cody-music

Control Spotify and iTunes, currently only on Mac OSX with NodeJS.

Installation

$ npm install cody-music

Running unit tests

$ npm test

Load the module

import * as music from 'cody-music';

OR

const music = require('cody-music');

API

Specify either "Spotify" or "iTunes" (case-insensitive).

// get the track info using get state
await music.getState('iTunes').then(state => {
    // - "genre" will be empty from Spotify
    // - duration is in milliseconds
    // {artist, album, genre, disc_number, duration, played_count, track_number, id, name, state}
    console.log(state);
});

// play a specific spotify track
await music
    .playTrack('Spotify', 'spotify:track:2YarjDYjBJuH63dUIh9OWv')
    .then(result => {
        // track is playing
    });

// play an iTunes track number
await music.playTrack('iTunes', 1).then(result => {
    // track is playing
});

// handling errors
await music.playTrack('iTunes', 1000000000).then(result => {
    // result will contain the "error" attribute with the error message
    if (result.error) {
        console.log(`Unable to play track, error: ${result.error}`);
    }
});

play("Spotify")

Resume playing current track.

pause("Spotify")

Pause playing track.

playPause("Spotify")

Toggle play.

next("Spotify")

Play next track.

previous("Spotify")

Play previous track.

volumeUp("Spotify")

Turn volume up.

volumeDown("Spotify")

Turn volume down.

setVolume("Spotify", volume)

Sets the volume.

music.setVolume('Spotify', 42).then(() => {
    music.getState(state => {
        console.log(state.volume);
    });
});

muteVolume("Spotify")

Reduces audio to 0, saving the previous volume.

unmuteVolume("Spotify")

Returns audio to original volume.

isRunning("Spotify")

Check if the music player is running.

music.isRunning('Spotify').then(isRunning => {
    console.log(isRunning); // true || false
});

isRepeating("Spotify")

Is repeating on or off?

music.isRepeating('Spotify').then(isRepeating => {
    console.log(isRepeating); // true || false
});

setShufflingOn("Spotify")

Is shuffling on or off?

music.isShuffling('Spotify').then(isShuffling => {
    console.log(isShuffling); // true || false
});

Contributors

  • Cody

License

Keywords

FAQs

Package last updated on 11 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc