Go to file
2016-05-19 22:49:13 +08:00
demo style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00
dist style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00
nodejs style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00
src style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00
.gitignore Better api: log; blacklist; bug fixing 2016-05-18 02:23:44 +08:00
.travis.yml init project 2016-05-03 22:11:47 +08:00
gulpfile.js comment; change demo link 2016-05-13 08:43:39 +08:00
package.json style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00
README.md style without danmaku; limit danmaku max length; right button menu; hot key 2016-05-19 22:49:13 +08:00

DPlayer

npm npm devDependency Status npm Travis %e2%9d%a4

Wow, such a lovely HTML5 danmaku video player

Introduction

Notice: This player is still under development.

Demo

Install

$ npm install dplayer --save

Usage

HTML

<link rel="stylesheet" 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
        api: 'https://dplayer.daoapp.io/',                             // Required, danmaku api
        token: 'tokendemo'                                             // Optional, danmaku token for api
    }
}

API

  • dp.init()
  • dp.play()
  • dp.pause()

Event binding

dp.on(event, handler)

event:

  • play: Triggered when DPlayer start play
  • pause: Triggered when DPlayer paused
  • canplay: Triggered when enough data is available that DPlayer can be played
  • playing: Triggered periodically when DPlayer is playing
  • ended: Triggered when DPlayer ended
  • error: Triggered when an error occurs

Work with module bundler

var DPlayer = require('DPlayer');
var dp = new DPlayer({
    // ...
});

Run in development

$ npm install
$ npm run dev

Make a release

$ npm install
$ npm run build

Todo

  • 中英文切换

  • 微博登录

  • 锁定IP规则

  • icon 动画

LICENSE

MIT © DIYgod