Turn the Pi into a Multimedia Center - Raspberry Pi: A Quick-Start Guide, 2nd Edition (2014)

Raspberry Pi: A Quick-Start Guide, 2nd Edition (2014)

Chapter 7. Turn the Pi into a Multimedia Center

The Pi’s small size, its low power consumption, and its graphics capabilities make it a perfect candidate for a fully integrated multimedia center, just like a PlayStation or an Apple TV box. To turn the Pi into such a multimedia center, you need a special piece of software named XBMC.[76]

XBMC is a media player on steroids that can turn nearly every PC into an entertainment hub for digital media. The Pi is no exception. In this chapter, you’ll learn how to run XBMC on the Pi.

Install Raspbmc

XBMC is a really big software project, and installing and configuring it can be tricky. Fortunately, you don’t have to do it yourself for the Pi; you can benefit from the glorious efforts of the Raspbmc[77] team. Raspbmc is a Linux distribution for the Pi that does nothing but run XBMC. You can install it using NOOBS (see Have a Look Around with NOOBS) or copy an image of this distribution to an SD card as usual. Then you can use the SD card to boot the Pi. Instead of starting a terminal or a desktop environment, the Raspbmc distribution starts XBMC automatically.

In contrast to other Linux distributions for the Pi, the Raspbmc team not only offers for download a complete image file for an SD card, they also decided to create an installer for all major platforms. This installer downloads the latest version of Raspbmc from the Web and automatically copies it to your SD card.

If you’re using a Windows PC to prepare a Raspbmc card, download the installer,[78] extract it to your hard drive, and start the program named installer.exe. You’ll see a window similar to this:

image


Figure 34. Raspbmc installer for Windows

Insert an SD card, select your SD card reader, and click the Install button. The installer will download the latest version of Raspbmc and copy it to the SD card. Note that the installer will delete all the data on the SD card.

The Raspbmc installer for Linux and Mac OS X doesn’t have a fancy UI, but it’s easy to use. It’s a Python program, and after you’ve downloaded it,[79] you can run it from a terminal, as in the following example:

image

image

image

The installation program shows a list of all the drives connected to your PC, including the SD card reader. On your PC the output will be different, but in the previous example, the SD card is mounted under the name disk4. Enter its name and confirm that you’d like to install Raspbmc. Make sure you choose the correct drive, because the installer deletes all the data on the device you’ve selected!

After you’ve created a bootable SD card, insert it into the Pi and turn it on. Surprisingly, the Pi won’t start XBMC right away; rather, it boots a minimalist Linux system and starts the actual installation of Raspbmc. First it repartitions the SD card and formats the newly created partitions. Then it downloads and installs the root file system, the kernel, some kernel modules, and a few libraries. After a reboot, it eventually downloads and installs the latest version of XBMC.

None of these steps requires user interaction. Depending on the speed of your SD card and your Internet connection, they take about twenty to thirty minutes. So, you can safely go for a walk or have a cup of your favorite hot beverage.

Start Raspbmc for the First Time

After the installation process has finished, Raspbmc starts XBMC automatically. Its main menu looks like Figure 35, Raspbmc main menu.

image


Figure 35. Raspbmc main menu

At first sight, XBMC looks like many other media players. It has menu items for viewing photos, watching videos, playing music, and configuring some system preferences. These functions are mainly self-explanatory—for playing or viewing any kind of content, you can simply select media files from the SD card or a USB device, and XBMC will output them.

To attach a USB device, such as a hard drive or a USB stick, to the Pi, you have to use a USB hub, or you have to temporarily disconnect your mouse and control XBMC using your keyboard. Instead of choosing a menu item by clicking it with the mouse, you can move the focus with the cursor keys and press Return to select an item. When you press the Esc key, you go back one step in the menu hierarchy.

To get the most out of XBMC, you should connect it to your network. If you’ve connected your Pi using Ethernet, you don’t have to do anything; XBMC will recognize it automatically. If you want to use Wi-Fi, choose the Programs > Raspbmc Settings menu. In the Network Configuration tab (see Figure 36, You can change many settings using the Raspbmc Settings menu), set the Network Mode to Wireless (WIFI) Network. Then enter your wireless network’s SSID and your password. Usually, it’s beneficial (but not necessary) to set a static IP address for your Pi when it’s running XBMC. So disable the Use DHCP button and enter a unique IP address in “IP address.” Click the OK button, and you’re finished.

image


Figure 36. You can change many settings using the Raspbmc Settings menu.

XBMC is more than a simple media player; you can improve and enhance it using many add-ons that are available for free on the Web. Simply put, add-ons give you access to media on the Web. For example, you can find add-ons that aggregate the content of certain TV stations or add-ons that give you access to the music of the greatest video games. XBMC even provides a very convenient way to manage add-ons. In Figure 37, Managing add-ons in XBMC, you can see the TED add-on, which lists the latest and greatest TED conference videos.

image


Figure 37. Managing add-ons in XBMC

Take a few minutes and browse the list of add-ons to see whether there’s something interesting to you. When in doubt, install it and take a look. It’s easy to remove an add-on if you don’t like it. Note that you need to make sure you have enough bandwidth for most add-ons, because they stream a lot of data.

Depending on the speed of your SD card and your Internet connection, you’ll experience a noticeable lag when choosing menu items in XBMC. This might get better in future releases, but for the moment you have to live with it and be patient when navigating through XBMC’s menus. However, playing content works fine, without any lags or staggering.

Finally, you should take a look at the Systems > Settings menu and see whether all settings match your local setup. If you’re using composite video, for example, you have to choose analog as your audio output device in Systems > Settings > Audio.

Add Files to XBMC

In XBMC you can easily add new movies, TV shows, or music using the Add Files menu in the Videos or Music menu. Before you start to add your media files, you should know how XBMC works internally. XBMC is more than a simple media player; it’s a full-blown media library that tries to automatically get as much information about your media files as possible. For example, XBMC reads additional information about your favorite TV shows from web databases and adds them to your library. This can be anything from an episode’s original air date to a short summary.

To do this, XBMC depends on a certain file-naming scheme—you can read all about it on the project’s wiki.[80] Note that choosing the correct filenames and directory structures even affects XBMC’s main menu. If you add a directory for TV shows, for example, XBMC adds a TV shows menu item to its main menu. So, to get the most out of XBMC, you should rename your media files accordingly before you import them.

Video and Music Formats

XBMC supports nearly all container formats and codecs on the market. You’ll rarely find a multimedia file that the Pi can’t play. There’s one problem, though: the Raspberry Foundation licensed hardware acceleration only for the H.264 video codec. Fortunately, this is one of the most popular codecs available, but if you have video files using a different codec, you might not be able to watch them unless you buy a license for them. At the moment, you can buy licenses for MPEG-2 and VC-1 online.[81] You provide your Pi’s serial number and get back a license key that you enter in Raspbmc’s Settings menu.

The easiest way to add files to XBMC is to attach a USB device containing your media files directly to the Pi. This solution works fine, but it also has some disadvantages. The USB device often is bigger than the Pi itself, and it probably consumes more power, too. In addition, it requires at least one of your valuable USB ports. A better solution is to store media on the SD card or to stream media from your local network. Because of XBMC’s great network integration, you can implement both solutions easily.

XBMC supports FTP, SFTP, SSH, NFS, and Samba out of the box, and you don’t have to configure much to get them all up and running. XBMC enables SSH by default, so to copy data to the SD card, you can use scp, for example, as you did in Use Secure Shell with the Pi. Run the following command from your PC’s terminal to create a folder named Movies in XBMC’s home directory:

!

maik> ssh pi@192.168.2.109 "mkdir /home/pi/Movies"

Replace the IP address with your Pi’s address. Note that Raspbmc also comes with a user named pi that has the password raspberry at the moment. Now you can copy media files using scp and add them to the XBMC library afterward.

!

maik> scp Pulp\ Fiction\ (1994).avi pi@192.168.2.109:Movies

Even if you use an SD card with plenty of space, it probably won’t be enough to store your whole media library. Also, it doesn’t make sense to always copy files before you can watch a film or listen to some music. That’s what network file systems such as NFS and Samba were built for, and XBMC supports them all.

Using NFS or Samba, you can host all your media files on your regular PC and stream them to the Pi when you want to use them. Configuring NFS[82] or Samba[83] is beyond the scope of this book, but the XBMC wiki has excellent documentation for all major platforms.

As soon as your media files are available in your home network via NFS or Samba, you can easily access them using XBMC. For NFS you don’t usually have to do anything, and you can configure your Samba settings in the System > Service > SMB client menu.

Control XBMC Remotely

If you want to use the Pi as a multimedia center in your living room, sooner or later you’ll want a remote control. If you have a modern TV, chances are good that you can control the Pi using your TV’s remote control. Modern TV sets use the HDMI cable not only for transferring video and audio data, but also for transmitting remote-control commands. In this case, your TV set will send remote-control commands automatically to the Raspberry Pi.

If your TV isn’t quite as modern, you can use some special hardware with an infrared dongle,[84] but the easiest method is just to use your smartphone.

Not only does XBMC have add-ons for managing your multimedia files, it also allows you to install web interfaces for controlling XBMC remotely. Go to the System > Settings > Services > Webserver menu and enable the “Allow control of XBMC via HTTP” option. Then click the “Web interface” button and select Get More. In Figure 38, XBMC comes with several web interfaces, you can see the currently available web interfaces. Enable all of them so you can try them and choose your favorite.

image


Figure 38. XBMC comes with several web interfaces.

After you’ve enabled the web interface, you can use it with every browser that has access to your network. The interface listens on port 80, so in your browser, you only have to enter your Pi’s IP address, such as http://192.168.2.109, to open XBMC’s web interface. (Remember to replace the IP address with your Pi’s IP address.) In Figure 39, The AWXi web interface in action, you can see the AWXi web interface in action, for example. It has all the usual buttons, such as play, pause, and stop, and it allows you to search your whole media library.

image


Figure 39. The AWXi web interface in action

If you have an iPad/iPhone[85] or an Android phone,[86] you can even install a native remote control application for XBMC. In Figure 40, Control XBMC on an Android device and Figure 41, It looks and works like a regular remote, you can see the Android version. It not only looks beautiful, but it also provides convenient access to all XBMC functions. In many regards, it’s much better than a regular TV remote.

image


Figure 40. Control XBMC on an Android device.

image


Figure 41. It looks and works like a regular remote.

If you’re still not satisfied with the remote control, you can search for even more advanced XBMC remote control apps. At the time of this writing, one is Yatse,[87] and more will probably be available soon.

Next Steps

In this chapter, you learned to do something completely different with the Pi. For the first time, you didn’t use it as a regular PC; instead, you turned it into a special-purpose device, a multimedia center. In the next chapter, you’ll learn how to run even more multimedia applications on your Pi, and you’ll play some entertaining games.

Footnotes

!

[76]

http://xbmc.org/

[77]

http://www.raspbmc.com/

[78]

http://www.raspbmc.com/wiki/user/windows-installation/

[79]

http://svn.stmlabs.com/svn/raspbmc/release/installers/python/install.py

[80]

http://wiki.xbmc.org/index.php?title=Adding_videos_to_the_library/Naming_files

[81]

http://www.raspberrypi.com/license-keys/

[82]

http://wiki.xbmc.org/index.php?title=NFS

[83]

http://wiki.xbmc.org/index.php?title=Samba

[84]

http://www.raspbmc.com/wiki/user/configuring-remotes/

[85]

http://itunes.apple.com/gb/app/official-xbmc-remote/id520480364

[86]

https://play.google.com/store/apps/details?id=org.xbmc.android.remote

[87]

https://play.google.com/store/apps/details?id=org.leetzone.android.yatsewidgetfree