{"by":"switz","descendants":11,"id":47222271,"kids":[47223149,47223084,47229742,47224672,47223406,47230739,47230093],"score":35,"text":"Hey HN,<p>I just released v4 of my gapless playback library that I first built in 2017 for <a href=\"https:&#x2F;&#x2F;relisten.net\" rel=\"nofollow\">https:&#x2F;&#x2F;relisten.net</a>. We stream concert recordings, where gapless playback is paramount.<p>It&#x27;s built from scratch, backed by a rigid state machine (the sole dependency is xstate) and is already running in production over at Relisten.<p>The way it works is by preloading future tracks as raw buffers and scheduling them via the web audio API. It seamlessly transitions between HTML5 and web audio. We&#x27;ve used this technique for the last 9 years and it works fairly well. Occasionally it will blip slightly from HTML5-&gt;web audio, but there&#x27;s not much to be done to avoid that (just when to do it - lotta nuance here). Once you get on web audio, everything should be clean.<p>Unfortunately web audio support still lacks on mobile, in which case you can just disable web audio and it&#x27;ll fallback to full HTML5 playback (sans gapless). But if you drive a largely desktop experience, this is fine. On mobile, most people use our native app.<p>You can view a demo of the project at <a href=\"https:&#x2F;&#x2F;gapless.saewitz.com\" rel=\"nofollow\">https:&#x2F;&#x2F;gapless.saewitz.com</a> - just click on &quot;Scarlet Begonias&quot;, seek halfway in the track (as it won&#x27;t preload until &gt;15s) and wait for &quot;decoding&quot; on &quot;Fire on the Mountain&quot; to switch to &quot;ready&quot;. Then tap &quot;skip to -2s and hear the buttery smooth segue.","time":1772477317,"title":"Show HN: Gapless.js – gapless web audio playback","type":"story","url":"https://github.com/RelistenNet/gapless.js"}