Skip to content

Add setTracks instance method - #1380

Merged
captbaritone merged 2 commits into
masterfrom
set-tracks-without-playing
Oct 15, 2026
Merged

captbaritone merged 2 commits into
masterfrom
set-tracks-without-playing

Conversation

@captbaritone

Copy link
Copy Markdown
Owner

setTracksToPlay(tracks) replaces the playlist but always starts playing (LOAD_STYLE.PLAY). An embedder who wants to swap the source without autoplaying, e.g. when the user selects a different file in a list, has to dispose() and create a new Webamp instance.

This adds:

webamp.setTracks(tracks);

It replaces the playlist and stops any current playback. The first track is loaded the same way initialTracks are (LOAD_STYLE.BUFFER), so its name and duration show up and it's ready to play, but it doesn't start.

I went with a separate method rather than an options argument on setTracksToPlay ({ play: false }), because "set tracks to play, but don't play" reads oddly.

Documented in the instance methods docs.

Testing

  • New setTracks.test.ts uses a fake media class via __customMediaClass. It checks that the playlist is replaced, the first track is loaded with autoPlay: false, and play() isn't called.
  • tsc, eslint, prettier --check and vitest run pass locally.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 490 kB

ℹ️ View Unchanged
Filename Size
packages/webamp/built/webamp.bundle.min.js 298 kB
packages/webamp/built/webamp.lazy-bundle.min.js 192 kB

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 fb74c51
🔍 Latest deploy log https://app.netlify.com/projects/tourmaline-kringle-c98715/deploys/6ad106b0b183490572c05420
😎 Deploy Preview https://deploy-preview-1380--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 set-tracks-without-playing branch 2 times, most recently from 462136f to 7c4bf87 Compare October 15, 2026 16:42
setTracksToPlay always starts playing the first track, so embedders who want
to swap the source without autoplaying had to dispose() and create a new
instance. setTracks replaces the playlist, stops any current playback, and
loads the first track (like initialTracks) without playing it.
@captbaritone
captbaritone force-pushed the set-tracks-without-playing branch from 7c4bf87 to fb74c51 Compare October 15, 2026 17:00
@captbaritone
captbaritone merged commit c85e44c into master Oct 15, 2026
2 of 4 checks passed
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