Quick start
Installβ
Install by npm:β
$ npm install artplayer
Install by yarn:β
$ yarn add artplayer
Then load the Artplayer module:
// ES6
import Artplayer from 'artplayer';
// CommonJS
const Artplayer = require('artplayer');
Install by script:β
<!-- locally -->
<script src="path/to/artplayer.js"></script>
<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js"></script>
<!-- unpkg -->
<script src="https://unpkg.com/artplayer/dist/artplayer.js"></script>
Then you can access the constructor via window.ArtPlayer
Useβ
Tip
The size of the player depends on the size of the container, so your container must have a size.
Use in Htmlβ
<!DOCTYPE html>
<html>
<head>
<title>ArtPlayer Demo</title>
<meta charset="UTF-8" />
<style>
.artplayer-app {
width: 400px;
height: 300px;
}
</style>
</head>
<body>
<div class="artplayer-app"></div>
<script src="path/to/artplayer.js"></script>
<script>
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
</script>
</body>
</html>