# ArtPlayer    > ArtPlayer is a modern HTML5 video player ## Status ⚠️ This project is WIP and not ready for production use yet! ## Demo [Checkout the demo](https://blog.zhw-island.com/ArtPlayer/) ## Introduction ## Install ``` $ npm install --save artplayer ``` ```js import Artplayer from 'artplayer'; import 'artplayer/dist/artplayer.css'; ``` OR umd builds are also available ```html ``` Will expose the global variable to `window.Artplayer`. ## Usage ```html
``` ```js var art = new Artplayer({ container: '.artplayer-app', url: 'path/to/video.mp4' }); ``` ## Ecosystem | Project | Description | | ------------------------------------------------------------------------------------------------------------- | -------------------------- | | [artplayer-plugin-danmu](https://github.com/zhw2590582/ArtPlayer/tree/master/packages/artplayer-plugin-danmu) | Danmu plugin for ArtPlayer | ## Configuration| parameter | description | example | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
Type: string, elementDefault: .artplayerRequired: trueDOM container of the player, you need to initialize a size for the container element |
Demo | ||||||||||||
url |
Type: stringDefault: ''Required: trueVideo source url, Three video file formats are supported: mp4, ogg, webm
|
Demo | ||||||||||||
poster |
Type: stringDefault: ''Video poster image url |
Demo | ||||||||||||
title |
Type: stringDefault: ''Video title, will be shown in screenshot file name and pip mode
|
Demo | ||||||||||||
volume |
Type: numberDefault: 0.7Default volume, player will cache the last volume, which may be overwritten |
Demo | ||||||||||||
autoplay |
Type: booleanDefault: falseWhether to play automatically, sometimes it doesn't necessarily succeed More info: autoplay-policy-changes |
Demo | ||||||||||||
autoSize |
Type: booleanDefault: falseKeep the original video aspect ratio and automatically zoom |
Demo | ||||||||||||
loop |
Type: booleanDefault: falseAutomatic loop playback |
Demo | ||||||||||||
playbackRate |
Type: booleanDefault: falseWhether to show playback rate controller in the contextmenu |
Demo | ||||||||||||
aspectRatio |
Type: booleanDefault: falseWhether to show aspect ratio controller in the contextmenu |
Demo | ||||||||||||
screenshot |
Type: booleanDefault: falseWhether to show screenshot controller in the bottom |
Demo | ||||||||||||
setting |
Type: booleanDefault: falseWhether to show setting controller in the bottom |
Demo | ||||||||||||
pip |
Type: booleanDefault: falseWhether to show pip controller in the bottom |
Demo | ||||||||||||
fullscreen |
Type: booleanDefault: falseWhether to show window fullscreen controller in the bottom |
Demo | ||||||||||||
fullscreenWeb |
Type: booleanDefault: falseWhether to show web page fullscreen controller in the bottom |
Demo | ||||||||||||
hotkey |
Type: booleanDefault: trueWhether to use hotkey
|
Demo | ||||||||||||
mutex |
Type: booleanDefault: truePlayer mutually exclusive, only one player can play at a time |
Demo | ||||||||||||
lang |
Type: stringDefault: navigator.language.toLowerCase()Default display language: en, zh-cn, zh-tw
|
Demo | ||||||||||||
theme |
Type: stringDefault: #f00Default theme color |
Demo | ||||||||||||
subtitle |
Type: objectDefault: {}Custom subtitle
|
Demo | ||||||||||||
thumbnails |
Type: objectDefault: {}Custom thumbnails in the progress bar with lazy load
|
Demo | ||||||||||||
moreVideoAttr |
Type: objectDefault: {'controls': false,'preload': 'auto'}More video Attributes, these properties will be written directly to the video element |
Demo | ||||||||||||
quality |
Type: arrayDefault: []Custom quality, The type of quality is an object
|
Demo | ||||||||||||
highlight |
Type: arrayDefault: []Custom highlight, The type of highlight is an object
|
Demo | ||||||||||||
layers |
Type: arrayDefault: []Custom layer, The type of layer is an object or function
|
Demo | ||||||||||||
contextmenu |
Type: arrayDefault: []Custom contextmenu, The type of layer is an object or function
|
Demo | ||||||||||||
controls |
Type: arrayDefault: []Custom controls, The type of controls is an object
|
Demo |
| property / method | parameter | description | example |
|---|---|---|---|
art.init() |
Initialization instance, in general you don't need it | ||
art.destroy() |
true / false |
Destroy instance, and whether to remove dom | Demo |
art.player.mountUrl() |
Demo | ||
art.player.play() |
Demo | ||
art.player.pause() |
Demo | ||
art.player.toggle() |
Demo | ||
art.player.seek() |
Demo | ||
art.player.volume() |
Demo | ||
art.player.currentTime() |
Demo | ||
art.player.duration() |
Demo | ||
art.player.switch() |
Demo | ||
art.player.playbackRateState() |
Demo | ||
art.player.playbackRate() |
Demo | ||
art.player.playbackRateRemove() |
Demo | ||
art.player.playbackRateReset() |
Demo | ||
art.player.aspectRatioState() |
Demo | ||
art.player.aspectRatio() |
Demo | ||
art.player.aspectRatioRemove() |
Demo | ||
art.player.aspectRatioReset() |
Demo | ||
art.player.screenshot() |
Demo | ||
art.player.fullscreenState() |
Demo | ||
art.player.fullscreenEnabled() |
Demo | ||
art.player.fullscreenExit() |
Demo | ||
art.player.fullscreenToggle() |
Demo | ||
art.player.fullscreenWebState() |
Demo | ||
art.player.fullscreenWebEnabled() |
Demo | ||
art.player.fullscreenWebExit() |
Demo | ||
art.player.fullscreenWebToggle() |
Demo | ||
art.player.pipState() |
Demo | ||
art.player.pipDraggie() |
Demo | ||
art.player.pipEnabled() |
Demo | ||
art.player.pipExit() |
Demo | ||
art.player.pipToggle() |
Demo | ||
art.player.loaded() |
Demo | ||
art.player.played() |
Demo | ||
art.player.autoSizeState() |
Demo | ||
art.player.autoSize() |
Demo | ||
art.player.autoSizeRemove() |
Demo | ||
art.player.flipState() |
Demo | ||
art.player.flip() |
Demo | ||
art.player.flipRemove() |
Demo |
| property / method | parameter | description | example |
|---|---|---|---|
Artplayer.version |
Version Information | ||
Artplayer.config |
Configuration information | ||
Artplayer.utils |
Common utils | ||
Artplayer.DEFAULTS |
Default configuration | ||
Artplayer.use() |
Function to load plugin |