Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

I Upgraded HTML5 by Changing 3 Characters (TMG Media Player)

The native HTML5 <video controls> attribute has barely evolved in a decade. It looks different across Chrome, Safari, and Firefox, is painful to style, and lacks modern features users now expect by default (hover preview

I Upgraded HTML5  by Changing 3 Characters (TMG Media Player)

The native HTML5 <video controls> attribute has barely evolved in a decade. It looks different across Chrome, Safari, and Firefox, is painful to style, and lacks modern features users now expect by default (hover preview thumbnails, chapter segments, auto-miniplayer on scroll, touch/wheel gestures, live caption styling, and unified HLS/DASH playback).

Most custom video player libraries either require heavy bundler setups or lock you into a specific UI framework.

I wanted a player you could drop into any existing HTML page by adding 3 characters:

<script src="https://cdn.jsdelivr.net/npm/tmg-media-player@latest" defer></script>

<!-- Add "tmg" in front of controls: -->
<video tmgcontrols src="movie.mp4"></video>

That is the entire setup. No bundler, no framework lock-in, and native <track> elements (subtitles, captions, chapters) work as-is.

One Unified UI Across Every Media Format

Drop in native MP4, HLS (.m3u8), DASH (.mpd), YouTube, Vimeo, or Audio files, and TMG auto-detects the right tech engine with zero extra configuration.

You also get drag-to-reorder playlists with auto-next countdowns, chapter-segmented timelines, hover preview thumbnails, and an auto-docking miniplayer when the user scrolls past the video.

Modular Settings, Reactive Ambience, and Adaptive Quality

Everything in TMG Media Player is built as an independent plug (32 modular plugs and 11 sub-pins in total):

  • Reactive Ambience Glow: Samples video frames in real time and feathers warm lighting into the surrounding page background.
  • Adaptive HLS & DASH Quality Selection: Exposes live stream bitrates and resolution switching cleanly inside the menu.
  • Live WebVTT Caption Designer: Viewers can customize font, size, color, opacity, background, and edge style on the fly.
  • Touch & Wheel Gestures: Swipe for volume, brightness, and scrubbing, plus YouTube-style 2x long-press fast play.
  • Built-in Voice & AI Copilot: Includes configurable voice commands and an autonomous ReAct agent over the player state tree (supporting Chrome's on-device Built-in AI or any OpenAI-compatible API) with full Undo/Redo.

Under the Hood: State & Intent Architecture (S.I.A.)

In most web media players, UI buttons and plugins directly call video.play() or mutate <video> properties while reacting to messy DOM events. Once you combine gestures, ads, persistence, captions, and multi-tech switching, race conditions quickly spiral out of control.

TMG is powered by sia-reactor, a transactional reactive router that separates every interaction into Intent (requests) and State (confirmed facts):

const { media } = video.tmgPlayer.controller;

// Request a change via Intent (never mutate the video element directly)
media.intent.paused = false;

// Intercept, clamp, or reject intents in the capture/mediator phase
media.set("intent.volume", (val) => Math.min(val, 50));
media.on("intent.paused", (e) => !e.value && !userHasAccess && e.reject(), { capture: true });

// Observe confirmed State in UI or React (via useReactor)
media.watch("state.paused", (paused) => {
  console.log(paused ? "Paused" : "Playing");
});

Because every plug registers cleanly through PlugRegistry and cleans up automatically via AbortSignal, you can disable, swap, or build custom plugs without touching the core engine.

Try It Out

npm install tmg-media-player
import "tmg-media-player";

TMG Media Player is dual-licensed under TMG Fair-Code v1.0 (100% free for personal projects, students, accredited education, non-profits, non-commercial open source, and commercial organizations under $100k annual revenue and cumulative funding), with a 4-year MIT sunset guarantee on every release.

Check out the live demo and drop a star on GitHub if you find it useful. I would love your feedback on the S.I.A. architecture and API design!

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.