Mopidy – Spotify client

Ever thought it would be great to stream your favorite spotify playlists to your stereo? Now you can with help of raspi and mopidy, a richer MPD alternative. Spotify Premium account is required to use mopidy, but you can try 30 day trial before subscribing.

For starters:

and then:

Above commands will add new source to your apt-get to install mopidy from.

By default, config is stored per user, edit it with:  sudo nano ~/.config/mopidy/mopidy.conf . Find below explanation for distinct sections of config file:

Logging

Standard configuration will do just fine, if you know what you are doing adjust to suit your needs.

Loglevels

Logging level of python modules.

Audio

Audio output, for more options read mopidy documentation, for most appliances default alsa sink will work.

Proxy

Provide hostname and credentials if you use one.

Spotify

Provide your spotify username and password to log on. You can choose bitrate from 160 up to 320, raspberry won’t break a sweat streaming 320 so I recommend this one (if you are not limited by internet connection).  As I mentioned before, you need a Premium account to stream to devices other than PC client and that includes raspi.

MPD

To use MPD clients to control mopidy enable mpd plugin. Hostname have to be set to 0.0.0.0 to control mopidy from hosts other than localhost.

 http

A http interface to control mopidy from browser. To enable it set enabled to true and remember to change 127.0.0.1 to 0.0.0.0 to access from your network.

Stream internet broadcasts

Enable or disable streaming through specific protocols.

Last.fm scrobbler

Provide your last.fm login and scrobble what you are listening to last.fm.

Media Player Remote Interfacing Specification (MPRIS)

Interface that lets you control mopidy through e.g. Ubuntu Sound Menu.

Local music collection

Of course, of what use will mopidy be if it weren’t for playing local music?

Test your setup by typing  mopidy . You can now connect to mopidy and test all its features, just don’t close putty window and don’t stop mopidy. To run mopidy at boot create startup script: sudo nano /etc/init.d/mopidy

Add execute rights:

Obligatory test:

If all works fine:

Let us know what you think about mopidy. What is your setup? Some helpful hints? Any issues with mopidy? Leave us a comment :)

Here is your raspberry pi ampilight system!
  • Kikkeraap

    Any idea how to fix the issue that XBMC does not boot (it goes into a kind of loop)? I’m running Raspbmc.

    • http://raspberry-at-home.pl/ Tomasz Szczerba

      Hi,

      Can you connect to raspi through putty?

      • Kikkeraap

        Yes, SSH works great! I added

        export LD_LIBRARY_PATH=/usr/local/lib

        without succes.

        • http://raspberry-at-home.pl/ Tomasz Szczerba

          Does $HOME/.xbmc/temp/xbmc.log show any errors?

    • Jacek

      Hi,
      I had the same issue a week ago (I think it was after one of the updates). I didn’t try to fix it – I have just re-installed whole Raspbmc which was rather “brute force” fix :) but it worked.

      • Kikkeraap

        I recieved my first Pi last week, so I started from scratch with a recent Raspbmc install. Any idea why I’m facing this problem, or any idea for a fix? Maybe I used instructions from a ‘wrong’ tutorial?

        • http://raspberry-at-home.pl/ Tomasz Szczerba

          I use Simple UI installer from http://www.raspbmc.com/download/ . Never failed me.

          • Kikkeraap

            Done a fresh install of Raspbmc (standalone image) and currently going through this tutorial again. Fingers crossed.

          • Kikkeraap

            I did a fresh install of Raspbmc, followed by installing mopidy as described in this tutorial. The steps I did were:

            wget -q -O – http://apt.mopidy.com/mopidy.g… | sudo apt-key add –
            sudo wget -q -O /etc/apt/sources.list.d/mopidy.list http://apt.mopidy.com/mopidy.l
            sudo apt-get update
            sudo apt-get install mopidy

            After this, I adjusted mopidy.conf to my needs, added snd-bcm2835,
            bcm2708_wdog and ipv6 to /etc/modules. After the reboot of the PI it
            still gets into a loop, therefore I added export
            LD_LIBRARY_PATH=/usr/local/lib to /etc/init.d/xbmc, without success. Any
            idea how to fix XBMC so that it starts (and not goes into a kind of
            loop)?

          • Guest

            did a fresh install of Raspbmc, as described in this tutorial. The steps I did were:

            wget -q -O – http://apt.mopidy.com/mopidy.g… | sudo apt-key add –
            sudo wget -q -O /etc/apt/sources.list.d/mopidy.list http://apt.mopidy.com/mopidy.l
            sudo apt-get update
            sudo apt-get install mopidy

            After this, I adjusted mopidy.conf to my needs, added snd-bcm2835, bcm2708_wdog and ipv6 to /etc/modules. After the reboot of the PI it still gets into a loop, therefore I added export LD_LIBRARY_PATH=/usr/local/lib to /etc/init.d/xbmc, without succes. Any idea how to fix XBMC so that it starts (and not goes into a kind of loop)?

          • http://raspberry-at-home.pl/ Tomasz Szczerba

            Did you do apt-get upgrade? Please try without it, mayby some other update broke xbmc because I see no way mopidy can even affect xbmc. I nhve mine working flawlessly sincr install. This might be a silly question, but this is often a source of all problems so please excuse me but I have to ask. Is your power supply for raspberry powerfull enough, meaning does it output above than 1A(or equal to)? And id you check xbmc log file? Does it show anuthing unussual?

          • Kikkeraap

            As suggested I did apt-get upgrade, no success. XBMC log’s does not show any weird things, but to be sure, shall I post it somewhere? I’m using a 1A power supply, the one that came with my HTC hero.

          • http://raspberry-at-home.pl/ Tomasz Szczerba

            This is a raspbmc issue, lots of users reported similar behavior of xbmc on current raspbmc build. Mine xbmc stoped working after rew reboots as well. Unfortunatelly, as much as I would like to help you I can’t. I hope Raspbmc team will work this out soon, I have a few tv shows to watch;) Let us know when your issue is resolved.

            Oh, one more thing – xbmc doesn’t even start on my installation, same situation as yours?

          • Kikkeraap

            Is there a way so that the Rapbmc team will pick up this issue? Anyway xbmc did launch after a clean install. I did not that /etc/init.d/xbmc was empty, did I enter the correct info in that file?

          • http://raspberry-at-home.pl/ Tomasz Szczerba

            What do you mean by ‘ I did not that /etc/init.d/xbmc was empty’? Why did you add ‘LD_LIBRARY_PATH=/usr/local/lib’ there?

          • http://raspberry-at-home.pl/ Tomasz Szczerba

            I’ve been recently using raspbian image but switched today for raspbmc and found recent build to be very buggy and unstable, I just have got same issue as you – XBMC is not starting, plain black screen despite everything else working… I think we just have to wait for bugfix release.

        • Guest

          I did a fresh install of Raspbmc, as described in this tutorial. The steps I did were:

          wget -q -O – http://apt.mopidy.com/mopidy.gpg | sudo apt-key add –
          sudo wget -q -O /etc/apt/sources.list.d/mopidy.list http://apt.mopidy.com/mopidy.list
          sudo apt-get update
          sudo apt-get install mopidy

          After this, I adjusted mopidy.conf to my needs, added snd-bcm2835, bcm2708_wdog and ipv6 to /etc/modules. After the reboot of the PI it still gets into a loop, therefore I added export LD_LIBRARY_PATH=/usr/local/lib to /etc/init.d/xbmc, without success. Any idea how to fix XBMC so that it starts (and not goes into a kind of loop)?

      • Kikkeraap

        Did you use a specific how to?

    • Rob

      I’ve had the same problem. A fix can be found here: http://geeks.noeit.com/xbmc-library-dependency-error/

  • southafricanrob

    Any idea on how to switch audio output device without a reboot, ie switch from analog to hdmi, or maybe use both at the same time??
    Would make for a great multi room speaker setup

    • http://raspberry-at-home.pl/ Tomasz Szczerba

      I don’t know whether it’s possible, but I would suggest you to use output from whatever you have with hdmi and sound output or getting any external usb sound card that is compatible, raspis internal sound card is awful.

      • southafricanrob

        Thanks – yeah I have a USB external card, much better. I’m still trying to switch between HDMI on the onboard card and the external card – will update if I find a solution…

      • eric

        In MPD it is possible to define multiple sound outputs and you can toggle each one on/off in the clients.

  • driesione

    Is it also possible to have more mopidy servers in the netwerk? In this way, you can chose where to play the music content (different stereo’s in different rooms). This must be great…

    • http://raspberry-at-home.pl/ Tomasz Szczerba

      Yes! That’s possible :) but if I may, think about mopidy as remotely controlled player more than a server. LMS have server capabilities – you can stream music to the slaves and control them separately. Mopidy instances are separate and play local music (or stream it from the internet). Probably you can set some kind of local server to stream music from, but I don’t know about any.

      Regards,
      Tomek.

  • Steven Truyens

    Hello all,
    I’am having problems to even start mopidy.
    Every change I do in /home/…/.config/mopidy/mopidy.conf, it is overwrite by somthing else.
    In the /etc dir is also a mopidy conf file but not accessable
    When I start mopidy, I get a “mpd server startup failed [errno 98] adress already in use.
    Which is used by Python, can some help me

    Thanks in advance

    • Josh

      Same for me!

      • Steven Truyens

        I use now Volumio, works great

    • eric

      Same here. couldn’t find a way to have it read the config from /etc/mopidy/mopidy.conf
      Plus: directories symlinked into /var/lib/mopidy/media are not scanned.

    • Vili

      Run “sudo netstat -npl | grep :6800” and it will show you the pid that uses this port.
      For me it says this:
      tcp 0 0 0.0.0.0:6680 0.0.0.0:* LISTEN 21595/python
      The pid here is 21595.
      When you know the pid, run “sudo kill “

  • Akshay Sharma

    not able to save changes in the config file. please tell me how to do it

    • Vili

      Run mopidy once, if it stops writing lines on the screen, kill it by pressing Ctrl+C and then try ‘nano ~/.config/mopidy/mopidy.conf’