Code Monkey home page Code Monkey logo

media-chrome's Introduction

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

Your media player's dancing suit. ๐Ÿ•บ

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 and the creator of Video.js.

Documentation

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

You can find the documentation for v0.x of media-chrome here.

Examples

See all of the repo examples in action.

Video Example

<script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome@3/+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>
Media Chrome Video Player Demo

Audio Example

<script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome@3/+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>
Media Chrome Audio Player Demo

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

media-chrome's People

Contributors

luwes avatar github-actions[bot] avatar heff avatar cjpillsbury avatar gkatsev avatar adamjaggard avatar dylanjha avatar davekiss avatar mmcc avatar littlespex avatar evoactivity avatar wietsehage avatar snyk-bot avatar mashaal avatar mattiasbuelens avatar jorisre avatar jonabc avatar redopop avatar jakubslambor avatar hermanbilous avatar harveyrandall avatar k-g-a avatar derikolsson avatar adtc avatar

media-chrome's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.