此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/DIYgod/DPlayer.git
一款非常好用的媒体播放器

DIYgod 02cbcf4495 deal danmaku maximum in back-end 9 years ago
demo 02cbcf4495 deal danmaku maximum in back-end 9 years ago
dist 02cbcf4495 deal danmaku maximum in back-end 9 years ago
nodejs 02cbcf4495 deal danmaku maximum in back-end 9 years ago
src 02cbcf4495 deal danmaku maximum in back-end 9 years ago
.gitignore f1a9b8664f Better api: log; blacklist; bug fixing 9 years ago
.travis.yml 6982d58cd7 init project 9 years ago
README.md 02cbcf4495 deal danmaku maximum in back-end 9 years ago
gulpfile.js 2c1d7c149d comment; change demo link 9 years ago
package.json 9b400b0188 1. new parameter: danmaku.maximum 9 years ago

README.md

DPlayer

npm npm devDependency Status npm Travis

Wow, such a lovely HTML5 danmaku video player

Introduction

Demo

Screenshot image

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, 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()

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(option);
dp.init();

Danmaku back-end

Ready-made API:

https://dplayer.daoapp.io/

Build yourself:

Required environment

  • Node.js
  • Mongodb

Run in development

$ npm install
$ npm run dev

Make a release

$ npm install
$ npm run build

Related Projects

Todo

  • [ ] 截图

  • [ ] 记录播放位置 记录透明度

  • [ ] 国际化

  • [ ] 微博登录

  • [ ] 锁定IP规则

  • [ ] icon 动画

  • [ ] 字体

LICENSE

MIT © DIYgod