mopidy/js
Paul Connolley a83b71239b Update test so that it correctly requires the mopidy module
As part of issue #609, the require statement in mopidy-test.js should
have been updated as the API to require mopidy has changed from:

    require('mopidy').Mopidy;

to:

    require('mopidy');
2013-12-17 08:57:44 +00:00
..
lib Preliminary commit for browserify compatibility 2013-12-15 01:52:24 +00:00
src Preliminary commit for browserify compatibility 2013-12-15 01:52:24 +00:00
test Update test so that it correctly requires the mopidy module 2013-12-17 08:57:44 +00:00
buster.js js: Upgrade when.js from 1.8.1 to 2.0.0 2013-03-31 14:09:32 +02:00
Gruntfile.js Preliminary commit for browserify compatibility 2013-12-15 01:52:24 +00:00
package.json Preliminary commit for browserify compatibility 2013-12-15 01:52:24 +00:00
README.md docs: nodejs deb now includes npm 2013-08-04 11:24:00 +02:00

Mopidy.js

Mopidy.js is a JavaScript library that is installed as a part of Mopidy's HTTP frontend or from npm. The library makes Mopidy's core API available from the browser or a Node.js environment, using JSON-RPC messages over a WebSocket to communicate with Mopidy.

Getting it for browser use

Regular and minified versions of Mopidy.js, ready for use, is installed together with Mopidy. When the HTTP frontend is running, the files are available at:

You may need to adjust hostname and port for your local setup.

In the source repo, you can find the files at:

  • mopidy/frontends/http/data/mopidy.js
  • mopidy/frontends/http/data/mopidy.min.js

Getting it for Node.js use

If you want to use Mopidy.js from Node.js instead of a browser, you can install Mopidy.js using npm:

npm install mopidy

After npm completes, you can import Mopidy.js using require():

var Mopidy = require("mopidy").Mopidy;

Using the library

See Mopidy's HTTP API documentation.

Building from source

  1. Install Node.js and npm. There is a PPA if you're running Ubuntu:

     sudo apt-get install python-software-properties
     sudo add-apt-repository ppa:chris-lea/node.js
     sudo apt-get update
     sudo apt-get install nodejs
    
  2. Enter the js/ in Mopidy's Git repo dir and install all dependencies:

     cd js/
     npm install
    

That's it.

You can now run the tests:

npm test

To run tests automatically when you save a file:

npm start

To run tests, concatenate, minify the source, and update the JavaScript files in mopidy/frontends/http/data/:

npm run-script build

To run other grunt targets which isn't predefined in package.json and thus isn't available through npm run-script:

PATH=./node_modules/.bin:$PATH grunt foo