media-chrome

muxincMIT活跃维护

一套基于 Web Components 的媒体播放器控件,能快速给网站或应用加上外观统一的音视频播放界面,不用自己从头写 UI。

Custom elements (web components) for making audio and video player controls that look great in your website or app.

v4.19.4发布于 2026-10-23 13:18 UTC2,768star +1 / 7 天129fork同步于 2026-11-10 23:44 UTC

怎么上手

由 README 提炼,执行前请确认
<script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome@4/+esm"></script>
硬件要求按 README 说明

README 未说明,纯前端库无特殊硬件要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Web Components 搭自定义音视频播放器控件,HTML 加 CSS 就能改样式

一套基于 Web Components 的媒体播放器控件,能快速给网站或应用加上外观统一的音视频播放界面,不用自己从头写 UI。

核心能力

  • 用 media-* 自定义元素拼装播放控件
  • 纯 HTML 增删控件、纯 CSS 改样式
  • 兼容 React、Angular、Svelte 等框架
  • 可对接 video/audio 及 YouTube、HLS.js 等播放器
  • 提供 React 包装组件避免 Web Components 写法别扭

容易踩的坑

React 中直接用需注意 class 而非 className,建议用官方 React 包装组件;项目方已推荐新项目改用 Video.js,需评估维护方向

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4.19.4
  1. v4.19.4最新正式版2026-10-23 · 2026-10-23 13:18 UTC

    Bug Fixes

    • error-dialog: render error attribute values as text (#1331) (d862932)
    • don't list disabled hotkeys in the keyboard shortcuts dialog (#1312) (9c819e1), closes #1305
    • hide poster on seek for ON_DEMAND streams (#1322) (2e7c52e)
    • i18n: accept partial dictionaries in addTranslation (#1321) (0ddb749), closes #1314

    Performance Improvements

    • tooltip: avoid recalculating tooltip on every attribute change (#1325) (df4ce9a)
  2. v4.19.32026-09-28 · 2026-09-28 15:07 UTC
    查看更新说明

    Bug Fixes

    • (docs) correct broken link to defaultstreamtype on stream-type page (#1298) (d8e337f), closes #1297
    • return '0 seconds' for zero input in formatAsTimePhrase (#1300) (c624760), closes #1299
    • snap media-time-range when seeking back less than 3% of duration (#1315) (803787e), closes #1306 #1307
    • updates mediacurrenttime when a seek starts, before it completes (#1316) (7e8a08f)
  3. v4.19.22026-06-10 · 2026-06-10 19:22 UTC
    查看更新说明

    Bug Fixes

    • treat only remote.state === "connected" as casting (#1296) (155e46d)
  4. v4.19.12026-06-01 · 2026-06-01 15:22 UTC
    查看更新说明

    Bug Fixes

  5. v4.19.02026-04-13 · 2026-04-13 18:46 UTC
    查看更新说明

    Bug Fixes

    Features

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    NPM Version NPM Downloads jsDelivr hits (npm) npm bundle size slack

    [!IMPORTANT] Media Chrome, meet Video.js 👋

    The folks behind Media Chrome, Plyr and Vidstack have joined forces to build the latest version of Video.js: one modern, accessible player with the best of all three. It keeps what made Media Chrome great, like HTML-first media-* elements styled with plain CSS, and adds React components, polished skins, and streaming built in. Starting something new? Give Video.js a try.

    Try Video.js → · Migrate from Media Chrome

    Your media player's dancing suit. :man_dancing:

    Fully customizable media player controls using web components (native custom elements).

    • Compatible with any javascript framework (React, Angular, Svelte, etc.)
    • Compatible with the <video> and <audio> elements and a lot of players (YouTube, HLS.js, and more)
    • Simple HTML to add/remove controls
    • Simple CSS to style the controls

    From Mux, the team behind Video.js. Need video hosting? Check out Mux!

    Documentation

    Visit the official documentation for Media Chrome for the latest up-to-date usage instructions.

    Examples

    See all of the repo examples in action.

    Video Example

    <script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome@4/+esm"></script>
    
    <media-controller>
      <video
        slot="media"
        src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4"
        crossorigin
      >
        <track
          label="thumbnails"
          default
          kind="metadata"
          src="https://image.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/storyboard.vtt"
        />
      </video>
      <media-control-bar>
        <media-play-button></media-play-button>
        <media-mute-button></media-mute-button>
        <media-volume-range></media-volume-range>
        <media-time-range></media-time-range>
        <media-pip-button></media-pip-button>
        <media-fullscreen-button></media-fullscreen-button>
      </media-control-bar>
    </media-controller>
    
    Results (Try the CodePen example)

    Audio Example

    <script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome@4/+esm"></script>
    
    <media-controller audio>
      <audio
        slot="media"
        src="https://stream.mux.com/O4h5z00885HEucNNa1rV02wZapcGp01FXXoJd35AHmGX7g/audio.m4a"
      ></audio>
      <media-control-bar>
        <media-play-button></media-play-button>
        <media-time-display showduration></media-time-display>
        <media-time-range></media-time-range>
        <media-playback-rate-button></media-playback-rate-button>
        <media-mute-button></media-mute-button>
        <media-volume-range></media-volume-range>
      </media-control-bar>
    </media-controller>
    
    Results (Try the CodePen example)

    Use with React

    While you technically can use Media Chrome elements directly with React, it can sometimes be a bit clunky to work with Web Components in React, and some things just don't feel idiomatic to the framework (for example: having to use class= instead of className=, see React's official docs regarding web components for more details). To help with this, we've published some React wrapper components for all of our core Elements. You can read up on using them here.

    Why?

    More often than not web designers and developers just use the default media player controls, even when creating a beautiful custom design theme. It's hard not to.

    • Web browsers have built-in media controls that can't easily be customized and look different in every browser.
    • Social sites like Youtube, Vimeo, and SoundCloud only let you customize small details of the player, like primary button color.
    • Media controls are complex and hard to build from scratch. Open source players like Video.js and JW Player help, but require you to learn proprietary JS APIs, and can be difficult to use with popular Javascript frameworks.

    It should be easier... <media-chrome> is an attempt at solving that.

    Why now?

    Web components. @heff spoke about the potential of web components for video at Demuxed 2015, and again in 2020. They allow us to extend the browser's base HTML functionality, meaning we can now build media player controls as simple HTML tags that:

    • Can be used like any native HTML tag in HTML, Javascript, and CSS (unleash your designer)
    • Are compatible by default with Javascript frameworks (React, Angular, Svelte)
    • Can be used across players when using multiple in the same site, e.g Youtube & <video>. (Could even be used by players as their own built-in controls)

    Core Concepts