HeadlinesBriefing favicon HeadlinesBriefing.com

gapless.js v4: Web Audio API Library for Seamless Audio Playback

Hacker News •
×

A developer has released v4 of gapless.js, a JavaScript library for seamless audio playback that powers Relisten.net's concert streaming service. The library uses a rigid state machine built with xstate as its sole dependency, handling transitions between HTML5 and Web Audio APIs to eliminate gaps between tracks.

Built from scratch and already running in production, gapless.js preloads future tracks as raw buffers and schedules them via the Web Audio API. The developer notes that while occasional blips can occur during HTML5-to-Web Audio transitions, the technique has proven reliable over nine years of use. The library works best on desktop environments, with mobile users typically using native apps due to limited Web Audio support.

The library features a dead simple API with callbacks for progress tracking, track changes, and error handling. A live demo showcases the gapless functionality by seeking halfway through one track and experiencing the smooth transition to the next. The v4 release represents a complete rewrite from previous versions, introducing ES module support, TrackInfo data objects instead of class instances, and built-in Media Session API integration.