$ show bytedance/xgplayer
xgplayer is a production-grade, plugin-based HTML5 video player library maintained by ByteDance. It provides a core player package (`packages/xgplayer`) with UI controls, event/hook systems, device sniffing, i18n, and a rich plugin registry, plus separate npm packages for streaming protocols including HLS, FLV, DASH, MP4, and MPEG-TS transmuxing. The architecture is a monorepo of coordinated packages: streaming plugins built on shared networking, MSE, buffer, and error utilities; a custom type-level transmuxer that demuxes/remuxes FLV/TS/MP4 into fMP4 for Media Source Extensions; and extension packages for Chromecast/AirPlay, Google IMA ads, subtitles, and music visualization. In production this library plays both VOD and live streams in the browser, handles adaptive bitrate switching, DRM, low-latency manifest polling, and provides full control UI for desktop and mobile.
The LLM identified 6 files worth highlighting for reuse:
A standalone Exp-Golomb bit reader used for parsing H.264/H.265 SPS/PPS and other video codec bitstream syntax. It is self-contained, dependency-free, and can be extracted directly into another codec or media tooling project.
A generic XHR streaming loader with configurable timeouts, retries, progress events, dynamic timeout estimation, and Range request validation. Isolated from player UI and reusable in any browser data-fetching pipeline that needs robust media or binary downloads.
A surgical HTML sanitizer for subtitle text that encodes raw HTML then allowlists safe inline tags, attributes, and URI protocols. It is small, self-contained, and directly reusable in any user-generated-content rendering context where XSS prevention is required.
A comprehensive ISOBMFF box parser and builder supporting ftyp/moov/moof/mdat/sidx and encrypted sample metadata. Although large, the static box-level API is decoupled enough to be extracted for generic MP4 inspection, remuxing, or streaming tooling outside the player.
A Web Audio AnalyserNode wrapper that renders frequency/time-domain data to canvas with multiple visualization modes (bars, waves, lightning, double-line). It is isolated from the music player UI and can be reused as a lightweight audio visualizer component in any browser project.
A utility for extracting and exposing SEI (Supplemental Enhancement Information) user-data payloads from media streams. Self-contained and useful for obtaining in-band metadata such as custom JSON from live encoders without coupling to a full player.