Skip to content

feat: stream music from StreamingAssets, played by the page on Web - #145

Merged
h0lybyte merged 1 commit into
mainfrom
feat/web-music
Nov 14, 2026
Merged

h0lybyte merged 1 commit into
mainfrom
feat/web-music

Conversation

@h0lybyte

Copy link
Copy Markdown
Owner

Moves the title music out of the Web build's .data download and the wasm heap.

  • Tracks are plain files under StreamingAssets/Music/, served next to the build.
  • MusicState (proto/luckynumbers/v1/music.proto, ln.web) holds the track, volume and fade time. Core IMusic (MusicPresenter) sets it, and it lives in the root scope, so the music keeps going (and fading) across scene changes.
  • Web: web/src/music.tsx streams the file into an <audio> element and through a Web Audio gain node, so fades work on iOS too, which ignores audio.volume. Playback starts on the first click, key or touch.
  • Editor and desktop: MusicPresenter loads the same file with UnityWebRequestMultimedia into an AudioSource on a DontDestroyOnLoad object. That object carries the app's one AudioListener, since no scene has one.
  • Title plays title.txtpb music (track, volume 0.6, 2 s fade-in) and fades it out over the Play push. This replaces the Title-scene TitleMusic from feat: title music (Break Beat Jazz Fusion) #144.

Web .data: 8.4 MB → 5.6 MB.

ln.py check: 0 errors. tests: 77/77. tsc: clean. build-web: OK. Served mp3 resolves at StreamingAssets/Music/BreakBeatJazzFusion.mp3 (audio/mpeg). Not listened to in a browser yet.

Music no longer rides in the Web build's .data download or the wasm
heap. Tracks are plain files under StreamingAssets; MusicState (ln.web)
says which track, how loud and how fast to fade. On the Web build the
overlay (web/src/music.tsx) streams the file through an <audio> element
into a gain node (fades work on iOS, which ignores audio.volume) and
starts on the first gesture. In the editor and on desktop,
Core/MusicPresenter loads the same file into an AudioSource on a
DontDestroyOnLoad object that also carries the app's AudioListener.

Title plays content/title.txtpb's music and fades it out over the Play
push; the fade now carries on across the scene change. Replaces the
Title-scene TitleMusic component. Web .data: 8.4 MB -> 5.6 MB.
@h0lybyte
h0lybyte merged commit 4328fd8 into main Nov 14, 2026
@h0lybyte
h0lybyte deleted the feat/web-music branch November 14, 2026 00:54
@h0lybyte h0lybyte mentioned this pull request Nov 14, 2026
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