Skip to content

Play the sound and the music of the game on the play page - #25

Open
beetlebugorg wants to merge 1 commit into
mainfrom
play-sound
Open

beetlebugorg wants to merge 1 commit into
mainfrom
play-sound

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

The game on https://beetlebug.org/lamplighter/play/ had no sound. The game only names its sounds in app(sfx) and its song in app(music); the page must play them, as toys.js does on the toy page of ztk. The play page had no player.

  • docs/site/play/sound.js: a copy of docs/site/toysound.js of ztk (BSD-2-Clause, with its header). It has an effect for each name that the game uses and the two songs lamplighter-title and lamplighter-play.
  • docs/site/play/index.html: in each frame the page reads and clears app(sfx) and reads app(music). Two buttons, Sound and Music, turn each one on. A browser starts audio only after a gesture, so both start off; the choice stays in localStorage, and a saved choice starts at the first tap or key. The sound stops while the tab is hidden.
  • tools/site.tcl copies sound.js.
  • tests/web/sound.mjs: a check in headless Chromium.

Ran: the site build with ztcl beta.8, the game files of the live site, and tests/web/sound.mjs in Chromium: the Sound button makes one AudioContext, jump land starts 2 voices and clears app(sfx), and the title music starts more. Not run: a real speaker, a phone, or Safari.

The game names its sounds in app(sfx) and its song in app(music), and the page must play them. The play page had no player, so the game was silent. The page now reads the two values in each frame and plays them with sound.js, a copy of toysound.js of ztk. Two buttons turn the sound and the music on, as a browser starts audio only after a gesture.

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