Brian Hung
Projects
Cadence
If Linear made a music player.
Loading the library
addAlbum
addArtist
album.json
public/albums/<name>/
<name>.json
public/artists/
importAlbum
fetch, resolve file urls
importArtist
fetch, resolve photo url
MusicStore
Maps of tracks, albums, artists
ids are uuid v5 of the names
Album, artist pages
look up ids in the Maps
SearchView
matches title, artist, album
PlayerStore
getCollectionTracks
Playing a track
src, play()
ended
playTrack(next)
Controls, Queue
and track lists
Media Session
OS media keys
PlayerStore
playTrack, togglePlayPause
<audio> element
load(), then play()
Audio events
set currentTime, isPlaying
getNextTrackIndex
shuffle, repeat, or i + 1
The current track, play state and position also show in the system's media controls.