jishi / node-sonos-web-controller

A web based controller for Sonos utilizing web sockets for a native look and feel
MIT License
247 stars 45 forks source link
sonos

Sonos Web Controller

NOTE! THIS IS A WORK IN PROGRESS! This is a really early alpha. Things might break from time to time, until I settle a final release that I consider stable for daily use. Until then only master branch will exist.

NOTE! Requires node.js 4.0.0+

As a substitute for the perl-based controller (www.purple.org) this project is aimed at giving similar controller as the native one, but in a browser.

Using node.js as backend, that will keep track of the state of the players, and WebSockets (socket.io) for a native feel (where the state of the players will be updated as soon as it changes).

Main focus will be to support the following:

Main target is to be able to run this on a raspberry pi, but any node.js compatible platform should work. I will only focus on supporting the following browsers:

For a screenshot of current progress, see: http://upload.grabbarna.se/files/sonos-web-controller-201412.png For a video demo: http://www.youtube.com/watch?v=_7Dke5LsTF0

Currently, prev, next, play/pause and the progress bar works. Volume (player and group) work as well. Track info, player state and progress bar updates instantly when controlled from another device, which was one of the main goals with this project. You can group and ungroup via drag n' drop, and you can change music source using your favorites (no browsing atm). Also, different playmode options can be toggled: repeat, random, crossfade.

settings.json

To persist settings between updates, you can create a file called settings.json in the root folder (same level as server.js). Today this can take two arguments:

{ "port": 8080, "cacheDir": "./cache" }

The above are the defaults. Change them as you like and it will take precedence over the default ones.

Installation

Easiest way to install this today would be to use git. Make sure and install node.js and npm (node package manager) for your platform. Make sure that the node and npm command works. If not, you will fail miserably. Install git for your platform. Make sure the git command works as well.

Create a folder on your computer where you want the files to reside (for example, c:\node\sonos-web-controller or /opt/node/sonos-web-controller). Now, using a command prompt/terminal, stand in that directory, and do the following:

git clone https://github.com/jishi/node-sonos-web-controller.git .
npm install
node server.js

Now, visit http://localhost:8080.

For running this as a service under linux, I suggest using pm2 (https://github.com/Unitech/pm2). You must use fork mode (-x) otherwise it will use 100% CPU (cluster mode is the default, if you want to switch you need to delete the old app from pm2 with "pm2 delete appname"). For windows, you may try Winser (http://jfromaniello.github.io/winser/), but haven't tested it.

This software is in no way affiliated nor endorsed by Sonos inc.

Change log