Chapter 8
IN THIS CHAPTER
Using LibreELEC to turn your Pi into a media center
Playing music and video stored on USB devices or networked devices
Viewing photos in the media center
Playing music in the desktop environment
In this chapter, we show you how you can turn your Raspberry Pi into a media center, capable of playing high-definition video files and music.
To do that, we use dedicated media player software based on the Kodi software that powers some set-top boxes and smart TVs. You can use it to play music and video you have on storage devices connected to your Raspberry Pi, or to play back media from other devices on your home network. To a more limited degree, you can also use it to play back streaming TV shows and radio stations from the Internet.
At the end of this chapter, we also show you how to play music on your Raspberry Pi in the desktop environment.
The Raspberry Pi can play back full HD 1080p video, which makes it ideal as the heart of a cheap and low-powered media center. The NOOBS software includes two Linux distributions, both based on Kodi, that turn your Raspberry Pi into a media center. The choices are OSMC and LibreELEC. Because they’re both based on the Kodi core, they have many similarities. In this chapter, we use LibreELEC because it uses the default Kodi design (or skin), so it's more likely to resemble other Kodi systems you have used. It's also a more lightweight option, so it may perform better on lower-powered Raspberry Pi models.
If you're using OSMC, the design looks different, but you should still be able to follow along in this chapter. To make it easier, you can choose the default Kodi skin by clicking Settings on the left, choosing Interface from the menu that appears, and then choosing Skin. Click Skin in the main part of the screen to open the options and choose Estuary, which is the Kodi default. You can change back to the OSMC skin from Estuary by clicking the Cogwheel icon at the top of the menu on the left, choosing Interface Settings from the menu that appears, hovering over Skin on the left, and then clicking Skin in the main part of the screen. You can exit any of the menus by pressing Esc.
To start setting up your media center, create an SD or MicroSD card with NOOBS Lite on it (see Chapter 2), and then use that card to install LibreELEC (see Chapter 3).
When you first boot up LibreELEC, you'll be guided through its main settings, including its name on the network, the network connection itself, and the remote access settings (so that you can access files on your device over the network).
The Kodi screen looks like Figure 8-1. LibreELEC uses Kodi’s simple interface, which is designed to work with only a remote control. In this chapter, we assume you’re using a mouse, but we give you some pointers on using remote controls in the section “Using a Remote Control,” later in this chapter. If you’re using a remote control, you should find the interface intuitive.
The menu on the left side of the screen gives you access to the different content types, including movies, TV shows, music, and music videos. When you hover the mouse pointer over one of these options, the main screen area on the right shows you options and submenus for accessing your content. The Music section, for example, shows you categories you can browse, recently played albums, recently added albums, random albums, random artists, unplayed albums, and most played albums. You can use the cursor keys to move around the options; or the mouse, with the scroll wheel moving between the options within a menu. To exit a menu, press the Escape key.
To select an item and start to play it, simply click it. You can pause playback by tapping the spacebar, and tap Escape to get back to the menu.
At the top of the menu on the left are buttons for switching off your Pi, accessing the settings menus (the Cogwheel icon), and searching for content (the magnifying glass).
Before you can play back content, you need to tell Kodi where it can find it. You have several options for providing it:
Kodi can create a library of your media and index it to provide you with easy access to it. You'll need to add your content to the library first to benefit from this.
To add music to your library, follow these steps:
Hover over Music in the menu on the left.
If you've already added music, you'll see options to browse it by artist, album, and year, among other categories.
Choose Files from the Categories menu at the top of the screen. (Use the scroll wheel to scroll this menu horizontally until you find it.)
This will show you the folders you have added to your library already, and any connected storage devices.
Choose Browse in the Add Music Source dialog box that opens and use the options to find where your music is stored. (See Figure 8-2.)
If you’ve connected a USB drive to your Pi, you can find it by clicking Root filesystem, media, and then the name of your USB device. To find media connected on your network, try the Windows Network (SMB) or Network File System options.
You may need to enter your username and password, and you should enable the option to remember them for this path if you don't want to have to enter them whenever you access your media. Click folders to open them. The .. (two dots) option at the top takes you up a level in the folder structure.
In the Add Music Source dialog box enter a name for the media source, if you want.
This will help you to identify the source on the menus.
To add movies to your library, follow these steps:
Click Movies from the menu on the left.
If you can't see it, it's probably off the top of the screen. Hover the mouse cursor over the menu and use the scroll wheel to bring the Movies option back again.
If you've already added some films, you'll see a list of them with .. (two dots) at the top of the list. In that case, click .. twice to go up a level and then choose Files. This will show you the folders you have added to your library already.
Choose Browse and use the options to find where your films are stored.
If you’ve connected a USB drive to your Pi, you can find it by clicking Root filesystem, media, and then clicking the name of your USB device. To find media connected on your network, try the Windows Network (SMB) or Network File System options. Click folders to open them. The .. option at the top takes you up a level in the folder structure.
Click OK.
If prompted, confirm that you'd like to refresh items in this path.
You can add TV shows or music videos using a similar process — just change the media type to TV Shows or Music Videos in Step 5.
To add photos, you follow a similar process to adding music and movies. Start by clicking Pictures from the main menu on the left, and then choose Add Pictures from the menu that appears. You can then add a folder of photos.
To view the folder, hover over Pictures on the main menu on the left and then select the folder name. You can use the left- and right-arrow keys to navigate your photos and hover over options in the bottom left to open a menu that enables you to display a slide show.
If you're in a folder and you want to view a different folder or add more pictures, click .. at the start of the photo folder.
Streaming media means that the content flows into your Raspberry Pi over the Internet as you watch it or listen to it. As a result, streaming services only work when you have a good Internet connection.
To enable streaming, you use add-ons, which are third-party applications that access sources of content online. Music add-ons, for example, enable you to listen to Internet radio stations and access some online music services. Video add-ons can give you access to online TV stations. The availability of add-ons varies over time as new services launch and older services disappear. The music and video add-ons can be particularly short-lived and unreliable because broadcasters are often keen to keep viewers using their own software and gateways.
To install an add-on, hover over Add-ons on the main menu on the left, and then choose Install from Repository from the menu at the top of the screen. From the new menu that appears, choose Kodi Add-On Repository to find add-ons from the official Kodi repository, which offers a range of add-ons that have undergone basic testing.
As well as music and video add-ons, there are options for a weather forecast provider, screensavers (in the Look and Feel category), and picture add-ons. Note that if you add a screensaver, you'll also need to enable it in the Interface settings.
To get started with playing music, hover over Music on the main menu to show your music collection in the main part of the screen. You can use the Categories menu at the top to browse by genre, artist, album, or song, among others. You can also choose Files from the Categories menu to go to the music folders you have added. In the main part of the screen are options for recently played or added albums, and random artists and albums too. Click a song to play it.
When music is playing, click the Options button in the bottom left to open a menu with options to pause, stop, or skip the track. From this menu or from the top of the main menu, click the icon showing four arrows, like a compass, to view the song full screen, where there are additional options for repeating or random song order. Note that there is a screensaver, so the screen display disappears after a moment or two. Press Escape to go back to the menu. You can tap the spacebar to pause or unpause the audio.
You can continue to browse your music while it is playing, and queue songs or albums to play next, by right-clicking them and choosing Queue Item from the menu that appears.
The Playlists option in the Categories section of the Music menu enables you to create lists of songs for playback that you can save and play whenever you want. Start by clicking New Playlist in the Playlists option to create a new playlist. To add a song from the Playlist browser, right-click its name and click Add from the menu that opens. When you've finished creating your playlist, choose Save from the menu on the left.
You can also make smart playlists, which are playlists that are generated from rules, such as songs that belong to particular years, genres, or artists. You need to add your rules before you can give your playlist a name. You use a simple menu system to set up your playlist rules.
Use the Movies, TV Shows, Music Videos, and Videos options to view your video content. What's available under each option will depend on the media you added in each section, and what type of media you told Kodi it was at the time (such as movie or TV show).
The Kodi software supports the H.264 video format to 1080p, which means you’ll be able to watch most .mp4
, .m4v
, and .avi
files in high definition. Note that content protected by digital rights management, including files bought from iTunes, can't be played in Kodi.
To play films, hover over Movies on the main menu to see options for different categories, recently added movies, random films, and unwatched movies. Click a film to start watching it. You can also click Movies on the main menu to see a list of your films, together with artwork and a synopsis downloaded from the Internet. Click the .. option at the top of this menu, and then click it again on the next menu to get to your files if you want to play media that isn't indexed in the library. As with audio, you can tap the spacebar to pause or unpause a film.
Click Pictures from the main menu to see a simple file browser that you can use to access your pictures, with your added folders listed. The media center software supports standard image formats, including JPEG, BMP, and TIFF, and generates thumbnails of your photos and folders. Navigate to a photo and click it. You use the left and right keys to move through your photos, and the Escape key (or right-click the mouse) to return to the menu.
The cogwheel at the top of the main menu gives you access to the settings for Kodi, divided into several sections. They include, among others:
Considering all the functionality we’ve covered in this chapter, you’re not that far away from running a low-power home media center. To complete it, you can use a remote control.
There are many ways to remotely control your Raspberry Pi media center. You can use a USB device, a cheap infrared remote, a keyboard remote, or even your Xbox controller, if you have one. Or you can use the existing Kodi remote app (available for iOS and Android operating systems) to control Kodi on your Raspberry Pi.
If you have a television that supports the HDMI CEC (Consumer Electronics Council) standard, a neat option is to enable your existing television remote to control your Pi. To do this, connect your networked Pi to your television’s HDMI socket. XMBC appears as a new input. Use the TV’s remote control to change to this input, and your Home screen then appears on the television.
To turn off your media center properly, click the Shutdown button in the top left of the Kodi main menu. You can just switch off the power supply, but you minimize the risk of corrupting your SD card or MicroSD card by shutting down properly.
Looking for musical inspiration while you program? The good news is that you can also play music and video from the Raspbian desktop environment. (See Chapter 4.) If you’re still using LibreELEC or OSMC, shut down your Raspberry Pi using the Shutdown icon in the top left and then reboot into Raspbian. You will need to either swap SD or MicroSD cards or, if you’re using NOOBS, choose to use Raspbian when you reboot.
VLC Media Player is a music and video player that works on the PIXEL desktop. You can install VLC at the command line (see Chapter 5) using:
sudo apt-get install vlc
After VLC has been installed, you can find it in the Sound and Video category of the Applications menu and click its name there to start it up.
On the Media menu of VLC are options to open a file or directory. Usually, you’ll want to open a directory so that you can play a whole album. By default, VLC shows you the album artwork (where available), but you can open the View menu and choose Playlist to see a list of songs so that you can pick another to play (as shown in Figure 8-3). In the box on the left, you can pick a device to play from, including several Internet services for streaming music. Choose Playlist from the View menu again to revert to the full-window artwork.
The playback controls to pause, play, skip, shuffle, and repeat songs are at the bottom left of the window. The volume control is at the bottom right.
3.147.66.178