Skip to content

Setup and Run Mopidy

Arthur Zanatta da Costa edited this page Oct 22, 2016 · 13 revisions

Setup and Run Mopidy

Setup Mopidy music server controlled by HTTP to play local files and Spotify streams

##Overview

In order to Mopidy to work correctly it is mandatory to set up its configuration file appropiately. To create the configuration file, run the command

mopidy

at the terminal. You can interrupt the server after a few seconds and go to the configuration file. The path to find it is

~/.config/mopidy/mopidy.conf

where ~ indicates your home directory. For instance, if you are logged in the account named 'my_account', the complete path would be /home/my_account/.config/mopidy/mopidy.conf.

Open the configuration file and uncomment the content of the following headers:

[local]

enabled = true

library = json

media_dir = $XDG_MUSIC_DIR

scan_timeout = 1000

excluded_file_extensions =
  
.directory

.html

.jpeg

.jpg

.log

.nfo

.png

.txt

[http]

enabled = true

hostname = 127.0.0.1

port = 6680

static_dir =

zeroconf = Mopidy HTTP server on $hostname

[spotify]

enabled=true

username=spotify_username

password=spotify_password

bitrate=160

volume_normalization=true

Local files

The extension for playing local files is bundled in the default installation of Mopody. When adding or deleting songs, it's necessary to update Mopidy local library with the command:

mopidy local scan

The default media directory is $XDG_MUSIC_DIR, which means that its located in under the Music folder of your user (probably will be ~/Music). All local files should be put in this directory.

As an example, let's do a step-by-step walkthrough of transfering a music folder from a USB flash drive to the Raspberry Pi and play it using Mopidy.

Step 1 - Get the name of the USB flash driver

1.1 Run the command

ls -l /dev/disk/by-uuid

to check the list of drivers currently on the Raspberry

1.2 Plug in the usb flash drive with the music folder in the Raspberry

1.3 Run again the command

ls -l /dev/disk/by-uuid

to check if the new drive was recognized. It will usually refer to "/sdax", where x is an integer.

Step 2 - Create a Mount Point

2.1 Create a folder to point to the content of the flash drive. We created it with the name 'flash', but you can name it as you want it.

sudo mkdir /media/flash

2.2 Raspberry user must own this folder. To do this, use the command

sudo chown -R pi:pi /media/flash

Step 3 - Mount the flash drive

To mount the drive in the flash folder, use the command:

sudo mount /dev/sdax /media/flash -o uid=pi,gid=pi

where x is the integer saw in the uuid list.

Step 4 - Copy the Music folder from the flash drive to the Mopidy music library

4.1 Supposing the music folder it's on the root of the flash driver, copy the folder with the command

sudo cp -r /media/flash/music_folder_name ~/Music

4.2 Raspberry user must own this folder. To do this, use the command

    sudo chown -R pi:pi ~/Music/music_folder_name

Step 5 - Update Mopidy library

5.1 Update Mopidy library with the command:

mopidy local scan

Step 6 - Unmount the flash drive

Before removing the flash drive from Raspberry, it's necessary to unmount it with the command:

sudo umount /media/flash

More details about the local file extension can be found here

Spotify

The extension for streaming from Spotify is bundled in the default installation of Mopody. It's necessary to have a premium account to use this feature. Before using it, it's necessary to set up the user and the password in the configuration file. Note that this credentials must be from Spotify. Facebook login will not work.

More details about the Mopidy Spotify extension can be found here

Spotify tunigo

Extension based on the Tunigo API to add browsing capabilities to the Spotify control in your Mopidy client. To install it, use the command:

sudo apt-get install mopidy-spotify-tunigo 

It's not necessary to modify the configuration file to run it.

More details about the Spotify tunigo for Mopidy can be found here

Web clients

Mopify

Mopify is in our opinion the best Mopidy web client to intercat with Mopidy. It has a very Spotify like design and it integrates great with the Spotify itself. Besides, it has wonderful features like the possibility of multiple user build a single queue of music to play and the Station feature, which makes Mopify select musics automatically for your given input (i.e. an artist, a song, a playlist and etc.).

The instructions to install Mopify can be found here

Before using Mopify, you must edit the Mopidy config header [http] with the following:

hostname = ::

and add the following lines:

[mopify]
enabled = true
debug = false

To access Mopify from a browser, run Mopidy on the Raspberry and put the following URL in the address field:

raspberry_ip:6680/Mopify

Unfortunately, Mopify still don't have a support to play local files from the Raspberry. Give a shoutout to the creator dirkgroenen saying we want this feature. Meanwhile, we also recommend the next web client to fulfill this gap.

Moped

Moped is a Mopidy web client capable of running in the most popular browsers, playing Spotify streams (not so good as Mopify) and local files. The instructions to install it on your Raspberry cab be found here

Before using Moped, you must edit the Mopidy config header [http] with the following:

hostname = ::

To access Moped from a browser, run Mopidy on the Raspberry and put the following URL in the address field:

raspberry_ip:6680/moped

The final result