Friday, November 21, 2014

Netflix on standalone XBMC in Linux

For a long time, getting Netflix working on Linux was really tricky. On a standalone Linux XBMC HTPC system, it was virtually impossible, so much so that I didn't even try it. Now though, with Chrome supporting HTML5, it's a lot easier.

I used NetfliXBMC + Chrome Launcher. NetfliXBMC lets you browse the content in XBMC, and can then launch the selected content to play in Google Chrome.

I'm using Arch Linux, with XMBC, without a desktop environment, you may be able to skip some of these steps, or adapt them according to your configuration.

Anyway, here's how I did it.

Update: Edited to reflect that there is a new repository and a new thread for NetfliXBMC on the Kodi forums.

Update 2: In Helix, it is not possible to start/stop openbox at launch/close of chrome, it must be started before Kodi does. So I have updated the script and added step for how to do this.

Get Chrome and NetfliXBMC up and running

  1. Install the XBMC repository for Chrome Launcher, you can find a link to it on the Chrome Launcher Kodi forum thread
  2. Install Google Chrome (need at least version 37, AUR has version 38, and that's the one I installed)
    1. Download the package file from AUR
    2. Instruction for how to install from AUR can be found here. Make sure to use the -s argument when you do makepkg, since it includes dependencies.
  3. Install Openbox window manager and xdotool: sudo pacman -S openbox xdtool
  4. Edit your kodi startup script (probably /usr/bin/kodi-standalone), and add "openbox &" (without the quotation marks) as the first instruction in it (immediately after the copywrite stuff). OBS: It seems that this gets lost when you update the Kodi package, so it needs to be redone when that happens 
  5. Create a script for launching Google Chrome (I simply called it chrome.sh and placed it in the xbmc home folder). It moves the mouse pointer off screen and starts Google Chrome.
    #!/bin/bash
    xdotool mousemove 0 740 &
    /opt/google/chrome/google-chrome $*
  6. Make the script executable: chmod + x chrome.sh
  7. Set Chrome launcher to start using this script
    1. Go to Add-On Settings
    2. Toggle "Use custom chrome/script path"
    3. Select "Chrome/script path", browse and select your script
  8. Install NetfliXBMC, you'll find it in the repository here
  9. In the Add-on settings for NetfliXBMC, enter you Netflix username and password, the rest of the settings are up to you

Video settings

My system runs natively at 720p, but XBMC runs at 1080p, this means that it'll change to 720p when Chrome opens.
  1. To fix this issue, I placed a config file in /etc/X11/xorg.conf.d/ (actually I added to one I already had, named 20-intel.conf):
    Section "Screen"
        Identifier             "Screen0"
        Device                 "Intel Graphics"
        Monitor                "PANASONIC TV"
        DefaultDepth           24
        SubSection             "Display"
            Depth              24
            Modes              "1920x1080"
        EndSubSection
    EndSection

Audio settings

Looking at the forums, there seems to be a lot of users that have a problem with this.

While audio works fine in XBMC, it didn't work at all outside of it (ie in Chrome) for me. Having looked around the forums on this, there seems to be many for which this is the case.
  1. In XBMC, set "Settings -> System -> Audio output -> Keep audio device alive" to "Off"
  2. Install alsa-utils: pacman -S alsa-utils
  3. From command line: alsamixer
  4. Unmute and raise volume for the channels that you are using
  5. You need the card and device numbers for the soundcard that you are using (even if it is built in): aplay -l
  6. Create a file (if it doesn't already exist) in the xbmc home directory (for me, /var/lib/xbmc), called .asoundrc, and place this info in it (replace card and device numbers with your own found above)

    pcm.!default {
        type hw
        card 0
        device 3
    }

Controls

If you are using a remote control, you'll want to assign one of the buttons to Esc or Alt+F4, in order to close Chrome when you are done watching something.

Aside from that, both Enter and Space work as play/pause, and since I use Enter to select a movie to play in XBMC anyway, that works out. The left and right arrows step back and forward in the movie, so they work kind of like rewind/fast forward (actually, I prefer the steps).

I kind of wish that I could access the sound/subtitle settings as well, but I haven't yet found a (good) way to do this.

Finally, if you absolutely feel that you want to use "p" (ie the same as play button in XBMC) to play/pause, there is an extension for Chrome that can make this happen called Flix Plus.

Remaining issue

My one gripe is that I only get stereo sound, rather than surround. After googling a bit, it turns out that surround sound is not supported by Netflix when using a HTML5 browser... So basically, it's Netflix's fault. Still, I think I prefer a nice and convenient interface and stereo audio, to my BD players slow-a** interface with surround. Maybe fire up the BD or Xbox if there is a specific movie that I really want 5.1 audio on.