Installing SqueezeLite on OpenElec / XBMC (Shared audio output device) UPDATED

Installing SqueezeLite on OpenElec / XBMC (Shared audio output device) UPDATED

UPDATE 2:

As of OpenElec version 5.0.X Kodi it appears .mp3 playback with Squeezelite is now broken due to missing libraries required for mp3 playback. I can still play .flac .wma and .m4a audio files OK however. There is a thread here on the OpenElec forum where they are discussing this issue and possible work a-rounds. As yet I have not fixed mp3 playback on my own system and am still looking in to it.

Sometime later..

I seem to have mp3 playback working again, you can see how I did this here. Basically you need to update SqueezeLite to a later version it seems. I have updated the article below with the new download links and information!

I have re-tested the SqueezeLite player playback with the following types of audio files and I was able to play them all OK.

.mp3 .wma .flac .m4a (AAC) .ogg

END OF UPDATE

Its taken me along time to work out how to do this and I finally have it setup and working today! So I thought I would write about it here on my blog, so I don’t forget how I did it.

Basically I wanted to run SqueezeLite as a background service on OpenElec and for SqueezeLite and XBMC to use / share the same HDMI audio output device. Not too much to ask for you would think and this is a ten minute setup in Windows however in Linux its taken me much longer to figure it all out.

Note: I have only tested this on OpenElec Frodo V12.2 and not on Gotham, as I haven’t upgraded to Gotham yet. If you try this and it works on Gotham please let me know. (See the update at the end of this post).

Some background, my HTPC is connected to my Denon AVR amplifier via the HDMI cable. I have a 5.1 speaker setup on the AVR in my living room. SqueezeLite if you don’t know is a Squeezebox software emulator, like SqueezeSlave and SqueezePlay etc. SqueezeLite is still being actively developed and is the one you should be using. The reason I wanted SqueezeLite to run as a background service on the OpenElec HTPC, was because I also have a Squeezebox in my kitchen connected to a pair of stereo speakers mounted above my kitchen cabinets. And I wanted to be able to play the same music in the living room in sync with the kitchen room. As the Logitech Media Server software supports playing zones in sync this is ideal.

1. Download SqueezeLite


OK lets get started first you need to download SqueezeLite for use with OpenElec. The download page is here. I used this version: Squeezelite 1.5 Linux ALSA Intel 64 bit as my HTPC is Intel based.

EDIT: There is a new download page for SqueezeLite for Linux which is here. I wasn’t totally sure which one to download for my Intel based HTPC so I picked this one “squeezelite-1.8-ubuntu-lts-x86_64”

2. Install SqueezeLite


The download contained just one file called squeezelite-x86-64 with no file extension, being a Linux newbie at first I had no idea what to then do with this file? You need to create a new directory on your OpenELec PC and copy the squeezelite-x86-64 file in to that new directory. I used this path: /storage/.xbmc/userdata/squeezelite

EDIT: The file downloaded from the new download page was called squeezelite-1.8-ubuntu-lts-x86_64.tar.gz I extracted this file on my Windows 7 workstation using Winrar, I then ended up with two files one called License.txt and one called just squeezelite with no file extension. You need to create a new directory on your OpenELec PC and copy the squeezelite file in to that new directory. I used this path: /storage/.xbmc/userdata/squeezelite

I used FileZilla FTP client to connect to my OpenElec PC and copied the squeezelite-x86-64 squeezelite file in to my new /storage/.xbmc/userdata/squeezelite folder, or you can just use Windows Explorer and enter \\IPADDRESSOFOPENELECPC to access the Samba shares.

image

Next you need to access the Terminal in OpenElec, to do this I use Putty for Windows on my laptop and can then connect to Terminal on my OpenElec PC. You need to select the SSH connection on port 22, enter the IP address of your OpenElec PC and use the default username: root and the default password is: openelec

image

We need to be able to access terminal in order to make the squeezelite-x86-64 squeezelite file executable. The terminal window looks like this.

image

Now navigate to the new squeezelite folder we created, enter the command shown below and press enter

image

The screen should then look like this one

image

Now we need to use this command: chmod +x squeezelite to make that file executable. So go ahead and enter that command and then press enter

image


3. Picking the correct Audio Output Device

OK now we need to think about which audio output device we would like SqueezeLite to run on? As I already stated due to my setup I wanted SqueezeLite to run on the HDMI port. However you may want it to run on the 3.5 analogue port or the digital SP/DIF port? depending on your setup and requirements.

Whilst still in Terminal we can list all the audio output devices on the system, to do this use the aplay –l command

image

I am using an Intel DH67CF Mini ITX media mother board in my HTPC and in the screen shot above you can see what audio output devices I have listed.

** In fact you might be better running this command instead: /storage/.xbmc/userdata/squeezelite/squeezelite –l


SqueezeLite then lists the audio output devices it finds on the system as shown in the screen shot below. If you cannot read it, click here for a larger image.

image

The device from the above list that I need to use is this one: hdmi:CARD=PCH,DEV=1 keep that in mind for later on…

4. Review the max sample rate


Now that we know which audio output device we want to use with SqueezeLite, we need to know what is the maximum sample rate? Connect back up to Terminal using Putty and issue this command:

/storage/.xbmc/userdata/squeezelite/squeezelite -d output=debug


Click here for a larger screen shot of the debug output

image

There is a line that says: output_init_common:394 supported rates: and lists the rates, find the largest number in that list? Mine was 384000

Press Ctrl+C to exit this command


5. Construct the SqueezeLite run command


Ok armed with all of the above information we can now start to construct our command to run SqueezeLite. This is the command I used:

/storage/.xbmc/userdata/squeezelite/squeezelite -o hdmi:CARD=PCH,DEV=1 -m 00:00:00:00:00:fe -r 384000


-o specifies the audio output device I want to use, in my case it was: hdmi:CARD=PCH,DEV=1

-m specifies the mac address the SqueezeLite player will use, I believe it can be the real mac address of the NIC on the PC or you can just make one up as I did, as long as each SqueezeLite instance you have running on your LAN has an individual mac address you should be OK.

-r specifies the maximum sample rate and also importantly enables audio output device to be off when squeezelite is started

One you have constructed your SqueezeLite command, you can test it by running the command in Terminal. Does it work? Do you have a new Squeezebox showing up in the LMS webpage? and can you play / hear an album when selecting that Squeezebox?

image

Tip: You can rename the new SqueezeLite player to a name of your choice like “XBMC01 – Living Room” in the LMS webpage – settings – player tab – player name

image

This is the LMS (Logitech Media Server) webpage

image

Here in the drop down list you can see my new SqueezeLite player aka “XBMC01 – Living Room”

image

 

6. Autostart SqueezeLite on boot up


OK so our command to run SqueezeLite is working we now need to be able to start SqueezeLite every time you turn on your OpenElec HTPC. To do this I used the OpenElec autostart.sh config file. If you haven’t got one already you need to follow this Wiki page here to create one.

EDIT: The OpenElec autostart.sh wiki page contents have changed, it use to tell you how to go about creating your autostart.sh file and now it does not. So this is how to do it:

Using Putty terminal in to your OpenElec PC.

Type these commands one at a time:

cd /storage/.config
touch autostart.sh
chmod +x autostart.sh
nano autostart.sh

You will then see a screen like this one:

In the autostart.sh config file add in the below code to automatically start your SqueezeLite player. Obviously change the SqueezeLite command to the one that you constructed suitable for your system.

#!/bin/sh

# Start SqueezeLite on the HDMI audio output device

(sleep 20; \

exec /storage/.xbmc/userdata/squeezelite/squeezelite -o hdmi:CARD=PCH,DEV=1 -m 00:00:00:00:00:fe -r 384000

)&

You can copy the code text above, then in putty just right click your mouse and the code will appear and then look like this:

 Now press Ctrl + X on the keyboard to save and exit the nano editor. Select Y to save and then press Enter when you see: File Name To Write: Autostart.sh

You will then be taken back to the normal terminal command prompt. Now type “reboot” without the quotes and press Enter on your keyboard to reboot your OpenElec PC.

The SqueezeLite instance should now be auto started each time you boot up your OpenElec PC.

 

Restoring sound back to XBMC

In this setup where XBMC and SqueezeLite share the same audio output device, you need to turn off the SqueezeLite player once you have finished using it, so XBMC will get its sound back. To do this just use the soft ON / OFF button on the LMS webpage or in your Squeezebox mobile remote control app etc.

image

image

Once the SqueezeLite has been soft powered off, the audio will return to XBMC.

Summary


I’ve been wanting to do this since I switched to XBMC and Linux over a year ago and have tried now and again to get it working without much luck. However eventually I was able to piece everything together from various forum posts and figure out how to get it working.

The other Squeezebox in my Kitchen is actually SqueezeLite running on my Windows Home Server, so I don’t actually have any hardware Squeezeboxes. I know syncing software Squeezeboxes is never as good as with hardware Squeezeboxes, however my experience of syncing these two rooms together using SqueezeLite has been very good so far, much better than when I was using SqueezeSlave in the past with Windows MCE.

Now I need to setup SqueezeLite on the OpenElec PC’s in our bedroom and in the kids bedrooms.

UPDATE 1:


I’ve tried this on OpenElec 4.0.4 Gotham now, it works OK but I felt the need to change a setting which was in the XBMC Settings – System – Audio – Keep Audio Device Alive – OFF

Changing this setting to off then allows the SqueezeLite player to use the audio device quicker when you start playing an album in LMS. However on my HTPC connected to my AVR turning this setting off did seem to then have some side affects on the navigational sounds you hear in XBMC when moving around the UI.

When you have finished playing your album in LMS and when you soft power off the SqueezeLite player it can take a little while for the audio to then be restored back to XBMC.

In Frodo it all seems to work a bit better and a bit faster, it still works well in Gotham, if you are aware of these slight niggles.

Until I figure out how to simultaneously at the same time allow XBMC and SqueezeLite to share the same HDMI audio device this is as good as its going to get.

Share

23 thoughts on “Installing SqueezeLite on OpenElec / XBMC (Shared audio output device) UPDATED

    1. I just loaded SqueezeLite on OpenELEC (Generic.x86_64-4.95.3) and it took a little messing around with libraries to get it to support MP3,OGG,AAC and FLAC. I also got it to autostart but that also took a little modification. Here is a link to an archive with all the libs/bin and a working autostart.sh. Just extract it to / on your OpenELEC box. Take note that it will overwrite your autostart.sh. So back up your existing autostart first and then merge in the changes. http://www.mediafire.com/download/ecp6gwl0dm75g34

      You will also have to modify the autostart.sh to match your output device, LMS server and Squeezeplayer Mac.

  1. Great write up. Thanks for the detailed explanations.. Enjoy this blog too..
    I am struggling with the autostart,sh not actually working.. but manually it works great..

  2. Hi, sorry guys, only just noticed these comments, I have updated the article today with new information about OpenElec 5.0.X and .mp3 files not playing, which I now have working again.

    Regarding the autostart.sh file it looks like the OE wiki has changed? I am sure it use to tell you how to go about creating your autostart.sh file, I will look in to this further. Does anyone have a guide for creating autostart.sh file ?

    With regard to having to mess about with libraries to get certain audio file types working I have not experienced the need to do this. If you read the article again I have updated the download page link for the newer versions of Squeezelite and using one of these I updated the squeezelite file on the OE PC and was then able to play .mp3 files again. And I can still play .flac .wma and .m4a (AAC) files OK as well. I don’t think I can test OGG files as I don’t think I have any.

    1. Hello CW-Kid,

      Thanks for this tutorial an all the updates.
      I was just checking the releasenotes of squeezelite 1.8 which talks about a “-C” switch that would close the audio device when Idle.
      This potentially could solve the issue that squeezelite does not release the audio device for Kodi to use it.
      Since I just found this, I didn’t had the time to test this yet.
      Is this something that you found out already, and would it be of any use?

      Martijn

      1. No I was not aware of that switch, but your right it could be useful and mean not having to remember to turn off the Squeezelite player in LMS to get the audio back to Kodi. Will have a look in to it and test.

        1. I did some quick tests and the first results look promissing. When I use 1.8 with the switch “-C 5” and I pause the LMS stream XBMC gets the control over the audio back after 5 seconds. When I start a LMS audio stream while XBMC is playing something, Squeezelite gets audio control right after I stop playback in XBMC. So all together this is exactly the way one would want it to behave for complete Wife Acceptance.

          1. Hello cw-kid,

            I did some futher testing and I realy seems to work wel over here.
            Lets see what the diferences between our configs are.
            I have 5 openelec systems in my house and I tested it on two if them up until now.
            Both systems send their audio over HDMI.
            One of them is doing passtrough to a yamaha receiver and the other is connected directly to a TV and is configured to not passtrough.
            Both systems are running openelec 4.2.1.
            I am using the ubuntu version of squeezelite 1.8. the one you provided in your link.
            Here is an example parameter line of one of my systems.
            -o hdmi:CARD=PCH,DEV=0 -m 00:00:00:00:01:26 -r 384000 -n Slaapkamer1 -C 5.

            I have one system running openelec 5.08 but I did not had the time to test this one out yet.
            Please make sure you use a capital C since the lowercase c does also exists but has a completely different function.
            I hope that this shines some light on differences and theirfor possible reasons why it does not seem to work on your side.

            kind regards,

            Martijn.

          2. I am on OpenElec 5.0.8

            I did use uppercase C.

            Is that -n a naming switch? That could be useful as well. Although I did rename them in the LMS settings.

            Not sure why it didnt seem to work, I will try again on a different HTPC upstairs.

          3. I was on 5.0.8 on several of my systems but could not get the remote.xml or keymaps.xml to work with my Mediacenter Remotes. This is why I was forced to go back to 4.2.1. As I said I still have one system running 5.0.8. But this one is using analog audio instead of HDMI. I will test it on this system as soon as I find the time. Do you still have a 4.2.1 system running somewhere to test it on?

          4. Tested it 5.0.8 with squeezelite 1.8 and definitely working as aspected with the -C option….
            When you pauze the squeezelite the soundcard is released and playback is returned to xbmc or kodi.

          5. Yesterday I did some testing on 5.08 my self and it works indeed. I even got it fully functional on a raspberry pi 2 wit 5.08 on it. Really strange that it won’t work on your side CW-Kid…

          6. CW-Kid, did you get things going with the -C switch? or is there something I can help you with? as I said I have it running on Intel hardware, and on a Raspberry PI 2.
            I have an other question. I am trying to get Google TTS working with squeezelite. I found that this works fine on my Windows machine but not on my Openelec systems. after doing some googling I found several forum posts where you are describing the exact same problem. Did you ever found a solution for this issue?

            Thanks again,

            Martijn.

          7. Doesn’t seem to work for me? I just added -C 5 to the end of my Squeezelite command. SqueezeLite still plays but when I paused SqueezeLite in LMS and then played something in Kodi I had no sound from Kodi.

            In Kodi Settings – System – Audio Output – Keep audio device alive, What do you have it set as?

            Thanks

          8. Hmmm doesn’t seem to work at all this -C 5 switch for me. I can only get sound back to Kodi when I turn off the SqueezeLite player as normally done.

            I am using the HDMI port on my HTPC and have it hooked up to my Denon AVR. So all the audio settings in Kodi are setup for Pass-through and 5.1 etc

  3. Hi

    I downloaded an OGG sample file from here: http://en.wikipedia.org/wiki/Rayman_2:_The_Great_Escape

    I then gave the file some metadata in mp3tag and scanned it in to the LMS music library.

    I then tried to play this OGG file on the OpenElec PC running SqueezeLite and it played but I could not hear any sound.

    I then scanned the OGG file in to the Kodi music library and tried to play it in Kodi, which worked OK and I could hear the music.

    I then tried to play the OGG file to another SqueezeLite instance running on my Windows file server and that worked OK and I could hear the music.

    So it seems I cannot play OGG files on SqueezeLite on the OpenElec PC. However I can seem to play everything else OK, files such as .mp3 .wma .flac .m4a (AAC) which are all the types of audio files I have in my music library.

  4. Hi, i just tried to follow your instructions to set up squeezelite on a wetek Play with OpenELEC.
    I am not sure whether i adapted your tutorial correctly to my needs.
    I can see the Squeezelite instance on my LMS but i get no sound.
    For sure it’s my fault ….

Leave a Reply

Your email address will not be published. Required fields are marked *