# xgplayer **Repository Path**: cucygh/xgplayer ## Basic Information - **Project Name**: xgplayer - **Description**: 西瓜播放器是一个HTML5播放器类库,它本着一切都是组件化的原则设计了独立可拆卸的 UI 组件。更重要的是它不只是在 UI 层有灵活的表现,在功能上也做了大胆的尝试:摆脱视频加载、缓冲、格式支持对 video 的依赖。尤其是在 mp4 点播上做了较大的努力,让本不支持流式播放的 mp4 能做到分段加载,这就意味着可以做到清晰度无缝切换、加载控制、节省视频流量。同时,它也集成了对 flv、hls、dash 的点播和直播支持。 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 164 - **Forks**: 51 - **Created**: 2018-08-22 - **Last Updated**: 2025-08-21 ## Categories & Tags **Categories**: multimedia **Tags**: None ## README
npm license commitizen

English | [简体中文](README.zh-CN.md) ### Introduction xgplayer is a web video and audio player library, designed with separate, detachable UI components. Since everything is componentized. the UI layer is very flexable. xgplayer is bold in its functionality: it gets rid of video loading, buffering, and format support for video dependence. For mp4 that does not support streaming, you can use staged loading. This means load control, seamless switching without artifacts, and video bandwidth savings. It also integrates on-demand and live support for FLV, HLS, and dash. For more details, please read the [Documentation](http://h5player.bytedance.com/en/). ### Start 1. Install ``` $ npm install xgplayer ``` 2. Usage Step 1: ```html
``` Step 2: ```js import Player from 'xgplayer'; const player = new Player({ id: 'vs', url: 'https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/byted-player-videos/1.0.0/xgplayer-demo.mp4' }) ``` This is the easiest way to configure the video player. For more advanced content, see the plug-in section or documentation. [more config](http://h5player.bytedance.com/en/config/) ### Plugins 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](http://h5player.bytedance.com/en/plugins/) The following is how to use a self-starting plug-in: ```js import Player from 'xgplayer'; import 'xgplayer-mp4'; const player = new Player({ id: 'video', url: '//abc.com/test.mp4' }) ``` 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](https://www.w3.org/TR/media-source/). [details](http://h5player.bytedance.com/en/plugins/#xgplayer-mp4) ### Dev For debugging, we provide example video files in github. You can clone the whole git repository, which includes both code and example videos with 'git clone --recurse-submodules -j8'. With 'git clone' you will pull only xgplayer code and its plugins. ``` $ git clone --recurse-submodules -j8 git@github.com:bytedance/xgplayer.git # OR git clone git@github.com:bytedance/xgplayer.git $ cd xgplayer $ npm install $ npm run dev ``` Then visit [http://localhost:9090/examples/index.html](http://localhost:9090/examples/index.html) ### Agreement 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](http://opensource.org/licenses/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. ### Join Us We welcome anyone with an interest in web media technology to join! Please contact us at yinguohui@bytedance.com