Git Product home page Git Product logo

mopidy.js's Introduction

Mopidy

Mopidy is an extensible music server written in Python.

Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a variety of MPD and web clients.

Stream music from the cloud

Vanilla Mopidy only plays music from files and radio streams. Through extensions, Mopidy can play music from cloud services like Spotify, SoundCloud, and Google Play Music. With Mopidy's extension support, backends for new music sources can be easily added.

Mopidy is just a server

Mopidy is a Python application that runs in a terminal or in the background on Linux computers or Macs that have network connectivity and audio output. Out of the box, Mopidy is an HTTP server. If you install the Mopidy-MPD extension, it becomes an MPD server too. Many additional frontends for controlling Mopidy are available as extensions.

Pick your favorite client

You and the people around you can all connect their favorite MPD or web client to the Mopidy server to search for music and manage the playlist together. With a browser or MPD client, which is available for all popular operating systems, you can control the music from any phone, tablet, or computer.

Mopidy on Raspberry Pi

The Raspberry Pi is a popular device to run Mopidy on, either using Raspbian, Ubuntu, or Arch Linux. Pimoroni recommends Mopidy for use with their Pirate Audio audio gear for Raspberry Pi. Mopidy is also a significant building block in the Pi Musicbox integrated audio jukebox system for Raspberry Pi.

Mopidy is hackable

Mopidy's extension support and Python, JSON-RPC, and JavaScript APIs make Mopidy a perfect base for your projects. In one hack, a Raspberry Pi was embedded in an old cassette player. The buttons and volume control are wired up with GPIO on the Raspberry Pi, and are used to control playback through a custom Mopidy extension. The cassettes have NFC tags used to select playlists from Spotify.

Getting started

To get started with Mopidy, begin by reading the installation docs.

Contributing

Begin by reading the contributing section of our documentation. If you are a developer, please also read Development environment and/or Extension development. We welcome all kinds of help with bug fixing, testing, documentation, and supporting other users.

Project resources

Latest PyPI version

Read the Docs build status

Test coverage

Chat on Zulip

mopidy.js's People

Contributors

altano avatar andrenarchy avatar atlantageek avatar connrs avatar cristianpb avatar dependabot[bot] avatar djmattyg007 avatar gamadril avatar jodal avatar kingosticks avatar whomwah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mopidy.js's Issues

Uncaught ReferenceError: setImmediate is not defined

Using this within Firefox gives the following error: Uncaught ReferenceError: setImmediate is not defined
According to these documentation this is a non-standard feature. In fact most-likely no browser (except MS Edge) supports it.
So I wonder if this problem could be solved using something else like plain setTimeout. Thanks for any feedback. ๐Ÿ™ƒ

Provide an example for browsing an album and play the songs in this album

Many thanks for your example that shows how to navigate through a playlist.

But unfortunatly the complicated thing seems for me how to create a playlist.
I think that "Browse" is simpler than "Search". Therefore the example should show how to
call "Browse" with a given url for a local directory that contains an album with some songs.
Then the result of Browse should be loaded into a playlist and should start to play the songs.

Many thanks for your support.

Close Non-Existant Web Socket

If you use autoConnect: false in the constructor of Mopidy and then call close on the instance without connecting, the following error is thrown:

TypeError: Cannot read property 'close' of null
    at Mopidy.close (/.../node_modules/mopidy/src/mopidy.js:166:20)

Emit pending requests count

Hello,
I would be interested in adding an event advertising the number of pending requests, at emission and reception of a message.
This would allow clients to easily know if there are pending requests going on.

I have added
this.emit("requests:count", Object.keys(this._pendingRequests).length)
after the lines 109 and 181 of mopidy.js, this seems to do the trick.

EventEmitter is not a constructor

Hi,

I installed mopidy.js like this: npm i mopidy.

Then I try to import and use Mopidy in my Vue3 project like this:

import Mopidy from 'mopidy'
const mopidy = new Mopidy()

I get the following error in the console:

Uncaught TypeError: EventEmitter is not a constructor
    js mopidy.js:10
    __require chunk-XNAE4CLY.js:7
    <anonymous> mopidy:1
mopidy.js:10

What am I doing wrong here?

List projects that use mopidy.js

I arrived on this project through a problem I'm having with node-red-contrib-mopidy (cf #42 ) and I realise this might also be used with https://github.com/jaedb/iris which I also use, so thanks again !

It would be nice to have a list of projects that use mopidy.js in the README, also enabling developers to see how it is being used (in my usecase trying to find example code for tracklist.add)

Pre-release testing of Mopidy.js v1.0

The release of Mopidy.js 1.0 is getting nearer. Due to the amount of changes in Mopidy.js since v0.5, I'd like to get some pre-release testing by existing Mopidy web clients before pushing a release to npm.

To build a single JS file to test with:

  1. clone the mopidy.js git repo,
  2. run yarn to install dependencies and then
  3. run yarn build to build dist/mopidy.js.

All breaking changes are documented in the changelog.

@tkem Do you have time to try Mopidy.js' master branch with Mopidy-Mobile?

@kingosticks @jcass77 Does any of you have time to try Mopidy.js' master branch with Mopidy-Musicbox-Webclient?

@jaedb Do you have time to try Mopidy.js' master branch with Mopidy-Iris?

No mopidy.history methods

I'm running Mopidy 1.0.0 and using latest mopidy.js build.

m = new Mopidy();
m.history
Object {getLength: function, getHistory: function}
m.history.getLength()
Server returned error: Object {message: "Method not found", code: -32601, data: "Object mounted at "core.history" has no member "get_length""}

The same error is returned for history.getHistory()

Expose when.all() and/or when.join()

Disclaimer: I'm not that much of a JS guru, so if I'm completely wrong on this issue or there are already much easier ways to do what I'm trying to achieve, I'd be glad to be corrected or pointed to the right direction...

The when.js CommonJS Promises/A implementation used by mopidy.js provides some useful "static" methods, which are not available easily through the mopidy.js interface. I especially like to use when.all() and/or when.join(), which somewhat resemble pykka.join(), which I like ;-)

I currently use what I consider a very ugly hack to get that functionality without loading when.js seperately, to do something like this:

var all = mopidy.getVersion().__proto__.constructor.all;
return all([
  mopidy.tracklist.getConsume(),
  mopidy.tracklist.getRandom(),
  mopidy.tracklist.getRepeat(),
  mopidy.tracklist.getSingle()
]).then(function(results) {
  return {
    consume: results[0],
    random: results[1],
    repeat: results[2],
    single: results[3]
  };
});

Now, it would be nice if all and/or the similar when.join() would be exposed by Mopidy directly, since I think this use case might not be uncommon for clients. I guess all could be easily added as a property to either the Mopidy constructor or a mopidy instance.

As stated before, I don't know if there's an easier or cleaner way to achieve this. However, what I don't want to do is add another

<script src="when.js">

since the functionality is already there...

mopidy.library.getImages expecting list of URIs validation error

"mopidy": "^0.5.0"

So when calling with:
mopidy.library.getImages(['spotify:artist:4FCGgZrVQtcbDFEap3OAb2'])

I get the message:
Expected a list of URIs, not u\'spotify:artist:4FCGgZrVQtcbDFEap3OAb2\' back.

Looking at the documentation this looks like the correct way to call the function? Have I understood correctly?

PS I have made the same call with:
mopidy.library.getImages({ uris: ['spotify:artist:4FCGgZrVQtcbDFEap3OAb2']})

I don't get an error, but have never got any images back (That could be a mopidy-spotify thing.

Feature request: mopidy plugin with mopidy.js

mopidy.js is great as a starter to build an own JS user interface. I think it would be even greater for JS developers to have an example mopidy plugin they can utilize.

Have a basic mopidy plugin (within examples) which servers the web files within the mopidy process. Only change the plugin name, drop your web files (HTML, CSS, JS, etc) in a dedicated folder, ready to go.

Just an idea...

Cheers
bluepuma

Missing event on playback stop

I'm logging all events, like:

mopidy.on(function (ev, args) {
  console.log(ev);
});

When pause or play occurs I get event:playbackStateChanged, however when the music is stopped (by mopidy.playback.stop()) I don't get any event.

Can't get tracklist.add to work (from node-red and node-red-contrib-mopidy)

Hi, thanks for developing and maintaining mopidy.js, I use it almost daily through my nodered setup with https://github.com/emiloberg/node-red-contrib-mopidy/ and it works great !

I'm having trouble writing a function that loads 20 random tracks from my library as described in emiloberg/node-red-contrib-mopidy#11

I'm not sure what I'm doing wrong and I seem to have gone through a number of combinations ('uris', 'tracks', etc.) without success.

Any tips on how to tackle this problem ?

Replace Bane.js with EventEmitter

Node.js has a quite standardized event interface called EventEmitter. In browsers, the same interface is made available with the help of Browserify (or Webpack).

The EventEmitter API is quite similar to Bane.js, so replacing Bane.js with the far more widely used EventEmitter API should be quite straight forward. However, EventEmitter lacks a the .off() method from Bane.js, so this is a breaking change.

Tasks:

  • Replace Bane.js with EventEmitter
  • Test that Browserify makes EventEmitter available on the browser
  • Update Mopidy's Mopidy.js docs

\'unicode\' object has no attribute \'items\

After getting the state:online event and calling...

mopidy.library.search({
  query: 'Newton Faulkner',
}).done(console.log.bind(console))

I'm getting this \'unicode\' object has no attribute \'items\ error sent back...

Server returned error: { message: 'Application error',
  code: 0,
  data: 
   { message: '\'unicode\' object has no attribute \'items\'',
     traceback: 'Traceback (most recent call last):\n  File "/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py", line 133, in _handle_single_request\n    result = self._unwrap_result(result)\n  File "/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py", line 222, in _unwrap_result\n    result = result.get()\n  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get\n    compat.reraise(*self._data[\'exc_info\'])\n  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise\n    exec(\'raise tp, value, tb\')\n  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop\n    response = self._handle_receive(message)\n  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive\n    return callee(*message[\'args\'], **message[\'kwargs\'])\n  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 316, in search\n    query = _normalize_query(query or kwargs)\n  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 358, in _normalize_query\n    for (field, values) in query.items():\nAttributeError: \'unicode\' object has no attribute \'items\'\n',
     type: 'AttributeError' } }

Is this something server side or am I messing up somewhere?

Cheers,

Ben

Uncaught (in promise) TypeError: track.artists is undefined

For hours I have been trying to get mopidy.js to run, my major challenges:

  1. Does not build with node 15 (seems to work with 12 and 14)
  2. Parcel needs to be installed
  3. Changing the script to connect to remote mopidy
  4. Configure mopidy to enable remote hosts to access
  5. Finally "Uncaught (in promise) TypeError: track.artists is undefined"

It seems to work now, I play a radio stream on the Raspi3+ (latest Raspberry Pi OS Lite), can access remotely via Iris and mopidy.js seems to connect, I can see web socket messages. But the console shows the exception and it displays "Unknown - Unknown".

MopidyJS-track artists_is_undefined-2

when I try to run the example code I get this uncaught syntax error.

When I try to run the example code I get this.

Uncaught SyntaxError: Cannot use import statement outside a module (at web.js:4:1)
I've done npm install and npm test seems to run fine.
Then I pointed my browser to the HTML file and got the previous mentioned error. I also ran a simple python webserver to host the HTML and browsed to the port and got the same error. I'm trying to open web.html so I can access the console and play with the API.

TypeScript Type Definitions: last mile?

I was working on a project that relied on Mopidy.js so I started writing a TypeScript definition file for the API. It is mostly done but I have some more urgent matters come up and am not going to be able to finish the definitions and submit them to DefinitelyTyped.

If anyone wants to pick up where I left off, I think there's <10% left to do, and the hard parts like the on/off event subscription API are already done. Just look for "@todo" comments in the code. Feel free to finish it and submit to DefinitelyTyped with your name instead of mine:

https://files.terriblefish.com/mopidyjs/index.d.ts

Switch to by-position-or-by-name as the default calling convention

Mopidy.js 0.4.0 released 2014-06-24 added support for the by-position-or-by-name calling convention, but the by-position-only calling convention is still the default.

Short term we should change the default. Long term we should remove the by-position-only calling convention.

We can change this now, but then we should not bundle the new release of Mopidy.js with Mopidy, so we don't break old clients, ref. mopidy/mopidy#1460.

Replace When.js with ES6 Promise

ES6 has standardized the Promise object. Of the browsers supporting WebSockets, mostly everyone except IE10 and IE11 supports Promise.

Mopidy.js should replace the When.js dependency with ES6 Promises without any bundled polyfill, making it as small as possible by default. Clients that want Mopidy.js to work with IE10/IE11 should provide a Promise polyfill themselves.

Tasks:

  • Remove Mopidy.when() reexport of When.js
  • Replace When.js with ES6 Promise in browsers
  • Replace When.js with "promise" npm package in Node.js
  • Update Mopidy's Mopidy.js docs

Add methods for creating models

As discussed in https://discuss.mopidy.com/t/unable-to-create-a-playlist-from-a-podcast-uri-in-mopidy-js/737, clients sometimes may want to create models by themselves, e.g. to add tracks to playlists. Currently, this is only possible by creating a plain JS object with the semi-documented __model__ property.
Although the use case discussed above concerns the playlist API, there may be other cases where creating models, especially Refs, may be desirable. So adding functionality to create these on the client in a way that's guaranteed to work with current and future versions of the API would be a welcome addition.

Use relative path for websocket

If the mopidy server is mounted in a subdirectory via a reverse proxy (e.g., https://domain/mydir, such that apps are available under https://domain/mydir/app), then the default websocket url in https://github.com/mopidy/mopidy.js/blob/master/src/mopidy.js#L65 points to the wrong location. Since the code already uses browserify (yey!), a solution is to use url.resolve() in order to determine the path:

var url = require("url");
var path = url.resolve(
    (typeof document !== "undefined" && document.location.pathname) || "/",
    "../mopidy/ws"
);

and then

settings.webSocketUrl = settings.webSocketUrl ||
    protocol + currentHost + path;

In my setup, mopidy is mounted in a subdirectory via nginx and it took me a while to figure out why moped wasn't able to connect to the websocket. The above change would make it work without any further configuration.

What do you think?

Replace Buster.js with Karma+Mocha

The main advantage of the Buster.js test framework is that the same test suite can be executed both on Node.js and in the browser. I believe the same is achievable with the Karma test runner together with the Mocha test framework.

Since Buster.js is barely maintained, Mopidy.js' test suite should be ported to Karma+Mocha.

When doing so, we can either keep referee for assertions through the use of karma-referee or rewrite them to use the Chai assertion library.

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.