There are two steps for adding music:

  • Add the music files (mp3, etc. ) to the /home/pi/music directory.
  • Create playlists files (m3u) in the /home/pi/playlists directory.

Playlists are really an optional feature from mpd's point of view. However, the Python radio program works by specifying a playlist to use for broadcast. So we'll go through both steps.

Add Music Files

This is pretty simple, just dump all the mp3 files in to the music directory:

music
├── song1.mp3
└── song2.mp3

However, if there are a lot of music files, from numerous artists and albums, then this can get messy. The mpd server will search the music folder recursively. So a good way to organize things is into a hierarchy of artist/album/song. Something like this:

music
├── artist1
│   ├── album1
│   │   ├── song1.mp3
│   │   └── song2.mp3
│   └── album2
│       └── song1.mp3
└── artists2

To provide examples for this guide, we'll use these two short mp3 files. Click each button to download them.

Copy them to the Raspberry Pi. To keep things simple, we'll just place them directly in the music directory so it ends up looking like this:

music
├── beats.mp3
└── happy.mp3

Create Playlist

A playlist is a simple text file with a .m3u extension. Each line of the playlist file references a music file. The full path of the file relative to the music folder is used.

Let's create one called test.m3u using the two example files downloaded in the previous section.

Use nano to create the test.m3u playlist file in the playlists directory.

Add the names of the two mp3 files.

Press <CTRL><X> to save and exit.

Multiple playlist files can be created and stored in the playlists directory.

Update MPD

Anytime new music files are added, or playlists added or updated, the mpd server needs to be told to update its internal database. This can be done using mpc:

mpc update

This will generally be very fast. But if there are a lot of new files to be searched through, it can take many seconds. The update progress can be checked using the status command with mpc. If this does not show "Updating DB", then the update is complete.

This guide was first published on May 24, 2023. It was last updated on Mar 29, 2024.

This page (Adding Music) was last updated on Mar 08, 2024.

Text editor powered by tinymce.