Modern browsers already had a vivid player for video

Overview

msc-ez-video

Published on webcomponents.org DeepScan grade

Modern browsers already had a vivid player for . However, web developers and designers still want to custom their own style player for different situations.

Sounds like web component will do a lot favor for this purpose. With support, customize control panel will become a piece of cake. adopts CSS custom properties, developers could style them as they want.

That's take a look what can do in different combination ?

(There will be only sound and picture in picture functions display when controls not set.)

<msc-ez-video />

Features

  • Tap to toggle play / pause.
  • Double click to turn on / off fullscreen.
  • Full function control panel will only display in fullscreen mode unless attribute - controls set.
  • Picture in picture support once browser enable.
  • Developers could customize control panel's appearance with CSS custom properties.

Basic Usage

is a web component. All we need to do is put the required script into your HTML document. Then follow 's html structure and everything will be all set.

  • Required Script
">
<script 
  type="module"
  src="https://your-domain/wc-msc-ez-video.js"
script>
  • Structure

Put into HTML document. It will have different functions and looks with attribute mutation.

">
<msc-ez-video
  src="your-video-path.mp4"
  poster="your-video-thumbnail-path.jpg"
  width="16"
  height="9"
  muted
  autoplay
  loop
  controls
  title="your video title"
  artist="your video artist"
>msc-ez-video>

Or

{ "src": "your-video-path.mp4", "poster": "your-video-thumbnail-path.jpg", "width": 16, "height": 9, "muted": true, "autoplay": true, "loop": true, "controls": true, "title": "your video title", "artist": "your video artist" } ">
<msc-ez-video>
  <script type="application/json">
    {
      "src": "your-video-path.mp4",
      "poster": "your-video-thumbnail-path.jpg",
      "width": 16,
      "height": 9,
      "muted": true,
      "autoplay": true,
      "loop": true,
      "controls": true,
      "title": "your video title",
      "artist": "your video artist"
    }
  script>
msc-ez-video>

Otherwise, developers could also choose remoteconfig to fetch config for .

">
<msc-ez-video
  remoteconfig="https://617751a89c328300175f58b7.mockapi.io/api/v1/ezVideo"
  ...
>msc-ez-video>

JavaScript Instantiation

could also use JavaScript to create DOM element. Here comes some examples.

import { MscEzVideo } from 'https://your-domain/wc-msc-ez-video.js'; //use DOM api const nodeA = document.createElement('msc-ez-video'); document.body.appendChild(nodeA); nodeA.src = 'your-video-path.mp4'; nodeA.poster = 'your-video-thumbnail-path.jpg'; // new instance with Class const nodeB = new MscEzVideo(); document.body.appendChild(nodeB); nodeB.src = 'your-video-path.mp4'; nodeB.poster = 'your-video-thumbnail-path.jpg'; // new instance with Class & default config const config = { src: 'your-video-path.mp4', poster: 'your-video-thumbnail-path.jpg', ... }; const nodeC = new MscEzVideo(config); document.body.appendChild(nodeC); ">
<script type="module">
import { MscEzVideo } from 'https://your-domain/wc-msc-ez-video.js';

//use DOM api
const nodeA = document.createElement('msc-ez-video');
document.body.appendChild(nodeA);
nodeA.src = 'your-video-path.mp4';
nodeA.poster = 'your-video-thumbnail-path.jpg';

// new instance with Class
const nodeB = new MscEzVideo();
document.body.appendChild(nodeB);
nodeB.src = 'your-video-path.mp4';
nodeB.poster = 'your-video-thumbnail-path.jpg';

// new instance with Class & default config
const config = {
  src: 'your-video-path.mp4',
  poster: 'your-video-thumbnail-path.jpg',
  ...
};
const nodeC = new MscEzVideo(config);
document.body.appendChild(nodeC);
script>

Style Customization

uses CSS variables to hook control panel's theme. That means developer could easy change it into the looks you like.

<style>
msc-ez-video {
  /* slider thumb */
  --slider-thumb-with: 14px;
  --slider-thumb-color: rgba(255,0,0,1);

  /* indicator */
  --indicator-background: rgba(255,255,255,.2);
  --indicator-buffer-start: rgba(255,255,255,.4);
  --indicator-buffer-end: rgba(255,255,255,.4);
  --indicator-duration-start: rgba(255,0,0,1);
  --indicator-duration-end: rgba(255,0,0,1);

  /* time information */  
  --time-text-size: 16px;
  --time-text-color: #fff;

  /* warning information */  
  --warning-font-size: 16px;
  --warning-color: #fff;
  --warning-text: 'Some errors occured. Please try later.';

  /* function button */
  --action-height: 36px;
  --action-icon-size: auto 65%;
  --ico-play: url(ico-play.svg);
  --ico-pause: url(ico-pause.svg);
  --ico-mute: url(ico-mute.svg);
  --ico-unmute: url(ico-unmute.svg);
  --ico-fullscreen: url(ico-fullscreen.svg);
  --ico-fullscreen-exit: url(ico-fullscreen-exit.svg);
  --ico-pip: url(ico-pip.svg);
  --ico-replay: url(ico-replay.svg);
  --ico-warning: url(ico-warning.svg);
  --ico-forward-5: url(ico-forward-5.svg);
  --ico-forward-10: url(ico-forward-10.svg);
  --ico-backward-5: url(ico-backward-5.svg);
  --ico-backward-10: url(ico-backward-10.svg);
  --ico-speed-up-rate: url(ico-speed-up-rate.svg);
  --ico-speed-down-rate: url(ico-speed-down-rate.svg);

  /* reaction */
  --reaction-width: 52px;
  --reaction-bgc-start: rgba(0,0,0,.4);
  --reaction-bgc-end: rgba(0,0,0,.4);

  /* tip */
  --tip-font-size: 12px;
  --tip-line-height: 1.8;
  --tip-color: #fff;
  --tip-background: rgba(0,0,0,.6);
  --tip-play: 'Play';
  --tip-pause: 'Pause';
  --tip-unmute: 'Unmute';
  --tip-mute: 'Mute';
  --tip-fullscreen: 'Full screen';
  --tip-fullscreen-exit: 'Exit full screen';
  --tip-PiP: 'Picture in Picture';

  /* playbackRate */
  --playbackrate-font-size: 18px;
  --playbackrate-line-height: 2;
  --playbackrate-color: #fff;
  --playbackrate-background: rgba(0,0,0,.6);
}
style>

Attributes

supports some attributes to let it become more convenience & useful.

  • src

Set 's video source.

">
<msc-ez-video
  src="your-video-path.mp4"
  ...
>msc-ez-video>
  • poster

Set 's poster.

">
<msc-ez-video
  poster="your-video-thumbnail-path.mp4"
  ...
>msc-ez-video>
  • width

Set 's width ratio. Default is 16.

">
<msc-ez-video
  width="16"
  ...
>msc-ez-video>
  • height

Set 's height ratio. Default is 9.

">
<msc-ez-video
  height="9"
  ...
>msc-ez-video>
  • title

Set 's title. Default is "unknown title".

">
<msc-ez-video
  tile="your-video-title"
  ...
>msc-ez-video>
  • artist

Set 's artist information. Default is "unknown artist".

">
<msc-ez-video
  artist="your-video-artist"
  ...
>msc-ez-video>
  • crossorigin

Set 's crossorigin. Default is "anonymous".

">
<msc-ez-video
  crossorigin="use-credentials"
  ...
>msc-ez-video>
  • muted

Set mute active or not. Default is false. Note: If developers like to implement autoplay, muted must set in mobile.

<msc-ez-video
  muted
  ...
>msc-ez-video>
  • autoplay

Set autoplay active or not. Default is false. Note: If developers like to implement autoplay, muted must set in mobile.

<msc-ez-video
  autoplay
  muted // must set to active autoplay
  ...
>msc-ez-video>
  • loop

Set > loop active or not. Default is false. There will be a replay sign appeared when video fininshed play once loop doesn't set.

<msc-ez-video
  loop
  ...
>msc-ez-video>
  • controls

Full function contrl panel will only display in fullscreen mode unless controls set. Default is false.

<msc-ez-video
  controls
  ...
>msc-ez-video>

Keyboard shortcut

also comes with keyboard shortcut. I believe this will make more vivid & more useful.

  • k

Toggle play or pause.

  • space

Toggle play or pause.

  • m

Toggle mute or not.

  • f

Toggle fullscreen or not.

  • i

Toggle into picture in picture or not.

  • esc

Turn off fullscreen mode.

backward 5 seconds.

forward 5 seconds.

  • j

backward 10 seconds.

  • l

forward 10 seconds.

  • <

Decrease playback rate. Minimum is 0.25.

  • >

Increase playback rate. Minimum is 2.

  • 0 ~ 9

jumps to specific timeline. Ex: 7 means to timeline 70%.

Properties

Property Name Type Description
src String Getter / Setter for 's video source.
poster String Getter / Setter for 's poster.
title String Getter / Setter for 's title.
artist String Getter / Setter for 's artist.
width Number Getter / Setter for 's width ratio.
height Number Getter / Setter for 's height ratio.
crossorigin String Getter / Setter for 's s crossorigin. (It might be "anonymous" or "use-credentials").
muted Boolean Getter / Setter for 's mute status.
autoplay Boolean Getter / Setter for 's autoplay status.
loop Boolean Getter / Setter for 's loop status.
controls Boolean Getter / Setter for 's control panel status.
currentTime Number Getter / Setter for 's currentTime (in seconds).
duration Number Getter for 's duration (in seconds).
playbackRate Number Getter / Setter for 's playback rate. Rate should between 0.25 ~ 2.
paused Boolean Getter for 's pause status.
fullscreened Boolean Getter for 's full screen status.
PiPed Boolean Getter for 's picture in picture status.

Mathods

Mathod Signature Description
play Play video.
pause Pause video.
requestFS Switch into full screen mode. Note: this is high-trusted event.
exitFS Switch back to normal mode. Note: this is high-trusted event.
requestPiP Switch into picture in picture mode. Note: this is high-trusted event.
exitPiP Switch back to normal mode. Note: this is high-trusted event.

Events

Event Signature Description
ez-video-play Fired when played.
ez-video-pause Fired when paused.
ez-video-seek Fired when seeked.
ez-video-mutechange Fired when 's mute status changed.
ez-video-fullscreenchange Fired when full screen changed.
ez-video-PiPchange Fired when picture in picutre changed.
ez-video-ratechange Fired when playback rate changed.
ez-video-error Fired when error occured.

Reference

You might also like...

a video player framework aims to bring wonderful experience on browser

a video player framework aims to bring wonderful experience on browser

Chimee English | 中文 Introduction Chimee is a web video player created by the Qiwoo Team. It's based on the web video element. It supports multiple med

Dec 22, 2022

A high-performance, interactive and customizable video player control, built upon Reanimated v2 & GestureHandler v2

A high-performance, interactive and customizable video player control, built upon Reanimated v2 & GestureHandler v2

`JSThread` to `JSThread`, `UIThread` to `UIThread`. React Native Reanimated Expo Player 100% written in Typescript video player component, interaction

Jan 4, 2023

This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library included.

Aim-Player This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library incl

Jun 27, 2021

Video Player

aksVideoPlayer.js Video Player View the Demo on CodePen → Getting Started Compiled and production-ready code can be found in the dist directory. 1. In

Oct 22, 2021

Enables video and audio tags in all major browsers.

HTML5 video made easy All it takes is a single line of code to make HTML5 video and audio tags work in all major browsers. How to enable video and aud

Dec 17, 2022

Secretly record audio and video with chromium based browsers

snoop TCC restricts access to the device camera and microphone to protect user data from unauthorized access. But... If you trusted your browser with

Aug 30, 2022

A Node JS Express/Serverless demo application that creates a slideshow video using the Pexels image library and Shotstack video editing API.

Shotstack Pexels Slideshow Video Demo This project demonstrates how to use the Shotstack cloud video editing API to create a video using an HTML form

Dec 9, 2022

A Chrome extension to help you inspect Mp4 video content and find irregularities in video streams.

A Chrome extension to help you inspect Mp4 video content and find irregularities in video streams.

MP4Inspector A Chrome extension to help you inspect Mp4 video content and find irregularities in video streams. Installation In chrome navigate to chr

Nov 28, 2022

Movie focused HTML5 Player

Movie focused HTML5 Player

Movie focused HTML5 Player

Dec 29, 2022
Owner
Paul
Paul is the lead programmer of the AMP project at Yahoo Taiwan and is always eager for modern web technologies.
Paul
SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.

SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.

ossrs 12 Oct 15, 2022
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Dec 27, 2022
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Jan 8, 2023
Video.js - open source HTML5 & Flash video player

Video.js - HTML5 Video Player Video.js is a web video player built from the ground up for an HTML5 world. It supports HTML5 video and Media Source Ext

Video.js 34.8k Jan 5, 2023
Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player Music player application built with HTML, CSS and vanilla JavaScrip

Karthik Umashankar 1 Feb 10, 2022
An online stem player. Inspired by but not affiliated with YEEZY TECH X KANO Stem Player.

Stem Player Online An online stem player. Inspired by but not affiliated with YEEZY TECH X KANO Stem Player. https://stemplayeronline.com See the proj

Luke Weiler 23 Nov 13, 2022
The HTML5 video player for the web

Flowplayer website | demos | docs For the impatient Download Flowplayer Unzip Drop the folder under your server Minimal setup <!DOCTYPE html> <head>

Flowplayer 1.9k Dec 30, 2022
A web video player built for the HTML5 world using React library.

video-react Video.React is a web video player built from the ground up for an HTML5 world using React library. Installation Install video-react and pe

null 2.4k Jan 6, 2023
Custom full screen video player

Video Player Native video player in html View Demo · Report Bug · Request Feature About The Project This is a custom video player for the web built on

Oscar Castaneda ⬢ 5 Feb 3, 2022
Accessible HTML5 Video Player

Accessible HTML5 Video Player What is it? A lightweight HTML5 video player which includes support for captions and screen reader accessibility. For de

PayPal 2.4k Jan 5, 2023