一个很好看的弹幕视频播放器。
Demo
屏幕截图
$ npm install dplayer --save
HTML
<link rel=" sheet" href="DPlayer.min.css"> <!-- ... --> <div id="player1" class="dplayer"></div> <!-- ... --> <script src="DPlayer.min.js"></script>
JS
var dp = new DPlayer(option); dp.init();
Options
var option = { element: document.getElementById('player1'), // Optional, player element autoplay: false, // Optional, autoplay video, not supported by mobile browsers theme: '#FADFA3', // Optional, theme color, default: #b7daff loop: true, // Optional, loop play music, default: true video: { // Required, video info url: '若能绽放光芒.mp4', // Required, video url pic: '若能绽放光芒.png' // Optional, music picture }, danmaku: { // Optional, showing danmaku id: '9E2E3368B56CDBB4', // Required, danmaku id, MUST BE UNIQUE, CAN NOT USE THESE IN YOUR NEW PLAYER: `https://dplayer.daoapp.io/list` api: 'https://dplayer.daoapp.io/', // Required, danmaku api token: 'tokendemo', // Optional, danmaku token for api maximum: 1000 // Optional, maximum quantity of danmaku } }
API
dp.init()
dp.play()
dp.pause()