npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

media-preview-hls-iframe

v0.1.0-beta.0

Published

Media Chrome <slot="preview"> add-on that renders hls.js I-frame trick-play previews on time-range hover.

Readme

<media-preview-hls-iframe>

A Media Chrome preview-slot add-on that renders hls.js I-frame trick-play previews on <media-time-range> hover.

Install

npm install media-preview-hls-iframe

Usage

Drop it into Media Chrome's <media-time-range> preview slot. Pair it with <hls-video>:

<script type="module">
  import 'hls-video-element';
  import 'media-chrome';
  import 'media-preview-hls-iframe';
</script>

<media-controller>
  <hls-video slot="media" src="…/master.m3u8" playsinline></hls-video>
  <media-control-bar>
    <media-play-button></media-play-button>
    <media-time-range>
      <media-preview-hls-iframe slot="preview"></media-preview-hls-iframe>
    </media-time-range>
  </media-control-bar>
</media-controller>

Requirements

| | | |---|---| | hls.js (consumer-installed) | Version with the I-frame trick-play API: hls.iframeVariants + hls.createIFramePlayer() + hlsIframesOnly.loadMediaAt(). Currently this lives in video-dev/hls.js#7757 on master; not yet in a published release. Once released, any version that exposes those methods works. | | media-chrome (consumer-installed) | The component slots into <media-time-range> and reads its mediapreviewtime attribute. | | Host video element | An <hls-video> (or anything that exposes its hls.js instance as .api) inside the same <media-controller>, or addressed by for="<id>". | | Stream content | Must publish #EXT-X-I-FRAME-STREAM-INF variants in the master playlist (and #EXT-X-I-FRAMES-ONLY in each I-frame variant playlist). If absent, no preview is created and the popup stays empty. | | Browser | Any browser with MSE + ES2022 (private class fields). All evergreen browsers. |

API

<media-preview-hls-iframe>

Attributes

  • for (optional) — id of the host element to bind to. Defaults to the <hls-video> inside the nearest <media-controller> ancestor.

Properties

  • player (read-only) — the currently wired I-frame player, or null. Provided for inspection; the component owns its lifecycle.

Events

  • iframe-player-readyCustomEvent<{ player }> fired each time a new I-frame player is wired up (initial mount + each stream switch). Fired before attachMedia, so listeners can subscribe to early events like MEDIA_ATTACHING.
  • frame-renderedCustomEvent<{ currentTime }> fired each time a new frame is composited. Useful for observability/logging.

Internal render target — Created in shadow DOM with aria-hidden="true" and pointer-events: none. When the manifest exposes an MJPG-coded I-frame variant (image codec on iframeVariants), the component uses hls.createImageIFramePlayer() and renders into an <img>; otherwise it uses hls.createIFramePlayer() and renders into a <video muted playsinline tabindex="-1">. The host element gets a data-renderer="image" attribute while the image path is active.

CSS

The component reads a few Media Chrome CSS custom properties so it sizes itself consistently with the default <media-preview-thumbnail>:

  • --media-preview-thumbnail-max-width (default 240px) — the host width

Aspect ratio is locked at 16:9 internally. Override host CSS to customize:

media-preview-hls-iframe {
  aspect-ratio: 4 / 3;
  width: 320px;
}

VTT thumbnail fallback

This component does not ship a VTT thumbnail fallback. If you want classic sprite thumbnails when no I-frame variants exist, slot a <media-preview-thumbnail> alongside it inside <media-time-range> (and provide a <track kind="metadata" label="thumbnails"> on your media element). Slotting any element into slot="preview" replaces Media Chrome's default thumbnail behavior, so you have to opt in to both explicitly.

Demo

The demo/ directory has two pages:

  • index.html — minimal end-to-end example: one <hls-video> + one <media-controller> + the component.
  • advanced.html — preset URL picker, hls.iframeVariants readout, event log, custom rendition menu with codec.

Local development

npm install
npm run dev        # demo dev server at http://localhost:5173
npm test           # unit tests (vitest)
npm run test:e2e   # end-to-end tests (playwright)
npm run build      # publishable ESM artifact in dist/

The demo (demo/index.html and demo/advanced.html) is intentionally wired to fetch the published media-preview-hls-iframe from jsDelivr via its importmap, so it reflects what consumers actually see. Vite is configured to externalize the package — local changes to src/ won't appear in the demo until they're published. For in-progress component work, drive the component through the unit / e2e tests rather than the demo.

A single vite.config.js handles both jobs — the library build (vite build --mode librarydist/) and the demo build (vite builddist-demo/).

The demo pins hls.js to @canary (package.json) so it tracks the bleeding-edge build that contains the unreleased I-frame trick-play API (video-dev/hls.js#7757). Once that API ships in a stable release, the pin can be relaxed to a normal version range.

To preview what publishing produces:

npm pack --dry-run

License

MIT © PBS