node-osx-mediacontrol

0.0.2 • Public • Published

node-osx-mediacontrol

This module allows to control iTunes and Spotify on macOS; it is possible to register a callback to be notified of the app's state.

For now, only iTunes is implemented with the functionality:

* Receive status updates (playback state changes)
* Control play, Control pause

Example usage:

  const MediaControl = require('node-osx-mediacontrol');
   
  ...

  /* Registers to listen to iTunes events */
  MediaControl.iTunes.observe(function(state) {
    
	switch (state) {
	    case MediaControl.ITUNES_STOPPED:
		/* do something */
		break;
	    case MediaControl.ITUNES_PLAYING;
		/* do something */
		break;
	    case MediaControl.ITUNES_PAUSED:
		/* do something */
		break;
  });

  MediaControl.iTunes.controlPause();

  MediaControl.iTunes.controlPlay();

  /* This will stop the module from listening to iTunes events */
  /* You can still use the control*() functions to control iTunes */
  MediaControl.iTunes.ignore();

Readme

Keywords

Package Sidebar

Install

npm i node-osx-mediacontrol

Weekly Downloads

4

Version

0.0.2

License

MIT

Last publish

Collaborators

  • mderezynski