May 5, 2019

465 words 3 mins read



A HTML5 video player with a parser that saves traffic

repo name bytedance/xgplayer
repo link
language JavaScript
size (curr.) 97133 kB
stars (curr.) 2309
created 2018-05-16
license MIT License


xgplayer is a web video player library. It has designed a separate, detachable UI component based on the principle that everything is componentized. More importantly, it is not only flexible in the UI layer, but also bold in its functionality: it gets rid of video loading, buffering, and format support for video dependence. Especially on mp4 it can be staged loading for that does not support streaming mp4. This means seamless switching with clarity, load control, and video savings. It also integrates on-demand and live support for FLV, HLS, and dash. Document


  1. Install

    $ npm install xgplayer
  2. Usage

    Step 1:

    <div id="vs"></div>

    Step 2:

    import Player from 'xgplayer';
    const player = new Player({
        id: 'vs',
        url: ''

    This is the easiest way to configure the player, then it runs with video. For more advanced content, see the plug-in section or documentation. more config


xgplayer provides more plugins. Plugins are divided into two categories: one is self-starting, and another inherits the player’s core class named xgplayer. In principle, the officially provided plug-ins are self-starting and the packaged third-party libraries are inherited. Some feature plug-ins themselves can provide a downgrade scenario that suggests a self-start approach, or an inheritance approach if not. The player supports custom plugins for more content viewing plugins

The following is how to use a self-starting plug-in:

import Player from 'xgplayer';
import 'xgplayer-mp4';

const player = new Player({
    id: 'video',
    url: '//'

xgplayer-mp4plugin is self-starting, It loads mp4 video itself, parses mp4 format, implements custom loading, buffering, seamless switching, and so on. it will automatically downgrade devices that do not support MSE. details

Mobile Support

xgplayer supports mobile terminal, but android device brand and system are numerous, there are much compatibility problems, the player provides whitelist mechanism to ensure the perfect operation in mobile terminal. whitelist


For debugging, we provide the example video resource which size is large in github. You can clone the whole git repository which includes codes and example videos with ‘git clone –recurse-submodules -j8’. With ‘git clone’ you will pull only codes of xgplayer and its plugins.

$ git clone --recurse-submodules -j8 # OR git clone
$ cd xgplayer
$ npm install
$ npm run dev

please visit http://localhost:9090/examples/index.html


Welcome to use xgplayer! Please read the following terms carefully. Using xgplayer means that you accept and agree to the terms.

  1. Xgplayer is licensed under the MIT License. You comply with its obligations by default.
  2. By default, you authorize us to place your logo in xgplayer website, which using xgplayer. If you have any problem, please let us know.
comments powered by Disqus