Feature #396


Need a music player app

Added by Hammel over 9 years ago. Updated over 5 years ago.

04 - Applications
Target version:
Start date:
11 Nov 2014
Due date:
% Done:


Estimated time:
01 - Critical


This app would allow browsing music using:
  1. Directory/File name
  2. Artist's Name
  3. Album name
    The top level list shows one of these three and the user selects and drills down to find the music of interest.

It requires a playlist to be configurable and can be saved and reloaded.

It should display the current album cover and title being played.

This all means it needs to be able to read ID3 tags from mp3's and have a directory for album covers.

If I can find a lightweight player (one that easily cross-compiles on PiBox) I may use that, otherwise we may have to write one.

Files (1.09 KB) - Generate a set of JSON files from ID3 data, including cover art and filename. Hammel, 31 Jan 2019 16:47 (1.09 KB) Hammel, 31 Jan 2019 16:56
Actions #1

Updated by Hammel over 9 years ago

Various players:
  1. Nightingale
  2. Clementime
  3. Exaile

Subsonic is also an (very good) option since it provides an API we can use from a GTK+ app. However, it requires Java 5 or later. See RM #

Actions #2

Updated by Hammel over 9 years ago

Web based servers/players that might work (some require Java so need to be tested with JavaVM).
  1. Subsonic - requires Java but has an API
  2. Ampache - may not require Java and has an API
Actions #3

Updated by Hammel over 9 years ago

Ampache requires MySQL so that one won't be used.

Actions #4

Updated by Hammel over 9 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10
Other possibilities
Actions #5

Updated by Hammel over 9 years ago

  • Target version changed from 1.0 - Atreides to 0.13.0
Actions #6

Updated by Hammel over 9 years ago

  • Severity changed from 03 - Medium to 02 - High
Actions #7

Updated by Hammel over 7 years ago

  • Priority changed from Normal to Urgent
  • Severity changed from 02 - High to 01 - Critical
Actions #8

Updated by Hammel about 6 years ago

Here is a way to extract id3 info from mp3s using exiftool:

exiftool file.mp3 | egrep "Artist|Album|Title" 

The problem is that this is a perl script and the module it belongs to is not specifically defined by Buildroot, though it may be possible to get it as a custom module. Alternatives to this include id3v2 or eyeD3. id3v2 only requires the idv3lib and is C code but it's output is not line oriented, making it harder to parse (but not impossible). It seems the best fit though it doesn't appear id3lib is included in Buildroot, re: I'd have to build both as a combined third party package.

Note that I simply need a way to create a DB for music, like I do with videos (via VideoLib and VideoFE). The player can be omxplayer, which knows how to play mp3 files.

Actions #9

Updated by Hammel over 5 years ago

There are two things that need to happen.
  • Use ffprobe (part of ffmpeg) to extract metadata as JSON:
    ffprobe -show_format -show_streams -print_format json <file> | jq .format.tags > <file>.json
  • Use ffmpeg to extract the cover art for an individual file:
    ffmpeg -i <file> <file>.png
To generate the DB:
  1. Set the root directory for music
  2. Find directories that contain music files.
  3. Create a .musicdb in that directory.
  4. Run ffmpeg to gen cover art to .musicdb/coverart for each file as file.png
  5. Run ffprobe for each file and output to .musicdb/file.json

That's it. No Internet lookups required. We assume your music is already tagged.

Users can search for music by Album or Artist (based on contents of all metadata files).

Now audioFE just scans the root directory for .musicdb/coverart and displays the first image found for each. Selecting an image selects that directory and extracts track names. User can play all or select one. No playlists to start (feature to be added later). Cover art for each track is displayed while playing the music. ESC stops the music playing or exits. omxplayer plays the music files.

This may be easier than I thought. I can add the DB generation to VideoLib pretty easily. Finding directories with music in them might be harder, maybe.

Actions #10

Updated by Hammel over 5 years ago

  • Priority changed from Urgent to Immediate
Actions #11

Updated by Hammel over 5 years ago

  • Target version changed from 0.13.0 to 1.1.0 - Upgrades
Actions #12

Updated by Hammel over 5 years ago

Attached is the Bash script used to generate a database and extract cover art. Turns out it's pretty freakin' easy.

Actions #13

Updated by Hammel over 5 years ago

Oops. Minor update to the script.

Actions #14

Updated by Hammel over 5 years ago

  • % Done changed from 10 to 20

Created new repo under Pibox project on GitLab. Pushed current code base to it. Code can now parse the db files, provides a selection of Album or Artist and shows a carousel of album art for both. Left and Right keys allow moving through the carousel.

Next up is to implement selection handling. In Album db hitting Enter on an album will show the available tracks and provide the playback options. In Artist db hitting enter shows the album carousel but only for the selected artist.

Playback options:
  • Show tracks (possibly sorted by album track number, if available)
  • Up/Down moves through track list.
  • Selecting active track plays it.
  • Tab changes to playback settings:
    • Repeat
    • Random
    • Auto play (play rest of tracks in list)
  • ESC returns to carousel mode.
Actions #15

Updated by Hammel over 5 years ago

  • % Done changed from 20 to 70

App is written and works fine on a build host (my laptop). It presents a carousel of artists and albums and a list of tracks to play that can be selected using up/down keys and ENTER to play (TAB changes mode from PLAY to STOP). It's possible to start playing a track, then select and play another one (even from another album) without first stopping the one that's playing. But to stop the playing track you either exit the app or change to STOP mode and hit ENTER again. Kinda cool that this is all written in Cairo and Pango.

There is one bug: Need to reset track index when leaving track mode so that choosing another album will start at the first track entry.

The test on the build host used vlc to play audio. Support for changing audio levels up/down should be added since that can be done by sending keys using a FIFO.

Still need to test this on the RPi. I need to create a USB stick with music that the app can browse and play.

Actions #16

Updated by Hammel over 5 years ago

Preparing test on RPi, I constructed my music databases (two of them) on a USB stick and tested on my desktop (bigger than my laptop). It exposed some bugs in how I find the files. Those were fixed and the changes pushed.

On the RPi the app comes up but fails to start because it can't find the default album.png image. This is in data/album.png in the source tree and appears to be hard coded in the source - I thought I made that configurable with the -T option but must have missed something. Anyway, on the RPi that file can't be found because it's actually in /usr/share/musicfe.

Once I fix that I think the app will start properly. Then I can see if it plays music and, probably more importantly, how responsive it is.

Actions #17

Updated by Hammel over 5 years ago

  • % Done changed from 70 to 80

Fixed that bug, plus a couple others I uncovered while testing on real hardware. All were pretty minor and easy to track down.

App works fine on hardware. It's a little sluggish on an RPi 2. Strange thing: I accidentally built for RPi1 (Pi Zero) and the binary worked fine for an RPi1, even with a different toolchain. Not much performance difference when compiled with the RPi2 toolchain. Both worked fine.

Haven't tested on RPi3 yet.

Still need to add new app to meta build. After I do that (and probably test on a RPi3, just for performance differences) then I'm done with this issue.

Actions #18

Updated by Hammel over 5 years ago

  • % Done changed from 80 to 90

Metabuild is updated.

Last thing is to do is test on RPI3 to see if performance is better.

Actions #19

Updated by Hammel over 5 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

Performance is about the same. At least it's not notably better or worse. Good enough for now.

All changes pushed. Closing issue.


Also available in: Atom PDF