MissingCore / Music

A Nothing inspired local music player.
GNU Affero General Public License v3.0
163 stars 9 forks source link

feat: View tracks in "Folder" structure #38

Closed cyanChill closed 1 month ago

cyanChill commented 1 month ago

Why

This was something requested by Ghouless on the Nothing Forums to relieve some potential issues with our current setup in regards to organization & searchability and should close #23.

Theoretically, everything in this PR should allow for folder structure and playing a track in some directory in the folder structure should only play the tracks directly in this directory.

When trying to implement the above, I realized that the core logic controlling the app is pretty messy and a bit all over the place. With that in mind, after improving file support in the app, I'll probably work on refactoring the logic and probably rewrite the playing logic, which might fix some of the other issues (ie: #30).

How

Generating the file system tree in the music directory

The overall idea ended up with us design the schema to be a tree data structure essentially with nodes.

For populating the tree, we know that file:///storage/emulated/0/Music/ is where music is stored on the device. We can go check the files in that directory and keep those that are actually directories, along with adding them to the database. We can then recursively repeat the process for each directory down the tree.

I've planned on potentially adding a "Re Scan" feature in the settings page, which would rebuild the file system tree, but that can come later. For now, I currently have some code that would initialize the tree as by default, this data doesn't exist. In addition, we have the tree automatically "regenerate" whenever we detect a new or deleted track.

UI Design

We wanted something that could reuse what we had already on hand, so we opted in for the simple design. This might get changed in the future, but for now, it works.

Test Plan

What we've tested is the following:

  1. We replicated the folder structure in the Music folder (excluded any private folders that start with a .).
  2. When going through the folder feature, we displayed the tracks & subdirectories in a given directory.
  3. When playing a track in a directory in the folder feature, the list of upcoming tracks are all from tracks that are directly in this directory (ie: doesn't include any tracks in the subdirectory).

Checklist