Top Related Projects
Quick Overview
Mopidy is an extensible music server written in Python. It can play music from local disk, Spotify, SoundCloud, Google Play Music, and more. Mopidy can be extended with frontend extensions to control playback from various clients, including web browsers, MPD clients, and even Spotify apps.
Pros
- Highly extensible with a plugin architecture
- Supports multiple music sources (local files, streaming services)
- Cross-platform compatibility (Linux, macOS, Windows)
- Active community and regular updates
Cons
- Setup can be complex for beginners
- Some features require additional plugins
- Performance may vary depending on the number of extensions used
- Limited built-in GUI options (relies on third-party frontends)
Code Examples
- Basic configuration in
mopidy.conf
:
[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
[audio]
output = autoaudiosink
[local]
media_dir = /path/to/your/music
- Starting Mopidy from Python:
from mopidy import core
from mopidy import config as config_lib
config = config_lib.load()
mopidy_core = core.Core(config)
mopidy_core.run()
- Using Mopidy's HTTP API with Python requests:
import requests
base_url = "http://localhost:6680/mopidy/rpc"
# Get current track
response = requests.post(base_url, json={
"jsonrpc": "2.0",
"id": 1,
"method": "core.playback.get_current_track"
})
print(response.json()["result"])
# Play a specific track
requests.post(base_url, json={
"jsonrpc": "2.0",
"id": 1,
"method": "core.playback.play",
"params": {"tl_track": {"tlid": 1}}
})
Getting Started
-
Install Mopidy:
pip install mopidy
-
Create a configuration file (
~/.config/mopidy/mopidy.conf
):[core] cache_dir = ~/.cache/mopidy config_dir = ~/.config/mopidy data_dir = ~/.local/share/mopidy [audio] output = autoaudiosink [local] media_dir = ~/Music
-
Start Mopidy:
mopidy
-
Access Mopidy's web interface at
http://localhost:6680
or use an MPD client to control playback.
Competitor Comparisons
๐งโ๏ธ Modern Music Server and Streamer compatible with Subsonic/Airsonic
Pros of Navidrome
- Built-in web UI for easy access and management
- Supports multiple users with individual preferences
- Focused specifically on music streaming, potentially simpler setup
Cons of Navidrome
- Limited to audio files only, no support for other media types
- Fewer extension options compared to Mopidy's plugin system
- Less mature project with potentially fewer community contributions
Code Comparison
Navidrome (Go):
func (s *Scanner) processAudioFiles(dir string, files []string) error {
for _, f := range files {
err := s.processAudioFile(dir, f)
if err != nil {
log.Error("Error processing audio file", "file", f, err)
}
}
return nil
}
Mopidy (Python):
def scan(self, uri=None, domains=None):
if uri is not None:
return self._scan_uri(uri)
elif domains is not None:
return self._scan_domains(domains)
else:
return self._scan_all()
Both projects handle audio file scanning, but Navidrome's implementation is more focused on processing individual files, while Mopidy's approach is more flexible, allowing for different scanning methods based on input parameters.
Open Source Spotify client library
Pros of librespot
- Focused specifically on Spotify streaming, providing a more specialized solution
- Written in Rust, potentially offering better performance and memory safety
- Supports Spotify Connect protocol, allowing seamless device switching
Cons of librespot
- Limited to Spotify, lacking support for other music services
- Smaller community and fewer contributors compared to Mopidy
- Less extensive documentation and fewer integrations with other tools
Code Comparison
Mopidy (Python):
def play(self):
if self.current_track:
self.audio.prepare_change()
self.audio.set_uri(self.current_track.uri)
self.audio.start_playback()
librespot (Rust):
pub fn play(&mut self) -> Result<(), Error> {
if let Some(track) = &self.current_track {
self.player.load(track.id, true, 0)?;
self.player.play()?;
}
Ok(())
}
Both projects handle playing tracks, but librespot's implementation is more concise and type-safe due to Rust's language features. Mopidy's code is more readable for those familiar with Python, while librespot's may require more Rust knowledge to understand fully.
A spotify daemon
Pros of Spotifyd
- Lightweight and resource-efficient, ideal for low-power devices
- Focuses solely on Spotify, providing a streamlined experience
- Written in Rust, offering better performance and memory safety
Cons of Spotifyd
- Limited to Spotify, lacking support for other music services
- Fewer features compared to Mopidy's extensible plugin system
- Requires a Spotify Premium account for full functionality
Code Comparison
Spotifyd (Rust):
let (mut stream, creds) = Session::connect(config, credentials, cache, player.clone()).await?;
Mopidy (Python):
def play(self):
self.audio.prepare_change()
self.audio.set_state(gst.State.PLAYING)
self.backend.on_playback_started(self.get_current_tl_track())
Both projects aim to provide music streaming capabilities, but they differ in scope and implementation. Spotifyd is a lightweight Spotify client daemon, while Mopidy is a more comprehensive music server with support for various backends and extensions. Spotifyd's Rust implementation offers potential performance benefits, while Mopidy's Python codebase allows for easier extensibility and a broader feature set.
Volumio 2 - Audiophile Music Player
Pros of Volumio2
- More user-friendly web interface for music playback and management
- Built-in support for a wider range of audio formats and streaming services
- Designed specifically for audio playback on single-board computers like Raspberry Pi
Cons of Volumio2
- Less flexible and extensible compared to Mopidy's plugin system
- More resource-intensive, which may impact performance on low-powered devices
- Limited to specific hardware platforms, while Mopidy is more platform-agnostic
Code Comparison
Volumio2 (JavaScript):
this.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'ControllerMpd::play');
return this.sendMpdCommand('play', []).then(function() {
return self.getState().then(function(state) {
return self.commandRouter.statePush(state);
});
});
Mopidy (Python):
def play(self):
self.core.playback.play().get()
return True
def get_state(self):
return self.core.playback.get_state().get()
The code snippets show differences in language and structure between the two projects. Volumio2 uses JavaScript with promises, while Mopidy uses Python with a more straightforward approach. Volumio2's code includes additional logging and state management, whereas Mopidy's implementation is more concise.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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.
.. _Mopidy: https://mopidy.com/ .. _extensions: https://mopidy.com/ext/ .. _Mopidy-MPD: https://mopidy.com/ext/mpd/ .. _Raspberry Pi: https://www.raspberrypi.org/ .. _Pirate Audio: https://shop.pimoroni.com/collections/pirate-audio .. _Pi Musicbox: https://www.pimusicbox.com/
Getting started
To get started with Mopidy, begin by reading the
installation docs <https://docs.mopidy.com/en/latest/installation/>
_.
Contributing
Begin by reading the
contributing <https://docs.mopidy.com/en/latest/contributing/>
_
section of our documentation.
If you are a developer, please also read
Development environment <https://docs.mopidy.com/en/latest/devenv/>
_
and/or
Extension development <https://docs.mopidy.com/en/latest/extensiondev/>
_.
We welcome all kinds of help with bug fixing, testing, documentation, and supporting other users.
Project resources
Documentation <https://docs.mopidy.com/>
_Discourse forum <https://discourse.mopidy.com/>
_Zulip chat <https://mopidy.zulipchat.com/>
_Source code <https://github.com/mopidy/mopidy>
_Issue tracker <https://github.com/mopidy/mopidy/issues>
_
.. image:: https://img.shields.io/pypi/v/mopidy :target: https://pypi.org/project/mopidy/ :alt: Latest PyPI version
.. image:: https://img.shields.io/github/actions/workflow/status/mopidy/mopidy/ci.yml :target: https://github.com/mopidy/mopidy/actions/workflows/ci.yml :alt: CI build status
.. image:: https://img.shields.io/readthedocs/mopidy :target: https://docs.mopidy.com/ :alt: Read the Docs build status
.. image:: https://img.shields.io/codecov/c/github/mopidy/mopidy :target: https://codecov.io/gh/mopidy/mopidy :alt: Test coverage
.. image:: https://img.shields.io/badge/chat-on%20zulip-brightgreen :target: https://mopidy.zulipchat.com/ :alt: Chat on Zulip
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot