Skip to main content

Raspberry Pi Headless Media Center


Greetings fellow Raspberry Pi enthusiasts. I have something pretty cool to share with you today. I've been wanting to use the Raspberry Pi for a media center since I first heard about it. When Newark finally told me I could order the Pi I jumped at it chance and then promptly left town on a family vacation. My nephew Isaiah, who I met up with in Alaska while we were on vacation, discussed the media center project and how to implement it. Upon his suggestion we settled on running VLC. I had assumed we would have to get some webserver up and running and figure out how to slave VLC to our wishes but that is largely built in already. It is called the VLC Web Interface (or VLC http interface). That made this project all the more simple.

Below is the process to install it. This process assumes you have a freshly flashed Raspbian Wheezy (7/15) image that has NEVER BEEN BOOTED BEFORE. This made the most sense for us as we assumed you would plop this guy down somewhere and not use it for anything else.
  1. Take a freshly flashed Raspbian Wheezy imaged SDCARD and put it in your RÏ€
  2. Make sure your WIFI adapter is NOT plugged in.
  3. Plug in keyboard
  4. Plug in Ethernet cable connected to the Internet
  5. Plug in RÏ€
  6. Raspbian will boot up to the setup screen
    1. expand_rootfs
    2. configure_keyboard
      1. Select keyboard that works for you (default is UK which is hard to use with a US keyboard) Images of this process are at the bottom of this post (its sort of long and tedious).
    3. change_locale
    4. change_timezone
    5. ssh
      1. enable SSH Server (not necessary but useful since its headless)
    6. boot_behavior
      1. So NO. You want to disable booting to the desktop
  7. Reboot
  8. Login as root. Type "root" at the login prompt.
  9. Enter the commands below. (downloads and executes an installer script written by my nephew)
    wget db.tt/rDy1S8Ga -O install.sh
    source ./install.sh
    
    It will prompt you the following things:
    Press zero to set output to auto, press 1 to force headphone jack, press 2 to force HDMI.
    
    I recommend you select 1 if you plan to use the headphone jack.
    Would you like to setup the GPIO relay [y/n]?
    Click Y if you want GPIO25 (pin 22) to go HIGH (3.3V) when VLC is playing. Pin 22 is positive and Pin 6 is GND. The numbering system is strange because it starts at 1. You want the third pins from the top and bottom on the outside. Refer to the photo below. SSR available at Amazon.com
  10. Would you like to install rtl8188cus WIFI drivers [y/n]?
    This is the driver for the WIFI adapter I selected. Available at Amazon.com
    This driver installer was acquired from the RÏ€ forum and used with permission.
  11. At this point the install actually begins. VLC takes a long time to download and install. Then, if you selected the WIFI drivers it will ask you a bunch of VERY IMPORTANT questions and PROMPT YOU WHEN IT IS SAFE TO INSERT YOUR WIFI ADAPTER. Please read and follow along. I found that if it pauses for a long time while it prompts you to wait for the adapter to blink and connect  a quick re-plugging in of the adapter gets the system running again. The WIFI driver script ends asking you if you would like to upgrade your entire RÏ€. I say no.
  12. Unplug your ethernet cable (if you are using wifi).
  13. Reboot.
  14. Boot up screen will tell you what the new IP address is on Wifi. make a note of it. You can then use this address to talk to your RÏ€ from local devices on the network. You can setup a static IP if you desire by going to /etc/networks/interfaces and changing the
    iface wlan0 inet dhcp
    TO
    iface wlan0 inet static
    address *your ip*
    netmask 255.255.255.0
    gateway *your gateway ip*
    
    wpa-ssid "*your SSID*"
    wpa-psk "*your password*"
    
You can now find you VLC running at http://*ip address*/. If you want to see if from the actual RÏ€ you need to go to http://localhost:8080 but we went through the effort of updating the IPTABLES to forward port 80 to port 8080. The /home/pi folder is the default place it looks for music.

The GPIO stuff works by running a script that checks the VLC status stream and turns the pin on or off as necessary. I did this with one long shell command the executes every 300ms. There are no doubt many ways to do this, but I always liked AWK and | so that's how I did it (its below). You can find all scripts we wrote to make this work in the /root folder.

wget -qO- localhost:8080/requests/status.xml | awk '/<state>/ {if (index($0,"playing") > 0 || index($0,"paused") > 0) {print "echo "1" > /sys/class/gpio/gpio25/value"} else {print "echo "0" > /sys/class/gpio/gpio25/value"}}' | bash

One thing I should mention is that depending on your network speed, you may want to increase the buffering cache so you do not get skips during streaming playback. This is done by modifying the /etc/init.d/rc.local. Add the two caching arguments you see below (to the line starting vlc you'll find it in there somewhere)
su - vlc -c "vlc --intf http --daemon --disc-caching=20000 --network-caching=20000

These are some screen shots from the initial config. I found the keyboard part sort of confusing.

Comments

  1. Thanks so much for this guide. Worked perfectly! Any idea, though, why .pls files (i.e. the stream from indiepoprocks internet radio station) won't show up when browsing the file system for media? I checked that it is an allowed file type in the internals of the vlc distro that we're using here... And it is. I wonder if it is a limitation with the front end of the interface that you built?

    ReplyDelete
  2. oh wait! I figured it out. I needed to edit controlers.js in /usr/share/vlc/lua/http/js according to the commit here: http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?p=vlc/vlc-2.0.git;a=commitdiff;h=9855165f8168f0db54852d208fd8be8a3e5cffb1;hp=ac7e319910923a63323728ce7ce999a52432c548

    ReplyDelete

Post a Comment

Popular posts from this blog

A Capacitive-Touch Janko Keyboard: What I Did at the 2017 Georgia Tech Moog Hackathon

Last weekend (February 10-12, 2017) I made a Janko-layout capacitive-touch keyboard for the Moog Werkstatt at the Georgia Tech Moog Hackathon. The day after (Monday the 13th), I made this short video of the keyboard being played: "Capacitive Touch Janko Keyboard for Moog Werkstatt" (Text from the video doobly doo) This is a Janko-layout touch keyboard I made at the 2017 Moog Hackathon at Georgia Tech, February 10-12. I'm playing a few classic bass and melody lines from popular and classic tunes. I only have one octave (13 notes) connected so far. The capacitive touch sensors use MPR121 capacitive-touch chips, on breakout boards from Adafruit (Moog Hackathon sponsor Sparkfun makes a similar board for the same chip). The example code from Adafruit was modified to read four boards (using the Adafruit library and making four sensor objects and initializing each to one of the four I2C addresses is remarkably easy for anyone with moderate familiarity with C++), and

Onboard Firmware of the Human Brain

Freesiders are continually tinkering with robotics and other such machinery .  Many of these embedded processors and firmware are becoming open source and every-more diversified in the wake of the modern Maker movement . One notable boost to the hackerspace arsenal is the Arduino (an like platforms).  This offers designers an incredible power to devise not just individual devices but even the emergence of complex, integrated systems . This evolutionary pace of modern technological systems may be significantly faster the biologic system development, but there may be a few well learned tricks yet to be mastered.  It seems that studying how nature has managed to solve many development challenges will aid in designing robotics, where efficiently counts just as much. One  challenge, that is particularly interesting, is data processing.  Artificial intelligence is labored with processing data and producing a meaningful and useful output.  When considering the increase in sensory

Freesiders Hackers Collaborate in Medical / Surgical Research

Published in the May issue of the Journal of Foot and Ankle Surgery : " A Novel Combination of Printed 3-Dimensional Anatomic Templates and Computer-assisted Surgical Simulation for Virtual Preoperative Planning in Charcot Foot Reconstruction ." This collaboration of specialties represents an undertaking by members of Freeside Atlanta , Southern Arizona Limb Salvage Alliance , and The Podiatry Institute .  Charcot foot reconstruction remains on of the most challenging procedures in foot and ankle surgery.  These procedures are often lengthy procedures which can be riddled with complications. With the help of Freeside Atlanta Members, institutional researchers used open source Osirix Image viewer and 3D Software such as Newtek's Lightwave or Blender to create simulated surgical reductions as well as 3D printed templates.  Freeside Atlanta members assisted in providing 3D printing solutions and know-how to the project. Experimental test prints were done on a M