HowTo - Mopidy music server to Ubuntu phone
HendriXXX last edited by HendriXXX
Mopidy is an extensible music server that plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a range of MPD and web clients. https://www.mopidy.com
Only Spotify related configuration is explained. If you want more features, please read docs from https://docs.mopidy.com/en/latest/
I assume that you have working adb shell connection to your phone. You should also have Spotify Premium account to get it work.
Remember to backup everything important if phone is your daily driver! I am not responsible if your phone goes haywire! This may also break OTA updates..
Mount system writable
$ sudo mount -o remount,rw /
We use Mopidy apt repositories, as they have precompiled armhf packages ready. Run following commands. Answer "yes" to install required dependencies (all packages should be around 30MB when installed).
$ wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
$ sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
$ sudo apt-get update
$ sudo apt-get install mopidy mopidy-spotify
Now start Mopidy first time and let it load fully. Then use CTRL+C to shut it down.
It created default config file for you. It is located in your home directory.. ~/.config/mopidy/mopidy.conf
Next we configure Mopidy. (use any editor you want). For "client_id" and "client_secret" you have to pair Mopidy with Spotify in here: https://www.mopidy.com/authenticate/#spotify
$ vi ~/.config/mopidy/mopidy.conf
I only show here what I changed. Otherwise I leaved things default.
[core] [logging] [audio] [proxy] [mpd] [http] [stream] [m3u] enabled = false [softwaremixer] [file] enabled = false [local] enabled = false [spotify] username = ...your spotify username here... password = ...your spotify password here... client_id = ...client_id goes here... client_secret = ...client_secret goes here...
Test your configuration by starting mopidy. It should tell in the console if something is wrong. When Mopidy says "MPD server running at [127.0.0.1]:6600" it’s ready to accept connections by any MPD client. Leave it running.
Now we have to install Mopidy Mobile (https://open.uappexplorer.com/app/mopidymobile) to our Ubuntu phone. Use Openstore app to install it.
Open Mopidy Mobile and add a new server.
Name: e.g Ubuntu phone Host: 127.0.0.1 Port: 6680 Path: /mopidy/ws/
Try to connect to the server by clicking server you just created.
Now you should be able to listen music from spotify.
Next we have to get Mopidy server starting while booting. First we create shell script "mopidy.sh"
$ cd ~
$ mkdir .scripts
$ cd .scripts
$ vi mopidy.sh
Add following to the file
#!/bin/sh mopidy & exit 0
$ chmod 744 ~/.scripts/mopidy.sh
Next we create a upstart job
$ sudo vi /usr/share/upstart/sessions/mopidystart.conf
Add following to the file
description "Mopidy start script" start on started unity8-dash exec /home/phablet/.scripts/mopidy.sh
Upstart file what we just created, will run once the desktop has started and you see the "home screen" (apps menu and scopes etc.).
Now reboot your phone and test that everything works. You should wait few minutes after dash loads before opening Mopidy Mobile- app.
- If network connection disconnects, it play from cache couple of minutes and shuts off. When network comes back on it may take few minutes before you hear sound again. App itself works but sound is missing for a while..
- High CPU usage when Mopidy Mobile app is active. I recommend that when start listen music, you should swipe app to backround. Then CPU usage drops to normal.
- Big playlist loads SLOW, be patient!
- No offline playlists.. yet!
Big thanks to Mikel Larrea from UBports Supergroup for testing this guide!