Skip to content

Add updateTrack instance method - #1381

Open
captbaritone wants to merge 2 commits into
masterfrom
update-track
Open

captbaritone wants to merge 2 commits into
masterfrom
update-track

Conversation

@captbaritone

@captbaritone captbaritone commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

There's currently no way to change a loaded track's name or metadata, short of replacing the whole playlist (which reloads the audio). The agentcloud requirements doc lists this as a nice-to-have ("Allow updating a loaded track's defaultName or metaData") without stating a use case. The likely one is an embedder whose track name changes after loading, e.g. a renamed file.

This adds:

webamp.updateTrack(index, { defaultName?: string, metaData?: { artist, title, album?, albumArtUrl? } });
  • Track lookup: index is the track's position in the playlist, the same order getPlaylistTracks() returns, and is resolved to the internal track id. An out-of-range index throws.
  • defaultName: set with a new SET_TRACK_DEFAULT_NAME action.
  • metaData: reuses the existing SET_MEDIA_TAGS action, which keeps the track's kbps/kHz/channels. It replaces any metadata the track already has, including metadata read from the file's tags. Note that the playlist shows "artist - title" in preference to defaultName when a track has metadata.

The update shape is Pick<Track, "defaultName" | "metaData">, so it matches the Track objects embedders already pass in. Documented in the instance methods docs.

Unrelated, but noticed while here: setCurrentTrack(index) passes index to playTrack, which expects a track id. Since ids are generated unique ids rather than positions, that looks like a bug. I've left it alone in this PR.

Testing

  • New updateTrack.test.ts (with a fake media class via __customMediaClass) checks that updating defaultName or metaData only affects the targeted track, and that a missing index throws.
  • tsc, eslint, prettier --check and vitest run pass locally.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Size Change: +257 B (+0.05%)

Total Size: 491 kB

📦 View Changed
Filename Size Change
packages/webamp/built/webamp.bundle.min.js 298 kB +125 B (+0.04%)
packages/webamp/built/webamp.lazy-bundle.min.js 192 kB +132 B (+0.07%)

compressed-size-action

@netlify

netlify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tourmaline-kringle-c98715 ready!

Name Link
🔨 Latest commit 23b9c98
🔍 Latest deploy log https://app.netlify.com/projects/tourmaline-kringle-c98715/deploys/6ad10b87df6d766a49dd55de
😎 Deploy Preview https://deploy-preview-1381--tourmaline-kringle-c98715.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@captbaritone
captbaritone force-pushed the update-track branch 3 times, most recently from 2fe5ff2 to 5852b59 Compare October 15, 2026 17:00
Allow embedders to rename a track, or replace its metadata, without
reloading it. defaultName is set with a new SET_TRACK_DEFAULT_NAME action;
metaData reuses SET_MEDIA_TAGS, which preserves the track's kbps/kHz/channels.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant