Disclosure: an AI agent wrote this recap from the project's source code and observed release checks. The implementation details and measurements below come from that work.
Hushbell has a browser timer with two endings. A meditation can end with a singing bowl. A sleep track fades to silence. Neither ending should require a JavaScript callback to run at the deadline. On iOS, screen lock and other audio interruptions make that dependency especially fragile.
The implementation puts the ending in the media file and derives the UI countdown from the media clock.
sound bed + gain envelope → AAC in M4A → HTTP byte ranges → native audio player ↓ audio.currentTime ↓ displayed timer One long asset per sleep sound
A 60-minute recording covers four timer choices. The player starts at a position measured from the end, so every choice reaches the same final fade.
| Timer | Starting position |
|---|---|
| 15 min | 45:00 |
| 30 min | 30:00 |
| 45 min | 15:00 |
| 60 min | 00:00 |
The last minute uses a logarithmic gain curve with an extra taper in decibels. A short cosine ramp joins the tail to zero before encoding. The one-minute demo uses a separate recording with a 15-second fade. Neither sleep asset adds an ending chime. FFmpeg writes the M4A with +faststart so the browser can read the container metadata early.
This trades file size and a small offline build pipeline for a simpler playback path. A single recording also means all four starting offsets share the exact same ending.
Start playback in the gesture
The click handler calls play() on a real <audio> element. Once media metadata is available, the player applies the selected offset. The timer derives its remaining time from the duration and currentTime, and pause and resume use the same element and position.
Where the browser exposes Audio Session, the player asks for the playback type. Media Session supplies metadata and the play/pause actions the browser can expose to the OS.
if ("audioSession" in navigator) { navigator.audioSession.type = "playback"; } The baked fade removes the need for the page to wake up and change volume at the deadline. Audio Session expresses playback intent on supporting browsers. On-device Safari testing is still needed to characterize lock-screen behavior and interruptions.
Check byte ranges before debugging the seek
If the player starts at 45:00, downloading the previous 45 minutes is unnecessary. The media origin needs to honor byte ranges. Here is a request against one of the deployed long tracks.
curl -sSI -H 'Range: bytes=0-1023' \ https://audio.hushbell.app/audio/sleep/gentle-rain-60m.m4a The observed response was 206 Partial Content, with Content-Range: bytes 0-1023/30621136, Accept-Ranges: bytes, and Content-Type: audio/mp4. All 86 release assets responded with partial-content headers. Their stored sizes and object ETags matched the source files.
The browser check matters separately. A byte-range response alone can't show that the player uses it correctly. The seek behavior can be reproduced on the deployed sleep player by choosing 15 minutes. The hosted Chromium tests checked that a 15-minute sleep session advances from above 2,700 seconds, pause and resume retain position, and the demo can extend onto the long track. Separate checks started meditation, rain, pink noise, and a bowl audition from the CDN and observed each native media clock advance.