Feature #396

Need a music player app

Added by Hammel almost 6 years ago. Updated over 1 year ago.

Status:ClosedStart date:11 Nov 2014
Priority:ImmediateDue date:
Assignee:Hammel% Done:


Category:04 - Applications
Target version:1.1.0 - Upgrades
Severity: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.

genid3db.sh Magnifier - genid3db.sh - Generate a set of JSON files from ID3 data, including cover art and filename. (1.09 KB) Hammel, 31 Jan 2019 16:47

genid3db.sh Magnifier - genid3db.sh (1.09 KB) Hammel, 31 Jan 2019 16:56

Associated revisions

Revision 42676318
Added by Hammel over 1 year ago

RM #396: Initial import of early-stage music player app (or it's early stage framework at least).

Revision b47c9c7e
Added by Hammel over 1 year ago

RM #396: Add script that generates the db from existing mp3 files.

Revision d95e5e1f
Added by Hammel over 1 year ago

RM #396: Add full navigation support for artists and albums with a stub for listing album track titles.

Revision 8da47889
Added by Hammel over 1 year ago

RM #396: Resize all coverart to be uniform.

Revision b8e54424
Added by Hammel over 1 year ago

RM #396: Add default album image to build.

Revision 02ff2438
Added by Hammel over 1 year ago

RM #396: Add support for displaying and highlighting/navigating album tracks.

Revision 0e5b4505
Added by Hammel over 1 year ago

RM #396: Sort album tracks and display them in a monospace font so that the track numbers and
titles are properly aligned.

Revision 4e20e941
Added by Hammel over 1 year ago

RM #396: Disable dbtop setting in default configuration file. Fallback to defaults in code.

Revision 31d3de4d
Added by Hammel over 1 year ago

RM #396: Add getopt to db generator script. Add sections (functions, initialization, main, etc.). Add option to support setting directory to scan.

Revision 3eb75496
Added by Hammel over 1 year ago

RM #396: Add player controls and fix player start to work properly.

Revision f301fe91
Added by Hammel over 1 year ago

RM #396: Add example config that runs vlc instead of omxplayer, which can be used for testing on build host.

Revision b59595d7
Added by Hammel over 1 year ago

RM #396: Fix call to player to pass correct index.

Revision 880a63af
Added by Hammel over 1 year ago

RM #396: Ignore data/musicfe.cfg so we can use it for testing without actually checking it in.

Revision 1c53b487
Added by Hammel over 1 year ago

RM #396: Copy the correct app icon to the opkg.

Revision 42cb8cde
Added by Hammel over 1 year ago

RM #396: Properly handle setting the dbTop and support multiple musiclib directories.

Revision 66c26e19
Added by Hammel over 1 year ago

RM #396: Add support for both GDK_KEY_<arrow> and GDK_KEY_KP_<arrow>. Fix off-by-one malloc that locked up on Pi but not on Intel desktops. Fix use of default image path for album.png if not using -T option.

Revision e4b7f95a
Added by Hammel over 1 year ago

RM #396: Fix mjpeg-stream build to use specific git commit. Add musicfe app to builds. Add new build mode: autokiosk.


#1 Updated by Hammel almost 6 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 #

#2 Updated by Hammel almost 6 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

#3 Updated by Hammel almost 6 years ago

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

#4 Updated by Hammel almost 6 years ago

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

#5 Updated by Hammel almost 6 years ago

  • Target version changed from 1.0 - Atreides to 0.13.0

#6 Updated by Hammel almost 6 years ago

  • Severity changed from 03 - Medium to 02 - High

#7 Updated by Hammel almost 4 years ago

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

#8 Updated by Hammel over 2 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.

#9 Updated by Hammel over 1 year 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.

#10 Updated by Hammel over 1 year ago

  • Priority changed from Urgent to Immediate

#11 Updated by Hammel over 1 year ago

  • Target version changed from 0.13.0 to 1.1.0 - Upgrades

#12 Updated by Hammel over 1 year ago

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

#13 Updated by Hammel over 1 year ago

Oops. Minor update to the script.

#14 Updated by Hammel over 1 year 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.

#15 Updated by Hammel over 1 year 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.

#16 Updated by Hammel over 1 year 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.

#17 Updated by Hammel over 1 year 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.

#18 Updated by Hammel over 1 year 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.

#19 Updated by Hammel over 1 year 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