Showing preview only (331K chars total). Download the full file or copy to clipboard to get everything.
Repository: DIYgod/DPlayer
Branch: master
Commit: bc43cc0ac247
Files: 73
Total size: 311.8 KB
Directory structure:
gitextract_j1tz1t__/
├── .github/
│ ├── FUNDING.yml
│ └── ISSUE_TEMPLATE.md
├── .gitignore
├── .husky/
│ └── pre-commit
├── .prettierignore
├── .prettierrc
├── .travis.yml
├── LICENSE
├── README.md
├── demo/
│ ├── demo.css
│ ├── demo.js
│ ├── index.html
│ └── modernizr.js
├── docs/
│ ├── .vuepress/
│ │ ├── components/
│ │ │ └── DPlayer.vue
│ │ ├── config.js
│ │ ├── styles/
│ │ │ ├── index.styl
│ │ │ └── palette.styl
│ │ └── theme/
│ │ ├── components/
│ │ │ └── CarbonAds.vue
│ │ ├── index.js
│ │ ├── layouts/
│ │ │ └── Layout.vue
│ │ └── package.json
│ ├── README.md
│ ├── ecosystem.md
│ ├── guide.md
│ ├── package.json
│ ├── support.md
│ └── zh/
│ ├── README.md
│ ├── ecosystem.md
│ ├── guide.md
│ └── support.md
├── package.json
├── src/
│ ├── css/
│ │ ├── balloon.less
│ │ ├── bezel.less
│ │ ├── controller.less
│ │ ├── danmaku.less
│ │ ├── global.less
│ │ ├── index.less
│ │ ├── info-panel.less
│ │ ├── logo.less
│ │ ├── menu.less
│ │ ├── notice.less
│ │ ├── player.less
│ │ ├── subtitle.less
│ │ └── video.less
│ ├── js/
│ │ ├── api.js
│ │ ├── bar.js
│ │ ├── bezel.js
│ │ ├── comment.js
│ │ ├── contextmenu.js
│ │ ├── controller.js
│ │ ├── danmaku.js
│ │ ├── events.js
│ │ ├── fullscreen.js
│ │ ├── hotkey.js
│ │ ├── i18n.js
│ │ ├── icons.js
│ │ ├── index.js
│ │ ├── info-panel.js
│ │ ├── options.js
│ │ ├── player.js
│ │ ├── setting.js
│ │ ├── subtitle.js
│ │ ├── subtitles.js
│ │ ├── template.js
│ │ ├── thumbnails.js
│ │ ├── timer.js
│ │ ├── user.js
│ │ └── utils.js
│ └── template/
│ ├── player.art
│ └── video.art
├── tea.yaml
└── webpack/
├── dev.config.js
└── prod.config.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
patreon: DIYgod
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
中文用户请注意:请尽量用**英文**描述你的 issue,这样能够让尽可能多的人帮到你。
If you want to report a bug, please provide the following information:
- The steps to reproduce.
- A minimal demo of the problem via https://jsfiddle.net or http://codepen.io/pen if possible.
- Which versions of DPlayer, and which browser / OS are affected by this issue?
<!-- Love DPlayer? Please consider supporting our project:
👉 https://github.com/MoePlayer/DPlayer#donate -->
================================================
FILE: .gitignore
================================================
.idea
node_modules
demo2
docs2
npm-debug.log
DPlayer.log*
wxw
.vscode
package-lock.json
docs/.vuepress/dist
================================================
FILE: .husky/pre-commit
================================================
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm exec lint-staged
================================================
FILE: .prettierignore
================================================
dist
demo
================================================
FILE: .prettierrc
================================================
{
"printWidth": 233,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- lts/*
script:
- npm run build
- npm run docs:build
deploy:
provider: pages
skip-cleanup: true
local_dir: docs/.vuepress/dist
github-token: $GITHUB_TOKEN # a token generated on github allowing travis to push code on you repository
keep-history: true
on:
branch: master
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) DIYgod <diy.d.god@gmail.com> (https://www.anotherhome.net/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
<p align="center">
<img src="https://i.imgur.com/LnPvZvO.png" alt="ADPlayer" width="100">
</p>
<h1 align="center">DPlayer</h1>
> 🍭 Wow, such a lovely HTML5 danmaku video player
[](https://www.npmjs.com/package/dplayer)
[](https://github.com/MoePlayer/DPlayer/blob/master/LICENSE)
[](https://www.npmjs.com/package/dplayer)
[](https://www.jsdelivr.com/package/npm/dplayer)
## Introduction

DPlayer is a lovely HTML5 danmaku video player to help people build video and danmaku easily.
**DPlayer supports:**
- Streaming formats
- [HLS](https://github.com/video-dev/hls.js)
- [FLV](https://github.com/Bilibili/flv.js)
- [MPEG DASH](https://github.com/Dash-Industry-Forum/dash.js)
- [WebTorrent](https://github.com/webtorrent/webtorrent)
- Any other custom streaming formats
- Media formats
- MP4 H.264
- WebM
- Ogg Theora Vorbis
- Features
- Danmaku
- Screenshot
- Hotkeys
- Quality switching
- Thumbnails
- Subtitle
Using DPlayer on your project? [Let me know!](https://github.com/DIYgod/DPlayer/issues/31)
**[Docs](https://dplayer.diygod.dev/)**
**[中文文档](https://dplayer.diygod.dev/zh/)**
## Thanks
### Sponsors
<div>
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
<img height="60px" src="https://player.dogecloud.com/img/logo_with_product3.png">
</a>
</div>
### Contributors
<a href="https://github.com/MoePlayer/DPlayer/graphs/contributors"><img src="https://opencollective.com/DPlayer/contributors.svg?width=890" /></a>
## Related Projects
Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
### Tooling
- [DPlayer-thumbnails](https://github.com/MoePlayer/DPlayer-thumbnails): generate video thumbnails
### Danmaku api
- [DPlayer-node](https://github.com/MoePlayer/DPlayer-node): Node.js
- [laravel-danmaku](https://github.com/MoePlayer/laravel-danmaku): PHP
- [dplayer-live-backend](https://github.com/Izumi-kun/dplayer-live-backend): Node.js, WebSocket live backend
- [RailsGun](https://github.com/MoePlayer/RailsGun): Ruby
### Plugins
- [DPlayer-for-typecho](https://github.com/volio/DPlayer-for-typecho): Typecho
- [Hexo-tag-dplayer](https://github.com/NextMoe/hexo-tag-dplayer): Hexo
- [DPlayer_for_Z-BlogPHP](https://github.com/fghrsh/DPlayer_for_Z-BlogPHP): Z-BlogPHP
- [DPlayer for Discuz!](https://coding.net/u/Click_04/p/video/git): Discuz!
- [DPlayer for WordPress](https://github.com/BlueCocoa/DPlayer-WordPress): WordPress
- [DPlayerHandle](https://github.com/kn007/DPlayerHandle): WordPress
- [Selection](https://github.com/GreatSatan79/Selection): WordPress
- [Vue-DPlayer](https://github.com/sinchang/vue-dplayer): Vue
- [react-dplayer](https://github.com/hnsylitao/react-dplayer): React
- [rc-dplayer](https://github.com/tianfeng98/rc-dplayer): React
### Other
- [DPlayer-Lite](https://github.com/kn007/DPlayer-Lite): lite version
- [hlsjs-p2p-engine](https://github.com/cdnbye/hlsjs-p2p-engine): Let your viewers become your unlimitedly scalable CDN
- [CBPlayer](https://github.com/cdnbye/CBPlayer): Dplayer with CDNBye P2P plugin built in, supporting HLS, MP4 and MPEG-DASH P2P streaming.
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
## Who use DPlayer?
- [学习强国](https://itunes.apple.com/cn/app/%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD/id1426355645?mt=8): “学习强国”学习平台精心打造的手机客户端
- [小红书](https://www.xiaohongshu.com/): 中国最大的生活社区分享平台,同时也是发现全球好物的电商平台
- [极客时间](https://time.geekbang.org/): 极客邦科技出品的一款 IT 内容知识服务 App
- [嘀哩嘀哩](http://www.dilidili.wang/): 兴趣使然的无名小站(D 站)
- [银色子弹](https://www.sbsub.com/): 银色子弹,简称银弹,由多数柯南热爱者聚集在一起的组织
- [浙江大学 CC98 论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
- [纸飞机南航青年网络社区](http://my.nuaa.edu.cn/video-video.html): 南京航空航天大学门户网站
- [otomads](https://otomads.com/): 专注于音 MAD 的视频弹幕网站
- [Cloudreve](https://github.com/HFO4/Cloudreve): 基于 ThinkPHP 构建的网盘系统
- [oneindex](https://github.com/donwa/oneindex): Onedrive Directory Index
- [arozos](https://github.com/tobychui/arozos): General purposed Web Desktop Operating Platform / OS for Raspberry Pis
- [新东方云教室](https://roombox.xdf.cn/)
- [BBHouse](https://github.com/endcloud/bbhouse-tauri): A Bilibili Cross-Platform Desktop Client Powered By Tauri
- [Tampermonkey 阿里云盘](https://greasyfork.org/zh-CN/scripts/425955-%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98)
- [arozos](https://github.com/tobychui/arozos)
- [GBCLStudio/fof-upload-qcloud](https://github.com/GBCLStudio/FoF-Upload-Qcloud)
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
## Donate
DPlayer is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
You can support DPlayer via donations.
### Recurring Donation
- Become a Sponser on [GitHub](https://github.com/sponsors/DIYgod)
- Become a Sponser on [Patreon](https://www.patreon.com/DIYgod)
- Become a Sponser on [爱发电](https://afdian.net/@diygod)
- Contact us directly: i@diygod.me
### One-time Donation
We accept donations via the following ways:
- [WeChat Pay](https://diygod.me/images/wx.jpg)
- [Alipay](https://diygod.me/images/zfb.jpg)
- [Paypal](https://www.paypal.me/DIYgod)
## Author
**DPlayer** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
Authored and maintained by DIYgod with help from contributors ([list](https://github.com/DIYgod/DPlayer/contributors)).
> [Blog](https://diygod.me) · GitHub [@DIYgod](https://github.com/DIYgod) · Twitter [@DIYgod](https://twitter.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
================================================
FILE: demo/demo.css
================================================
body {
max-width: 700px;
margin: 0 auto;
padding: 45px 10px;
position: relative;
}
.show-dialog {
cursor: pointer;
border: 1px solid #f00;
width: 120px;
height: 40px;
line-height: 40px!important;
text-align: center;
border-radius: 4px;
}
.float-dplayer {
display: none;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .3);
position: fixed;
top: 0;
left: 0;
z-index: 99;
}
.dplayer-container {
width: 700px;
height: 358px;
border: 1px solid #f00;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.close-dialog {
position: absolute;
right: 40px;
top: 10px;
font-size: 40px!important;
font-weight: normal!important;
color: #fff;
cursor: pointer;
z-index: 100;
}
.example {
position: relative;
margin: 15px 0 0;
padding: 39px 19px 14px;
background-color: #fff;
border-radius: 4px 4px 0 0;
border: 1px solid #ddd;
}
@media (max-width:500px) {
.example {
padding: 39px 10px 14px;
}
}
.example:after {
content: "Example";
position: absolute;
top: 0;
left: 0;
padding: 2px 8px;
font-size: 12px;
font-weight: bold;
background-color: #f5f5f5;
color: #9da0a4;
border-radius: 4px 0 4px 0;
}
.highlight {
position: relative;
border-radius: 0 0 4px 4px;
border: 1px solid #ddd;
border-top: none;
}
.highlight.highlight-middle {
margin: 0;
border-radius: 0;
}
.highlight-html:after {
content: "HTML";
position: absolute;
top: 0;
right: 0;
padding: 2px 8px;
font-size: 12px;
font-weight: bold;
background-color: #f5f5f5;
color: #555;
border-radius: 0 0 0 4px;
}
.highlight-js:after {
content: "js";
position: absolute;
top: 0;
right: 0;
padding: 2px 8px;
font-size: 12px;
font-weight: bold;
background-color: #f5f5f5;
color: #555;
border-radius: 0 0 0 4px;
}
.btn {
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
height: 40px;
font-size: 14px;
margin: 0 0 10px;
cursor: pointer;
outline: none;
}
summary {
outline: none;
cursor: pointer;
margin-bottom: 10px;
}
#events {
font-size: 12px;
margin-top: 5px;
height: 120px;
overflow: scroll;
}
#events p {
margin: 0;
line-height: 17px;
}
/* github-corner */
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0)
}
20%,
60% {
transform: rotate(-25deg)
}
40%,
80% {
transform: rotate(10deg)
}
}
@media (max-width:500px) {
.github-corner:hover .octo-arm {
animation: none
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
}
/* modernizr */
.adownload li.adownload{ color: green; }.canvas li.canvas{ color: green; }.cssanimations li.cssanimations{ color: green; }.csstransforms li.csstransforms{ color: green; }.documentfragment li.documentfragment{ color: green; }.fullscreen li.fullscreen{ color: green; }.localstorage li.localstorage{ color: green; }.svg li.svg{ color: green; }.texttrackapi li.texttrackapi{ color: green; }.track li.track{ color: green; }.todataurljpeg li.todataurljpeg{ color: green; }.todataurlpng li.todataurlpng{ color: green; }.todataurlwebp li.todataurlwebp{ color: green; }.video li.video{ color: green; }.websockets li.websockets{ color: green; }.setclasses li.setclasses{ color: green; }
.no-adownload li.adownload{ color: red; }.no-canvas li.canvas{ color: red; }.no-cssanimations li.cssanimations{ color: red; }.no-csstransforms li.csstransforms{ color: red; }.no-documentfragment li.documentfragment{ color: red; }.no-fullscreen li.fullscreen{ color: red; }.no-localstorage li.localstorage{ color: red; }.no-svg li.svg{ color: red; }.no-texttrackapi li.texttrackapi{ color: red; }.no-track li.track{ color: red; }.no-todataurljpeg li.todataurljpeg{ color: red; }.no-todataurlpng li.todataurlpng{ color: red; }.no-todataurlwebp li.todataurlwebp{ color: red; }.no-video li.video{ color: red; }.no-websockets li.websockets{ color: red; }.no-setclasses li.setclasses{ color: red; }
================================================
FILE: demo/demo.js
================================================
// stats.js: JavaScript Performance Monitor
const stats = new Stats();
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild(stats.dom);
function animate() {
stats.begin();
// monitored code goes here
stats.end();
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
initPlayers();
handleEvent();
function handleEvent() {
document.getElementById('dplayer-dialog').addEventListener('click', (e) => {
const $clickDom = e.currentTarget;
const isShowStatus = $clickDom.getAttribute('data-show');
if (isShowStatus) {
document.getElementById('float-dplayer').style.display = 'none';
} else {
$clickDom.setAttribute('data-show', 1);
document.getElementById('float-dplayer').style.display = 'block';
}
});
document.getElementById('close-dialog').addEventListener('click', () => {
const $openDialogBtnDom = document.getElementById('dplayer-dialog');
$openDialogBtnDom.setAttribute('data-show', '');
document.getElementById('float-dplayer').style.display = 'none';
});
}
function initPlayers() {
// dplayer-float
window.dpFloat = new DPlayer({
container: document.getElementById('dplayer-container'),
preload: 'none',
screenshot: true,
video: {
url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4',
pic: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg',
thumbnails: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg'
},
subtitle: {
url: 'subtitle test'
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/'
}
});
// dp1
window.dp1 = new DPlayer({
container: document.getElementById('dplayer1'),
preload: 'none',
screenshot: true,
video: {
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg'
},
subtitle: {
url: [
{
url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.vtt',
lang: 'zh-cn',
name: '光',
},
{
url: 'https://gist.githubusercontent.com/samdutton/ca37f3adaf4e23679957b8083e061177/raw/e19399fbccbc069a2af4266e5120ae6bad62699a/sample.vtt',
lang: 'en-us',
name: 'github',
},
],
defaultSubtitle: 7,
type: 'webvtt',
fontSize: '25px',
bottom: '10%',
color: '#b7daff'
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
addition: ['https://s-sh-17-dplayercdn.oss.dogecdn.com/1678963.json']
}
});
// dp2
window.dp2 = new DPlayer({
container: document.getElementById('dplayer2'),
preload: 'none',
autoplay: false,
theme: '#FADFA3',
loop: true,
screenshot: true,
airplay: true,
chromecast: true,
hotkey: true,
logo: 'https://i.loli.net/2019/06/06/5cf8c5d94521136430.png',
volume: 0.2,
mutex: true,
lang: 'zh-cn',
video: {
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg',
type: 'auto'
},
subtitle: {
url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.vtt',
type: 'webvtt',
fontSize: '25px',
bottom: '10%',
color: '#b7daff'
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
addition: ['https://s-sh-17-dplayercdn.oss.dogecdn.com/1678963.json'],
token: 'tokendemo',
maximum: 3000,
user: 'DIYgod',
bottom: '15%',
unlimited: true,
speedRate: 0.5,
},
contextmenu: [
{
text: 'custom contextmenu',
link: 'https://github.com/MoePlayer/DPlayer'
}
]
});
const events = [
'abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error',
'loadeddata', 'loadedmetadata', 'loadstart', 'mozaudioavailable', 'pause', 'play',
'playing', 'ratechange', 'seeked', 'seeking', 'stalled',
'volumechange', 'waiting',
'screenshot',
'thumbnails_show', 'thumbnails_hide',
'danmaku_show', 'danmaku_hide', 'danmaku_clear',
'danmaku_loaded', 'danmaku_send', 'danmaku_opacity',
'contextmenu_show', 'contextmenu_hide',
'notice_show', 'notice_hide',
'quality_start', 'quality_end',
'destroy',
'resize',
'fullscreen', 'fullscreen_cancel', 'webfullscreen', 'webfullscreen_cancel',
'subtitle_show', 'subtitle_hide', 'subtitle_change'
];
const eventsEle = document.getElementById('events');
for (let i = 0; i < events.length; i++) {
dp2.on(events[i], (info) => {
eventsEle.innerHTML += `<p>Event: ${events[i]} ${info?`Data: <span>${JSON.stringify(info)}</span>`:''}</p>`;
eventsEle.scrollTop = eventsEle.scrollHeight;
});
}
// dp3
// window.dp3 = new DPlayer({
// container: document.getElementById('dplayer3'),
// preload: 'none',
// video: {
// quality: [{
// name: 'HD',
// url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.m3u8',
// type: 'hls'
// }, {
// name: 'SD',
// url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
// type: 'normal'
// }],
// defaultQuality: 0,
// pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png'
// }
// });
// // dp4
// window.dp4 = new DPlayer({
// container: document.getElementById('dplayer4'),
// preload: 'none',
// video: {
// url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.m3u8',
// type: 'hls'
// }
// });
// // dp5
// window.dp5 = new DPlayer({
// container: document.getElementById('dplayer5'),
// preload: 'none',
// video: {
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.flv',
// type: 'flv'
// }
// });
// window.dp8 = new DPlayer({
// container: document.getElementById('dplayer8'),
// preload: 'none',
// video: {
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/dash/hikarunara.mpd',
// type: 'dash'
// }
// });
// window.dp9 = new DPlayer({
// container: document.getElementById('dplayer9'),
// video: {
// url: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
// type: 'webtorrent'
// }
// });
// window.dp6 = new DPlayer({
// container: document.getElementById('dplayer6'),
// preload: 'none',
// live: true,
// danmaku: true,
// apiBackend: {
// read: function (endpoint, callback) {
// console.log('假装 WebSocket 连接成功');
// callback();
// },
// send: function (endpoint, danmakuData, callback) {
// console.log('假装通过 WebSocket 发送数据', danmakuData);
// callback();
// }
// },
// video: {
// url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.m3u8',
// type: 'hls'
// }
// });
// window.dp10 = new DPlayer({
// container: document.getElementById('dplayer10'),
// video: {
// url: 'https://qq.webrtc.win/tv/Pear-Demo-Yosemite_National_Park.mp4',
// type: 'pearplayer',
// customType: {
// 'pearplayer': function (video, player) {
// new PearPlayer(video, {
// src: video.src,
// autoplay: player.options.autoplay
// });
// }
// }
// }
// });
}
function clearPlayers() {
for (let i = 0; i < 6; i++) {
window['dp' + (i + 1)].pause();
document.getElementById('dplayer' + (i + 1)).innerHTML = '';
}
}
function switchDPlayer() {
if (dp2.options.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
dp2.switchVideo({
url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4',
pic: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg',
type: 'auto',
}, {
id: '5rGf5Y2X55qu6Z2p',
api: 'https://api.prprpr.me/dplayer/',
maximum: 3000,
user: 'DIYgod'
});
} else {
dp2.switchVideo({
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg',
type: 'auto'
}, {
id: '9E2E3368B56CDBB42',
api: 'https://api.prprpr.me/dplayer/',
maximum: 3000,
user: 'DIYgod'
});
}
}
================================================
FILE: demo/index.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DPlayer Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css">
<link rel="stylesheet" href="demo.css">
<script src="https://cdn.jsdelivr.net/npm/flv.js/dist/flv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dashjs/dist/dash.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pearplayer"></script>
<script src="DPlayer.js"></script>
</head>
<body class="markdown-body">
<h2>在 dialog 中承载视频</h2>
<h3 id="dplayer-dialog" class="show-dialog">Show Dialog</h3>
<div id="float-dplayer" class="float-dplayer">
<div id="dplayer-container" class="dplayer-container"></div>
<h3 id="close-dialog" class="close-dialog">X</h3>
</div>
<h2 id="quick-start">Quick Start</h2>
<div class="example">
<div id="dplayer1"></div>
</div>
<h2 id="options">Options</h2>
<div class="example">
<button class="btn" onclick="switchDPlayer()">Switch Video</button>
<button class="btn" onclick="dp2.notice('Notice演示')">notice</button>
<button class="btn" onclick="dp2.seek(120)">seek</button>
<button class="btn" onclick="dp2.volume(0.2)">volume</button>
<button class="btn" onclick="dp2.toggle()">toggle</button>
<button class="btn" onclick="dp2.destroy()">destroy</button>
<button class="btn" onclick="dp2.danmaku.hide()">danmaku.hide</button>
<button class="btn" onclick="dp2.danmaku.show()">danmaku.show</button>
<div id="dplayer2"></div>
<div id="events"></div>
</div>
<h2 id="quality-switching">Quality switching</h2>
<div class="example">
<button class="btn" onclick="dp3.switchQuality(1)">Switch quality</button>
<div id="dplayer3"></div>
</div>
<h2 id="hls-support">HLS support</h2>
<div class="example">
<div id="dplayer4"></div>
</div>
<h2 id="dash-support">MPEG DASH support</h2>
<div class="example">
<div id="dplayer8"></div>
</div>
<h2 id="flv-support">FLV support</h2>
<div class="example">
<div id="dplayer5"></div>
</div>
<h2 id="webtorrent">WebTorrent</h2>
<div class="example">
<div id="dplayer9"></div>
</div>
<h2 id="live">Live</h2>
<div class="example">
<button class="btn" onclick="dp6.danmaku.draw({text: '假装收到 WebSocket 弹幕', color: '#fff', type: 'right'})">假装收到 WebSocket 弹幕</button>
<div id="dplayer6"></div>
</div>
<h2 id="custon-type">Custon video type</h2>
<div class="example">
<div id="dplayer10"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/stats.js"></script>
<script src="demo.js"></script>
</body>
</html>
================================================
FILE: demo/modernizr.js
================================================
/*!
* modernizr v3.5.0
* Build https://modernizr.com/download?-adownload-canvas-cssanimations-csstransforms-documentfragment-fullscreen-localstorage-svg-texttrackapi_track-todataurljpeg_todataurlpng_todataurlwebp-video-websockets-setclasses-dontmin
*
* Copyright (c)
* Faruk Ates
* Paul Irish
* Alex Sexton
* Ryan Seddon
* Patrick Kettner
* Stu Cox
* Richard Herrera
* MIT License
*/
/*
* Modernizr tests which native CSS3 and HTML5 features are available in the
* current UA and makes the results available to you in two ways: as properties on
* a global `Modernizr` object, and as classes on the `<html>` element. This
* information allows you to progressively enhance your pages with a granular level
* of control over the experience.
*/
;(function(window, document, undefined){
var classes = [];
var tests = [];
/**
*
* ModernizrProto is the constructor for Modernizr
*
* @class
* @access public
*/
var ModernizrProto = {
// The current version, dummy
_version: '3.5.0',
// Any settings that don't work as separate modules
// can go in here as configuration.
_config: {
'classPrefix': '',
'enableClasses': true,
'enableJSClass': true,
'usePrefixes': true
},
// Queue of tests
_q: [],
// Stub these for people who are listening
on: function(test, cb) {
// I don't really think people should do this, but we can
// safe guard it a bit.
// -- NOTE:: this gets WAY overridden in src/addTest for actual async tests.
// This is in case people listen to synchronous tests. I would leave it out,
// but the code to *disallow* sync tests in the real version of this
// function is actually larger than this.
var self = this;
setTimeout(function() {
cb(self[test]);
}, 0);
},
addTest: function(name, fn, options) {
tests.push({name: name, fn: fn, options: options});
},
addAsyncTest: function(fn) {
tests.push({name: null, fn: fn});
}
};
// Fake some of Object.create so we can force non test results to be non "own" properties.
var Modernizr = function() {};
Modernizr.prototype = ModernizrProto;
// Leak modernizr globally when you `require` it rather than force it here.
// Overwrite name so constructor name is nicer :D
Modernizr = new Modernizr();
/*!
{
"name": "SVG",
"property": "svg",
"caniuse": "svg",
"tags": ["svg"],
"authors": ["Erik Dahlstrom"],
"polyfills": [
"svgweb",
"raphael",
"amplesdk",
"canvg",
"svg-boilerplate",
"sie",
"dojogfx",
"fabricjs"
]
}
!*/
/* DOC
Detects support for SVG in `<embed>` or `<object>` elements.
*/
Modernizr.addTest('svg', !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect);
/*!
{
"name": "WebSockets Support",
"property": "websockets",
"authors": ["Phread [fearphage]", "Mike Sherov [mikesherov]", "Burak Yigit Kaya [BYK]"],
"caniuse": "websockets",
"tags": ["html5"],
"warnings": [
"This test will reject any old version of WebSockets even if it is not prefixed such as in Safari 5.1"
],
"notes": [{
"name": "CLOSING State and Spec",
"href": "https://www.w3.org/TR/websockets/#the-websocket-interface"
}],
"polyfills": [
"sockjs",
"socketio",
"kaazing-websocket-gateway",
"websocketjs",
"atmosphere",
"graceful-websocket",
"portal",
"datachannel"
]
}
!*/
var supports = false;
try {
supports = 'WebSocket' in window && window.WebSocket.CLOSING === 2;
} catch (e) {}
Modernizr.addTest('websockets', supports);
/*!
{
"name": "Local Storage",
"property": "localstorage",
"caniuse": "namevalue-storage",
"tags": ["storage"],
"knownBugs": [],
"notes": [],
"warnings": [],
"polyfills": [
"joshuabell-polyfill",
"cupcake",
"storagepolyfill",
"amplifyjs",
"yui-cacheoffline"
]
}
!*/
// In FF4, if disabled, window.localStorage should === null.
// Normally, we could not test that directly and need to do a
// `('localStorage' in window)` test first because otherwise Firefox will
// throw bugzil.la/365772 if cookies are disabled
// Similarly, in Chrome with "Block third-party cookies and site data" enabled,
// attempting to access `window.sessionStorage` will throw an exception. crbug.com/357625
// Also in iOS5 Private Browsing mode, attempting to use localStorage.setItem
// will throw the exception:
// QUOTA_EXCEEDED_ERROR DOM Exception 22.
// Peculiarly, getItem and removeItem calls do not throw.
// Because we are forced to try/catch this, we'll go aggressive.
// Just FWIW: IE8 Compat mode supports these features completely:
// www.quirksmode.org/dom/html5.html
// But IE8 doesn't support either with local files
Modernizr.addTest('localstorage', function() {
var mod = 'modernizr';
try {
localStorage.setItem(mod, mod);
localStorage.removeItem(mod);
return true;
} catch (e) {
return false;
}
});
/**
* is returns a boolean if the typeof an obj is exactly type.
*
* @access private
* @function is
* @param {*} obj - A thing we want to check the type of
* @param {string} type - A string to compare the typeof against
* @returns {boolean}
*/
function is(obj, type) {
return typeof obj === type;
}
;
/**
* Run through all tests and detect their support in the current UA.
*
* @access private
*/
function testRunner() {
var featureNames;
var feature;
var aliasIdx;
var result;
var nameIdx;
var featureName;
var featureNameSplit;
for (var featureIdx in tests) {
if (tests.hasOwnProperty(featureIdx)) {
featureNames = [];
feature = tests[featureIdx];
// run the test, throw the return value into the Modernizr,
// then based on that boolean, define an appropriate className
// and push it into an array of classes we'll join later.
//
// If there is no name, it's an 'async' test that is run,
// but not directly added to the object. That should
// be done with a post-run addTest call.
if (feature.name) {
featureNames.push(feature.name.toLowerCase());
if (feature.options && feature.options.aliases && feature.options.aliases.length) {
// Add all the aliases into the names list
for (aliasIdx = 0; aliasIdx < feature.options.aliases.length; aliasIdx++) {
featureNames.push(feature.options.aliases[aliasIdx].toLowerCase());
}
}
}
// Run the test, or use the raw value if it's not a function
result = is(feature.fn, 'function') ? feature.fn() : feature.fn;
// Set each of the names on the Modernizr object
for (nameIdx = 0; nameIdx < featureNames.length; nameIdx++) {
featureName = featureNames[nameIdx];
// Support dot properties as sub tests. We don't do checking to make sure
// that the implied parent tests have been added. You must call them in
// order (either in the test, or make the parent test a dependency).
//
// Cap it to TWO to make the logic simple and because who needs that kind of subtesting
// hashtag famous last words
featureNameSplit = featureName.split('.');
if (featureNameSplit.length === 1) {
Modernizr[featureNameSplit[0]] = result;
} else {
// cast to a Boolean, if not one already
if (Modernizr[featureNameSplit[0]] && !(Modernizr[featureNameSplit[0]] instanceof Boolean)) {
Modernizr[featureNameSplit[0]] = new Boolean(Modernizr[featureNameSplit[0]]);
}
Modernizr[featureNameSplit[0]][featureNameSplit[1]] = result;
}
classes.push((result ? '' : 'no-') + featureNameSplit.join('-'));
}
}
}
}
;
/**
* docElement is a convenience wrapper to grab the root element of the document
*
* @access private
* @returns {HTMLElement|SVGElement} The root element of the document
*/
var docElement = document.documentElement;
/*!
{
"name": "Document Fragment",
"property": "documentfragment",
"notes": [{
"name": "W3C DOM Level 1 Reference",
"href": "https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-B63ED1A3"
}, {
"name": "SitePoint Reference",
"href": "http://reference.sitepoint.com/javascript/DocumentFragment"
}, {
"name": "QuirksMode Compatibility Tables",
"href": "http://www.quirksmode.org/m/w3c_core.html#t112"
}],
"authors": ["Ron Waldon (@jokeyrhyme)"],
"knownBugs": ["false-positive on Blackberry 9500, see QuirksMode note"],
"tags": []
}
!*/
/* DOC
Append multiple elements to the DOM within a single insertion.
*/
Modernizr.addTest('documentfragment', function() {
return 'createDocumentFragment' in document &&
'appendChild' in docElement;
});
/**
* A convenience helper to check if the document we are running in is an SVG document
*
* @access private
* @returns {boolean}
*/
var isSVG = docElement.nodeName.toLowerCase() === 'svg';
/**
* setClasses takes an array of class names and adds them to the root element
*
* @access private
* @function setClasses
* @param {string[]} classes - Array of class names
*/
// Pass in an and array of class names, e.g.:
// ['no-webp', 'borderradius', ...]
function setClasses(classes) {
var className = docElement.className;
var classPrefix = Modernizr._config.classPrefix || '';
if (isSVG) {
className = className.baseVal;
}
// Change `no-js` to `js` (independently of the `enableClasses` option)
// Handle classPrefix on this too
if (Modernizr._config.enableJSClass) {
var reJS = new RegExp('(^|\\s)' + classPrefix + 'no-js(\\s|$)');
className = className.replace(reJS, '$1' + classPrefix + 'js$2');
}
if (Modernizr._config.enableClasses) {
// Add the new classes
className += ' ' + classPrefix + classes.join(' ' + classPrefix);
if (isSVG) {
docElement.className.baseVal = className;
} else {
docElement.className = className;
}
}
}
;
/**
* createElement is a convenience wrapper around document.createElement. Since we
* use createElement all over the place, this allows for (slightly) smaller code
* as well as abstracting away issues with creating elements in contexts other than
* HTML documents (e.g. SVG documents).
*
* @access private
* @function createElement
* @returns {HTMLElement|SVGElement} An HTML or SVG element
*/
function createElement() {
if (typeof document.createElement !== 'function') {
// This is the case in IE7, where the type of createElement is "object".
// For this reason, we cannot call apply() as Object is not a Function.
return document.createElement(arguments[0]);
} else if (isSVG) {
return document.createElementNS.call(document, 'http://www.w3.org/2000/svg', arguments[0]);
} else {
return document.createElement.apply(document, arguments);
}
}
;
/*!
{
"name": "Canvas",
"property": "canvas",
"caniuse": "canvas",
"tags": ["canvas", "graphics"],
"polyfills": ["flashcanvas", "excanvas", "slcanvas", "fxcanvas"]
}
!*/
/* DOC
Detects support for the `<canvas>` element for 2D drawing.
*/
// On the S60 and BB Storm, getContext exists, but always returns undefined
// so we actually have to call getContext() to verify
// github.com/Modernizr/Modernizr/issues/issue/97/
Modernizr.addTest('canvas', function() {
var elem = createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
});
/*!
{
"name": "HTML5 Video",
"property": "video",
"caniuse": "video",
"tags": ["html5"],
"knownBugs": [
"Without QuickTime, `Modernizr.video.h264` will be `undefined`; https://github.com/Modernizr/Modernizr/issues/546"
],
"polyfills": [
"html5media",
"mediaelementjs",
"sublimevideo",
"videojs",
"leanbackplayer",
"videoforeverybody"
]
}
!*/
/* DOC
Detects support for the video element, as well as testing what types of content it supports.
Subproperties are provided to describe support for `ogg`, `h264` and `webm` formats, e.g.:
```javascript
Modernizr.video // true
Modernizr.video.ogg // 'probably'
```
*/
// Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
// thx to NielsLeenheer and zcorpan
// Note: in some older browsers, "no" was a return value instead of empty string.
// It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2
// It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5
Modernizr.addTest('video', function() {
var elem = createElement('video');
var bool = false;
// IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
try {
bool = !!elem.canPlayType
if (bool) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '');
// Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '');
bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '');
bool.vp9 = elem.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '');
bool.hls = elem.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '');
}
} catch (e) {}
return bool;
});
/*!
{
"name": "a[download] Attribute",
"property": "adownload",
"caniuse" : "download",
"tags": ["media", "attribute"],
"builderAliases": ["a_download"],
"notes": [{
"name": "WhatWG Reference",
"href": "https://developers.whatwg.org/links.html#downloading-resources"
}]
}
!*/
/* DOC
When used on an `<a>`, this attribute signifies that the resource it points to should be downloaded by the browser rather than navigating to it.
*/
Modernizr.addTest('adownload', !window.externalHost && 'download' in createElement('a'));
/*!
{
"name": "canvas.toDataURL type support",
"property": ["todataurljpeg", "todataurlpng", "todataurlwebp"],
"tags": ["canvas"],
"builderAliases": ["canvas_todataurl_type"],
"async" : false,
"notes": [{
"name": "MDN article",
"href": "https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement.toDataURL"
}]
}
!*/
var canvas = createElement('canvas');
Modernizr.addTest('todataurljpeg', function() {
return !!Modernizr.canvas && canvas.toDataURL('image/jpeg').indexOf('data:image/jpeg') === 0;
});
Modernizr.addTest('todataurlpng', function() {
return !!Modernizr.canvas && canvas.toDataURL('image/png').indexOf('data:image/png') === 0;
});
Modernizr.addTest('todataurlwebp', function() {
var supports = false;
// firefox 3 throws an error when you use an "invalid" toDataUrl
try {
supports = !!Modernizr.canvas && canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0;
} catch (e) {}
return supports;
});
/*!
{
"name": "Track element and Timed Text Track",
"property": ["texttrackapi", "track"],
"tags": ["elem"],
"builderAliases": ["elem_track"],
"authors": ["Addy Osmani"],
"notes": [{
"name": "W3 track Element Spec",
"href": "http://www.w3.org/TR/html5/video.html#the-track-element"
},{
"name": "W3 track API Spec",
"href": "http://www.w3.org/TR/html5/media-elements.html#text-track-api"
}],
"warnings": ["While IE10 has implemented the track element, IE10 does not expose the underlying APIs to create timed text tracks by JS (really sad)"]
}
!*/
Modernizr.addTest('texttrackapi', typeof (createElement('video').addTextTrack) === 'function');
// a more strict test for track including UI support: document.createElement('track').kind === 'subtitles'
Modernizr.addTest('track', 'kind' in createElement('track'));
/**
* cssToDOM takes a kebab-case string and converts it to camelCase
* e.g. box-sizing -> boxSizing
*
* @access private
* @function cssToDOM
* @param {string} name - String name of kebab-case prop we want to convert
* @returns {string} The camelCase version of the supplied name
*/
function cssToDOM(name) {
return name.replace(/([a-z])-([a-z])/g, function(str, m1, m2) {
return m1 + m2.toUpperCase();
}).replace(/^-/, '');
}
;
/**
* If the browsers follow the spec, then they would expose vendor-specific styles as:
* elem.style.WebkitBorderRadius
* instead of something like the following (which is technically incorrect):
* elem.style.webkitBorderRadius
* WebKit ghosts their properties in lowercase but Opera & Moz do not.
* Microsoft uses a lowercase `ms` instead of the correct `Ms` in IE8+
* erik.eae.net/archives/2008/03/10/21.48.10/
* More here: github.com/Modernizr/Modernizr/issues/issue/21
*
* @access private
* @returns {string} The string representing the vendor-specific style properties
*/
var omPrefixes = 'Moz O ms Webkit';
var cssomPrefixes = (ModernizrProto._config.usePrefixes ? omPrefixes.split(' ') : []);
ModernizrProto._cssomPrefixes = cssomPrefixes;
/**
* atRule returns a given CSS property at-rule (eg @keyframes), possibly in
* some prefixed form, or false, in the case of an unsupported rule
*
* @memberof Modernizr
* @name Modernizr.atRule
* @optionName Modernizr.atRule()
* @optionProp atRule
* @access public
* @function atRule
* @param {string} prop - String name of the @-rule to test for
* @returns {string|boolean} The string representing the (possibly prefixed)
* valid version of the @-rule, or `false` when it is unsupported.
* @example
* ```js
* var keyframes = Modernizr.atRule('@keyframes');
*
* if (keyframes) {
* // keyframes are supported
* // could be `@-webkit-keyframes` or `@keyframes`
* } else {
* // keyframes === `false`
* }
* ```
*
*/
var atRule = function(prop) {
var length = prefixes.length;
var cssrule = window.CSSRule;
var rule;
if (typeof cssrule === 'undefined') {
return undefined;
}
if (!prop) {
return false;
}
// remove literal @ from beginning of provided property
prop = prop.replace(/^@/, '');
// CSSRules use underscores instead of dashes
rule = prop.replace(/-/g, '_').toUpperCase() + '_RULE';
if (rule in cssrule) {
return '@' + prop;
}
for (var i = 0; i < length; i++) {
// prefixes gives us something like -o-, and we want O_
var prefix = prefixes[i];
var thisRule = prefix.toUpperCase() + '_' + rule;
if (thisRule in cssrule) {
return '@-' + prefix.toLowerCase() + '-' + prop;
}
}
return false;
};
ModernizrProto.atRule = atRule;
/**
* List of JavaScript DOM values used for tests
*
* @memberof Modernizr
* @name Modernizr._domPrefixes
* @optionName Modernizr._domPrefixes
* @optionProp domPrefixes
* @access public
* @example
*
* Modernizr._domPrefixes is exactly the same as [_prefixes](#modernizr-_prefixes), but rather
* than kebab-case properties, all properties are their Capitalized variant
*
* ```js
* Modernizr._domPrefixes === [ "Moz", "O", "ms", "Webkit" ];
* ```
*/
var domPrefixes = (ModernizrProto._config.usePrefixes ? omPrefixes.toLowerCase().split(' ') : []);
ModernizrProto._domPrefixes = domPrefixes;
/**
* contains checks to see if a string contains another string
*
* @access private
* @function contains
* @param {string} str - The string we want to check for substrings
* @param {string} substr - The substring we want to search the first string for
* @returns {boolean}
*/
function contains(str, substr) {
return !!~('' + str).indexOf(substr);
}
;
/**
* fnBind is a super small [bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) polyfill.
*
* @access private
* @function fnBind
* @param {function} fn - a function you want to change `this` reference to
* @param {object} that - the `this` you want to call the function with
* @returns {function} The wrapped version of the supplied function
*/
function fnBind(fn, that) {
return function() {
return fn.apply(that, arguments);
};
}
;
/**
* testDOMProps is a generic DOM property test; if a browser supports
* a certain property, it won't return undefined for it.
*
* @access private
* @function testDOMProps
* @param {array.<string>} props - An array of properties to test for
* @param {object} obj - An object or Element you want to use to test the parameters again
* @param {boolean|object} elem - An Element to bind the property lookup again. Use `false` to prevent the check
* @returns {false|*} returns false if the prop is unsupported, otherwise the value that is supported
*/
function testDOMProps(props, obj, elem) {
var item;
for (var i in props) {
if (props[i] in obj) {
// return the property name as a string
if (elem === false) {
return props[i];
}
item = obj[props[i]];
// let's bind a function
if (is(item, 'function')) {
// bind to obj unless overriden
return fnBind(item, elem || obj);
}
// return the unbound function or obj or value
return item;
}
}
return false;
}
;
/**
* Create our "modernizr" element that we do most feature tests on.
*
* @access private
*/
var modElem = {
elem: createElement('modernizr')
};
// Clean up this element
Modernizr._q.push(function() {
delete modElem.elem;
});
var mStyle = {
style: modElem.elem.style
};
// kill ref for gc, must happen before mod.elem is removed, so we unshift on to
// the front of the queue.
Modernizr._q.unshift(function() {
delete mStyle.style;
});
/**
* domToCSS takes a camelCase string and converts it to kebab-case
* e.g. boxSizing -> box-sizing
*
* @access private
* @function domToCSS
* @param {string} name - String name of camelCase prop we want to convert
* @returns {string} The kebab-case version of the supplied name
*/
function domToCSS(name) {
return name.replace(/([A-Z])/g, function(str, m1) {
return '-' + m1.toLowerCase();
}).replace(/^ms-/, '-ms-');
}
;
/**
* wrapper around getComputedStyle, to fix issues with Firefox returning null when
* called inside of a hidden iframe
*
* @access private
* @function computedStyle
* @param {HTMLElement|SVGElement} - The element we want to find the computed styles of
* @param {string|null} [pseudoSelector]- An optional pseudo element selector (e.g. :before), of null if none
* @returns {CSSStyleDeclaration}
*/
function computedStyle(elem, pseudo, prop) {
var result;
if ('getComputedStyle' in window) {
result = getComputedStyle.call(window, elem, pseudo);
var console = window.console;
if (result !== null) {
if (prop) {
result = result.getPropertyValue(prop);
}
} else {
if (console) {
var method = console.error ? 'error' : 'log';
console[method].call(console, 'getComputedStyle returning null, its possible modernizr test results are inaccurate');
}
}
} else {
result = !pseudo && elem.currentStyle && elem.currentStyle[prop];
}
return result;
}
;
/**
* getBody returns the body of a document, or an element that can stand in for
* the body if a real body does not exist
*
* @access private
* @function getBody
* @returns {HTMLElement|SVGElement} Returns the real body of a document, or an
* artificially created element that stands in for the body
*/
function getBody() {
// After page load injecting a fake body doesn't work so check if body exists
var body = document.body;
if (!body) {
// Can't use the real body create a fake one.
body = createElement(isSVG ? 'svg' : 'body');
body.fake = true;
}
return body;
}
;
/**
* injectElementWithStyles injects an element with style element and some CSS rules
*
* @access private
* @function injectElementWithStyles
* @param {string} rule - String representing a css rule
* @param {function} callback - A function that is used to test the injected element
* @param {number} [nodes] - An integer representing the number of additional nodes you want injected
* @param {string[]} [testnames] - An array of strings that are used as ids for the additional nodes
* @returns {boolean}
*/
function injectElementWithStyles(rule, callback, nodes, testnames) {
var mod = 'modernizr';
var style;
var ret;
var node;
var docOverflow;
var div = createElement('div');
var body = getBody();
if (parseInt(nodes, 10)) {
// In order not to give false positives we create a node for each test
// This also allows the method to scale for unspecified uses
while (nodes--) {
node = createElement('div');
node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
div.appendChild(node);
}
}
style = createElement('style');
style.type = 'text/css';
style.id = 's' + mod;
// IE6 will false positive on some tests due to the style element inside the test div somehow interfering offsetHeight, so insert it into body or fakebody.
// Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270
(!body.fake ? div : body).appendChild(style);
body.appendChild(div);
if (style.styleSheet) {
style.styleSheet.cssText = rule;
} else {
style.appendChild(document.createTextNode(rule));
}
div.id = mod;
if (body.fake) {
//avoid crashing IE8, if background image is used
body.style.background = '';
//Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible
body.style.overflow = 'hidden';
docOverflow = docElement.style.overflow;
docElement.style.overflow = 'hidden';
docElement.appendChild(body);
}
ret = callback(div, rule);
// If this is done after page load we don't want to remove the body so check if body exists
if (body.fake) {
body.parentNode.removeChild(body);
docElement.style.overflow = docOverflow;
// Trigger layout so kinetic scrolling isn't disabled in iOS6+
// eslint-disable-next-line
docElement.offsetHeight;
} else {
div.parentNode.removeChild(div);
}
return !!ret;
}
;
/**
* nativeTestProps allows for us to use native feature detection functionality if available.
* some prefixed form, or false, in the case of an unsupported rule
*
* @access private
* @function nativeTestProps
* @param {array} props - An array of property names
* @param {string} value - A string representing the value we want to check via @supports
* @returns {boolean|undefined} A boolean when @supports exists, undefined otherwise
*/
// Accepts a list of property names and a single value
// Returns `undefined` if native detection not available
function nativeTestProps(props, value) {
var i = props.length;
// Start with the JS API: http://www.w3.org/TR/css3-conditional/#the-css-interface
if ('CSS' in window && 'supports' in window.CSS) {
// Try every prefixed variant of the property
while (i--) {
if (window.CSS.supports(domToCSS(props[i]), value)) {
return true;
}
}
return false;
}
// Otherwise fall back to at-rule (for Opera 12.x)
else if ('CSSSupportsRule' in window) {
// Build a condition string for every prefixed variant
var conditionText = [];
while (i--) {
conditionText.push('(' + domToCSS(props[i]) + ':' + value + ')');
}
conditionText = conditionText.join(' or ');
return injectElementWithStyles('@supports (' + conditionText + ') { #modernizr { position: absolute; } }', function(node) {
return computedStyle(node, null, 'position') == 'absolute';
});
}
return undefined;
}
;
// testProps is a generic CSS / DOM property test.
// In testing support for a given CSS property, it's legit to test:
// `elem.style[styleName] !== undefined`
// If the property is supported it will return an empty string,
// if unsupported it will return undefined.
// We'll take advantage of this quick test and skip setting a style
// on our modernizr element, but instead just testing undefined vs
// empty string.
// Property names can be provided in either camelCase or kebab-case.
function testProps(props, prefixed, value, skipValueTest) {
skipValueTest = is(skipValueTest, 'undefined') ? false : skipValueTest;
// Try native detect first
if (!is(value, 'undefined')) {
var result = nativeTestProps(props, value);
if (!is(result, 'undefined')) {
return result;
}
}
// Otherwise do it properly
var afterInit, i, propsLength, prop, before;
// If we don't have a style element, that means we're running async or after
// the core tests, so we'll need to create our own elements to use
// inside of an SVG element, in certain browsers, the `style` element is only
// defined for valid tags. Therefore, if `modernizr` does not have one, we
// fall back to a less used element and hope for the best.
// for strict XHTML browsers the hardly used samp element is used
var elems = ['modernizr', 'tspan', 'samp'];
while (!mStyle.style && elems.length) {
afterInit = true;
mStyle.modElem = createElement(elems.shift());
mStyle.style = mStyle.modElem.style;
}
// Delete the objects if we created them.
function cleanElems() {
if (afterInit) {
delete mStyle.style;
delete mStyle.modElem;
}
}
propsLength = props.length;
for (i = 0; i < propsLength; i++) {
prop = props[i];
before = mStyle.style[prop];
if (contains(prop, '-')) {
prop = cssToDOM(prop);
}
if (mStyle.style[prop] !== undefined) {
// If value to test has been passed in, do a set-and-check test.
// 0 (integer) is a valid property value, so check that `value` isn't
// undefined, rather than just checking it's truthy.
if (!skipValueTest && !is(value, 'undefined')) {
// Needs a try catch block because of old IE. This is slow, but will
// be avoided in most cases because `skipValueTest` will be used.
try {
mStyle.style[prop] = value;
} catch (e) {}
// If the property value has changed, we assume the value used is
// supported. If `value` is empty string, it'll fail here (because
// it hasn't changed), which matches how browsers have implemented
// CSS.supports()
if (mStyle.style[prop] != before) {
cleanElems();
return prefixed == 'pfx' ? prop : true;
}
}
// Otherwise just return true, or the property name if this is a
// `prefixed()` call
else {
cleanElems();
return prefixed == 'pfx' ? prop : true;
}
}
}
cleanElems();
return false;
}
;
/**
* testPropsAll tests a list of DOM properties we want to check against.
* We specify literally ALL possible (known and/or likely) properties on
* the element including the non-vendor prefixed one, for forward-
* compatibility.
*
* @access private
* @function testPropsAll
* @param {string} prop - A string of the property to test for
* @param {string|object} [prefixed] - An object to check the prefixed properties on. Use a string to skip
* @param {HTMLElement|SVGElement} [elem] - An element used to test the property and value against
* @param {string} [value] - A string of a css value
* @param {boolean} [skipValueTest] - An boolean representing if you want to test if value sticks when set
* @returns {false|string} returns the string version of the property, or false if it is unsupported
*/
function testPropsAll(prop, prefixed, elem, value, skipValueTest) {
var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
// did they call .prefixed('boxSizing') or are we just testing a prop?
if (is(prefixed, 'string') || is(prefixed, 'undefined')) {
return testProps(props, prefixed, value, skipValueTest);
// otherwise, they called .prefixed('requestAnimationFrame', window[, elem])
} else {
props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
return testDOMProps(props, prefixed, elem);
}
}
// Modernizr.testAllProps() investigates whether a given style property,
// or any of its vendor-prefixed variants, is recognized
//
// Note that the property names must be provided in the camelCase variant.
// Modernizr.testAllProps('boxSizing')
ModernizrProto.testAllProps = testPropsAll;
/**
* prefixed returns the prefixed or nonprefixed property name variant of your input
*
* @memberof Modernizr
* @name Modernizr.prefixed
* @optionName Modernizr.prefixed()
* @optionProp prefixed
* @access public
* @function prefixed
* @param {string} prop - String name of the property to test for
* @param {object} [obj] - An object to test for the prefixed properties on
* @param {HTMLElement} [elem] - An element used to test specific properties against
* @returns {string|false} The string representing the (possibly prefixed) valid
* version of the property, or `false` when it is unsupported.
* @example
*
* Modernizr.prefixed takes a string css value in the DOM style camelCase (as
* opposed to the css style kebab-case) form and returns the (possibly prefixed)
* version of that property that the browser actually supports.
*
* For example, in older Firefox...
* ```js
* prefixed('boxSizing')
* ```
* returns 'MozBoxSizing'
*
* In newer Firefox, as well as any other browser that support the unprefixed
* version would simply return `boxSizing`. Any browser that does not support
* the property at all, it will return `false`.
*
* By default, prefixed is checked against a DOM element. If you want to check
* for a property on another object, just pass it as a second argument
*
* ```js
* var rAF = prefixed('requestAnimationFrame', window);
*
* raf(function() {
* renderFunction();
* })
* ```
*
* Note that this will return _the actual function_ - not the name of the function.
* If you need the actual name of the property, pass in `false` as a third argument
*
* ```js
* var rAFProp = prefixed('requestAnimationFrame', window, false);
*
* rafProp === 'WebkitRequestAnimationFrame' // in older webkit
* ```
*
* One common use case for prefixed is if you're trying to determine which transition
* end event to bind to, you might do something like...
* ```js
* var transEndEventNames = {
* 'WebkitTransition' : 'webkitTransitionEnd', * Saf 6, Android Browser
* 'MozTransition' : 'transitionend', * only for FF < 15
* 'transition' : 'transitionend' * IE10, Opera, Chrome, FF 15+, Saf 7+
* };
*
* var transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
* ```
*
* If you want a similar lookup, but in kebab-case, you can use [prefixedCSS](#modernizr-prefixedcss).
*/
var prefixed = ModernizrProto.prefixed = function(prop, obj, elem) {
if (prop.indexOf('@') === 0) {
return atRule(prop);
}
if (prop.indexOf('-') != -1) {
// Convert kebab-case to camelCase
prop = cssToDOM(prop);
}
if (!obj) {
return testPropsAll(prop, 'pfx');
} else {
// Testing DOM property e.g. Modernizr.prefixed('requestAnimationFrame', window) // 'mozRequestAnimationFrame'
return testPropsAll(prop, obj, elem);
}
};
/*!
{
"name": "Fullscreen API",
"property": "fullscreen",
"caniuse": "fullscreen",
"notes": [{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en/API/Fullscreen"
}],
"polyfills": ["screenfulljs"],
"builderAliases": ["fullscreen_api"]
}
!*/
/* DOC
Detects support for the ability to make the current website take over the user's entire screen
*/
// github.com/Modernizr/Modernizr/issues/739
Modernizr.addTest('fullscreen', !!(prefixed('exitFullscreen', document, false) || prefixed('cancelFullScreen', document, false)));
/**
* testAllProps determines whether a given CSS property is supported in the browser
*
* @memberof Modernizr
* @name Modernizr.testAllProps
* @optionName Modernizr.testAllProps()
* @optionProp testAllProps
* @access public
* @function testAllProps
* @param {string} prop - String naming the property to test (either camelCase or kebab-case)
* @param {string} [value] - String of the value to test
* @param {boolean} [skipValueTest=false] - Whether to skip testing that the value is supported when using non-native detection
* @example
*
* testAllProps determines whether a given CSS property, in some prefixed form,
* is supported by the browser.
*
* ```js
* testAllProps('boxSizing') // true
* ```
*
* It can optionally be given a CSS value in string form to test if a property
* value is valid
*
* ```js
* testAllProps('display', 'block') // true
* testAllProps('display', 'penguin') // false
* ```
*
* A boolean can be passed as a third parameter to skip the value check when
* native detection (@supports) isn't available.
*
* ```js
* testAllProps('shapeOutside', 'content-box', true);
* ```
*/
function testAllProps(prop, value, skipValueTest) {
return testPropsAll(prop, undefined, undefined, value, skipValueTest);
}
ModernizrProto.testAllProps = testAllProps;
/*!
{
"name": "CSS Animations",
"property": "cssanimations",
"caniuse": "css-animation",
"polyfills": ["transformie", "csssandpaper"],
"tags": ["css"],
"warnings": ["Android < 4 will pass this test, but can only animate a single property at a time"],
"notes": [{
"name" : "Article: 'Dispelling the Android CSS animation myths'",
"href": "https://goo.gl/OGw5Gm"
}]
}
!*/
/* DOC
Detects whether or not elements can be animated using CSS
*/
Modernizr.addTest('cssanimations', testAllProps('animationName', 'a', true));
/*!
{
"name": "CSS Transforms",
"property": "csstransforms",
"caniuse": "transforms2d",
"tags": ["css"]
}
!*/
Modernizr.addTest('csstransforms', function() {
// Android < 3.0 is buggy, so we sniff and blacklist
// http://git.io/hHzL7w
return navigator.userAgent.indexOf('Android 2.') === -1 &&
testAllProps('transform', 'scale(1)', true);
});
// Run each test
testRunner();
// Remove the "no-js" class if it exists
setClasses(classes);
delete ModernizrProto.addTest;
delete ModernizrProto.addAsyncTest;
// Run the things that are supposed to run after the tests
for (var i = 0; i < Modernizr._q.length; i++) {
Modernizr._q[i]();
}
// Leak Modernizr namespace
window.Modernizr = Modernizr;
;
})(window, document);
================================================
FILE: docs/.vuepress/components/DPlayer.vue
================================================
<template>
<div class="dplayer-wrap">
<div class="dplayer" ref="dplayer"><button class="load" v-on:click="load">Load demo</button></div>
</div>
</template>
<script>
export default {
props: {
immediate: {
type: Boolean,
default: false,
},
options: {
type: Object,
default: () => ({
autoplay: false,
theme: '#FADFA3',
loop: true,
lang: 'zh-cn',
hotkey: true,
preload: 'auto',
logo: 'https://i.loli.net/2019/06/06/5cf8c5d94521136430.png',
volume: 0.7,
mutex: true,
screenshot: true,
subtitle: {
url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.vtt',
type: 'webvtt',
fontSize: '20px',
bottom: '10%',
color: '#FADFA3'
},
video: {
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg',
type: 'auto'
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
token: 'tokendemo',
user: 'DIYgod',
addition: ['https://s-sh-17-dplayercdn.oss.dogecdn.com/1678963.json']
},
contextmenu: [
{
text: 'custom1',
link: 'https://github.com/DIYgod/DPlayer'
},
{
text: 'custom2',
click: (player) => {
console.log(player);
}
}
],
highlight: [
{
time: 20,
text: '这是第 20 秒'
},
{
time: 120,
text: '这是 2 分钟'
}
]
})
},
},
methods: {
load: function () {
this.options.container = this.$refs.dplayer;
setTimeout(() => {
this.dplayer = new window.DPlayer(this.options);
}, 0);
}
},
mounted: function () {
if (this.immediate) {
setTimeout(() => {
this.dplayer = new window.DPlayer(this.options);
}, 0);
}
},
beforeDestroy: function () {
this.dplayer && this.dplayer.destroy();
}
}
</script>
<style>
</style>
================================================
FILE: docs/.vuepress/config.js
================================================
module.exports = {
plugins: {
'@vuepress/back-to-top': true,
umami: {
trackerUrl: 'https://umami.diygod.dev',
siteId: 'f3b469a2-8054-4bbb-8873-4035761aa4e3',
},
},
locales: {
'/zh/': {
lang: 'zh-CN',
title: 'DPlayer',
description: '🍭 Wow, such a lovely HTML5 danmaku video player',
},
'/': {
lang: 'en-US',
title: 'DPlayer',
description: '🍭 Wow, such a lovely HTML5 danmaku video player',
},
},
head: [
['link', { rel: 'icon', href: `/logo.png` }],
['script', { src: 'https://cdn.jsdelivr.net/npm/flv.js/dist/flv.min.js' }],
['script', { src: 'https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js' }],
['script', { src: 'https://cdn.jsdelivr.net/npm/dashjs/dist/dash.all.min.js' }],
['script', { src: 'https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js' }],
['script', { src: 'https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js' }],
],
theme: 'vuepress-theme-dplayer',
themeConfig: {
repo: 'MoePlayer/DPlayer',
editLinks: true,
docsDir: '.',
locales: {
'/zh/': {
lang: 'zh-CN',
selectText: '选择语言',
label: '简体中文',
editLinkText: '在 GitHub 上编辑此页',
lastUpdated: '上次更新',
nav: [
{
text: '指南',
link: '/zh/guide/',
},
{
text: '生态',
link: '/zh/ecosystem/',
},
{
text: '支持 DPlayer',
link: '/zh/support/',
},
],
},
'/': {
lang: 'en-US',
selectText: 'Languages',
label: 'English',
editLinkText: 'Edit this page on GitHub',
lastUpdated: 'Last Updated',
nav: [
{
text: 'Guide',
link: '/guide/',
},
{
text: 'Ecosystem',
link: '/ecosystem/',
},
{
text: 'Support DPlayer',
link: '/support/',
},
],
},
},
},
};
================================================
FILE: docs/.vuepress/styles/index.styl
================================================
.navbar .home-link .site-name {
color: #F5712C;
}
.page .custom-block.tip {
border-color: #F5712C;
}
.icon.outbound {
display: none;
}
a {
word-break: break-all;
}
#指南 {
display: none;
}
#guide {
display: none;
}
#app .global-ui .sw-update-popup {
border: 1px solid #F5712C;
}
.routes .sidebar-group-items > li > .sidebar-sub-headers > .sidebar-sub-header > a {
color: $accentColor;
}
#dplayer {
margin-top: -1.5rem;
margin-bottom: 1rem;
}
.hero .description {
display: none;
}
.hero .action {
display: none;
}
.hero.custom .action {
display: block;
}
================================================
FILE: docs/.vuepress/styles/palette.styl
================================================
$accentColor = #F5712C
================================================
FILE: docs/.vuepress/theme/components/CarbonAds.vue
================================================
<script>
export default {
name: 'CarbonAds',
watch: {
'$route' (to, from) {
if (
to.path !== from.path
// Only reload if the ad has been loaded
// otherwise it's possible that the script is appended but
// the ads are not loaded yet. This would result in duplicated ads.
&& this.$el.querySelector('#carbonads')
) {
this.$el.innerHTML = ''
this.load()
}
}
},
mounted () {
this.load()
},
methods: {
load () {
const s = document.createElement('script')
s.id = '_carbonads_js'
s.src = `//cdn.carbonads.com/carbon.js?serve=CEAI6277&placement=dplayerjsorg`
this.$el.appendChild(s)
}
},
render (h) {
return h('div', { class: 'carbon-ads' })
}
}
</script>
<style lang="stylus">
.carbon-ads
min-height 102px
padding 1.5rem 1.5rem 0
margin-bottom -0.5rem
font-size 0.75rem
a
color #444
font-weight normal
display inline
.carbon-img
float left
margin-right 1rem
border 1px solid $borderColor
img
display block
.carbon-poweredby
color #999
display block
margin-top 0.5em
@media (max-width: $MQMobile)
.carbon-ads
.carbon-img img
width 100px
height 77px
</style>
================================================
FILE: docs/.vuepress/theme/index.js
================================================
module.exports = {
extend: '@vuepress/theme-default',
};
================================================
FILE: docs/.vuepress/theme/layouts/Layout.vue
================================================
<template>
<ParentLayout>
<template #sidebar-top>
<CarbonAds />
</template>
</ParentLayout>
</template>
<script>
import ParentLayout from '@parent-theme/layouts/Layout.vue'
import CarbonAds from '@theme/components/CarbonAds.vue'
export default {
name: 'Layout',
components: {
ParentLayout,
CarbonAds,
}
}
</script>
================================================
FILE: docs/.vuepress/theme/package.json
================================================
{
"name": "vuepress-theme-dplayer",
"main": "index.js"
}
================================================
FILE: docs/README.md
================================================
---
home: true
actionText: Get Started →
actionLink: /guide/
footer: MIT Licensed | Made with love by DIYgod
---
<div>
<DPlayer :immediate="true"></DPlayer>
</div>
<div class="hero custom"><p class="action"><router-link to="/guide/" class="nav-link action-button">Get Started →</router-link></p></div>
================================================
FILE: docs/ecosystem.md
================================================
---
sidebar: auto
---
# Ecosystem
Let's make DPlayer better, feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
## Help
### Creating issue
- [MoePlayer/DPlayer/issues](https://github.com/MoePlayer/DPlayer/issues)
## Related Projects
### Tooling
- [DPlayer-thumbnails](https://github.com/MoePlayer/DPlayer-thumbnails): generate video thumbnails
### Danmaku api
- [DPlayer-node](https://github.com/MoePlayer/DPlayer-node): Node.js
- [laravel-danmaku](https://github.com/MoePlayer/laravel-danmaku): PHP
- [dplayer-live-backend](https://github.com/Izumi-kun/dplayer-live-backend): Node.js, WebSocket live backend
- [RailsGun](https://github.com/MoePlayer/RailsGun): Ruby
### Plugins
- [DPlayer-for-typecho](https://github.com/volio/DPlayer-for-typecho): Typecho
- [Hexo-tag-dplayer](https://github.com/NextMoe/hexo-tag-dplayer): Hexo
- [DPlayer_for_Z-BlogPHP](https://github.com/fghrsh/DPlayer_for_Z-BlogPHP): Z-BlogPHP
- [DPlayer for Discuz!](https://coding.net/u/Click_04/p/video/git): Discuz!
- [DPlayer for WordPress](https://github.com/BlueCocoa/DPlayer-WordPress): WordPress
- [DPlayerHandle](https://github.com/kn007/DPlayerHandle): WordPress
- [Selection](https://github.com/GreatSatan79/Selection): WordPress
- [Vue-DPlayer](https://github.com/sinchang/vue-dplayer): Vue
- [react-dplayer](https://github.com/hnsylitao/react-dplayer): React
- [rc-dplayer](https://github.com/tianfeng98/rc-dplayer): React
### Other
- [DPlayer-Lite](https://github.com/kn007/DPlayer-Lite): lite version
- [hlsjs-p2p-engine](https://github.com/cdnbye/hlsjs-p2p-engine)
## Who use DPlayer?
- [学习强国](https://itunes.apple.com/cn/app/%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD/id1426355645?mt=8): “学习强国”学习平台精心打造的手机客户端
- [小红书](https://www.xiaohongshu.com/): 中国最大的生活社区分享平台,同时也是发现全球好物的电商平台
- [极客时间](https://time.geekbang.org/): 极客邦科技出品的一款 IT 内容知识服务 App
- [嘀哩嘀哩](http://www.dilidili.wang/): 兴趣使然的无名小站(D 站)
- [银色子弹](https://www.sbsub.com/): 银色子弹,简称银弹,由多数柯南热爱者聚集在一起的组织
- [浙江大学 CC98 论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
- [纸飞机南航青年网络社区](http://my.nuaa.edu.cn/video-video.html): 南京航空航天大学门户网站
- [otomads](https://otomads.com/): 专注于音 MAD 的视频弹幕网站
- [Cloudreve](https://github.com/HFO4/Cloudreve): 基于 ThinkPHP 构建的网盘系统
- [arozos](https://github.com/tobychui/arozos): General purposed Web Desktop Operating Platform / OS for Raspberry Pis
- [新东方云教室](https://roombox.xdf.cn/)
- [BBHouse](https://github.com/endcloud/bbhouse-tauri): A Bilibili Cross-Platform Desktop Client Powered By Tauri
- [Tampermonkey 阿里云盘](https://greasyfork.org/zh-CN/scripts/425955-%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98)
- [arozos](https://github.com/tobychui/arozos)
- [GBCLStudio/fof-upload-qcloud](https://github.com/GBCLStudio/FoF-Upload-Qcloud)
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
## Contributors
This project exists thanks to all the people who contribute.
<a href="https://github.com/MoePlayer/DPlayer/graphs/contributors"><img src="https://opencollective.com/DPlayer/contributors.svg?width=890" /></a>
================================================
FILE: docs/guide.md
================================================
---
sidebar: auto
---
# Guide
# DPlayer
🍭 Wow, such a lovely HTML5 danmaku video player
<DPlayer :immediate="true"></DPlayer>
## Special Thanks
### Sponsors
<div>
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
<img height="60px" src="https://player.dogecloud.com/img/logo_with_product3.png">
</a>
</div>
## Installation
Using npm:
```
npm install dplayer --save
```
Using Yarn:
```
yarn add dplayer
```
## Quick Start
At first, let's initialize a simplest DPlayer
Load DPlayer files
```html
<div id="dplayer"></div>
<script src="DPlayer.min.js"></script>
```
Or work with module bundler:
```js
import DPlayer from 'dplayer';
const dp = new DPlayer(options);
```
Initialization in js:
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
screenshot: true,
video: {
url: 'demo.mp4',
pic: 'demo.jpg',
thumbnails: 'thumbnails.jpg',
},
subtitle: {
url: 'webvtt.vtt',
},
danmaku: {
id: 'demo',
api: 'https://api.prprpr.me/dplayer/',
},
});
```
## Options
You can custom your player instance by those options
| Name | Default | Description |
| -------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| container | document.querySelector('.dplayer') | player container |
| live | false | enable live mode, see [#live](#live) |
| autoplay | false | video autoplay |
| theme | '#b7daff' | main color |
| loop | false | video loop |
| lang | navigator.language.toLowerCase() | values: 'en', 'zh-cn', 'zh-tw' |
| screenshot | false | enable screenshot, if true, video and video poster must enable Cross-Origin |
| airplay | false | enable airplay in Safari |
| chromecast | false | enable Chromecast |
| hotkey | true | enable hotkey, support FF, FR, volume control, play & pause |
| preload | 'auto' | values: 'none', 'metadata', 'auto' |
| volume | 0.7 | default volume, notice that player will remember user setting, default volume will not work after user set volume themselves |
| playbackSpeed | [0.5, 0.75, 1, 1.25, 1.5, 2] | optional playback speed, or or you can set a custom one |
| logo | - | showing logo in the top left corner, you can adjust its size and position by CSS |
| apiBackend | - | getting and sending danmaku in your way, see [#live](#live) |
| preventClickToggle | false | prevent toggle video play/pause status when click player |
| video | - | video info |
| video.quality | - | see [#Quality switching](#quality-switching) |
| video.defaultQuality | - | see [#Quality switching](#quality-switching) |
| video.url | - | video url |
| video.pic | - | video poster |
| video.thumbnails | - | video thumbnails, generated by [DPlayer-thumbnails](https://github.com/MoePlayer/DPlayer-thumbnails) |
| video.type | 'auto' | values: 'auto', 'hls', 'flv', 'dash', 'webtorrent', 'normal' or other custom type, see [#MSE support](#mse-support) |
| video.customType | - | custom video type, see [#MSE support](#mse-support) |
| subtitle | - | external subtitle |
| subtitle.url | `required` | subtitle url |
| subtitle.type | 'webvtt' | subtitle type, values: 'webvtt', 'ass', but only webvtt is supported for now |
| subtitle.fontSize | '20px' | subtitle font size |
| subtitle.bottom | '40px' | the distance between the subtitle and player bottom, values like: '10px' '10%' |
| subtitle.color | '#fff' | subtitle color |
| danmaku | - | showing danmaku |
| danmaku.id | `required` | danmaku pool id, it must be unique |
| danmaku.api | `required` | see [#Danmaku API](#danmaku-api) |
| danmaku.token | - | back end verification token |
| danmaku.maximum | - | danmaku maximum quantity |
| danmaku.addition | - | additional danmaku, see [#bilibili danmaku](#bilibili-danmaku) |
| danmaku.user | 'DIYgod' | danmaku user name |
| danmaku.bottom | - | values like: '10px' '10%', the distance between the danmaku bottom and player bottom, in order to prevent warding off subtitle |
| danmaku.unlimited | false | display all danmaku even though danmaku overlap, notice that player will remember user setting, default setting will not work after user set it themselves |
| danmaku.speedRate | 1 | danmaku speed multiplier, the larger the faster |
| contextmenu | [] | custom contextmenu |
| highlight | [] | custom time markers upon progress bar |
| mutex | true | prevent to play multiple player at the same time, pause other players when this player start play |
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
autoplay: false,
theme: '#FADFA3',
loop: true,
lang: 'zh-cn',
screenshot: true,
hotkey: true,
preload: 'auto',
logo: 'logo.png',
volume: 0.7,
mutex: true,
video: {
url: 'dplayer.mp4',
pic: 'dplayer.png',
thumbnails: 'thumbnails.jpg',
type: 'auto',
},
subtitle: {
url: 'dplayer.vtt',
type: 'webvtt',
fontSize: '25px',
bottom: '10%',
color: '#b7daff',
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
token: 'tokendemo',
maximum: 1000,
addition: ['https://api.prprpr.me/dplayer/v3/bilibili?aid=4157142'],
user: 'DIYgod',
bottom: '15%',
unlimited: true,
speedRate: 0.5,
},
contextmenu: [
{
text: 'custom1',
link: 'https://github.com/DIYgod/DPlayer',
},
{
text: 'custom2',
click: (player) => {
console.log(player);
},
},
],
highlight: [
{
text: 'marker for 20s',
time: 20,
},
{
text: 'marker for 2mins',
time: 120,
},
],
});
```
## API
- `dp.play()`: play video
- `dp.pause()`: pause video
- `dp.seek(time: number)`: seek to specified time
```js
dp.seek(100);
```
- `dp.toggle()`: toggle between play and pause
- `dp.on(event: string, handler: function)`: bind video and player events, [see more details](https://dplayer.diygod.dev/guide.html#event-binding)
- `dp.switchVideo(video, danmaku)`: switch to a new video
```js
dp.switchVideo(
{
url: 'second.mp4',
pic: 'second.png',
thumbnails: 'second.jpg',
},
{
id: 'test',
api: 'https://api.prprpr.me/dplayer/',
maximum: 3000,
user: 'DIYgod',
}
);
```
- `dp.notice(text: string, time: number, opacity: number)`: show message, the unit of time is millisecond, the default of time is 2000, the default of opacity is 0.8
```js
dp.notice('Amazing player', 2000, 0.8);
```
- `dp.switchQuality(index: number)`: switch quality
- `dp.destroy()`: destroy player
- `dp.speed(rate: number)`: set video speed
- `dp.volume(percentage: number, nostorage: boolean, nonotice: boolean)`: set video volume
```js
dp.volume(0.1, true, false);
```
- `dp.video`: native video
- `dp.video.currentTime`: returns the current playback position
- `dp.video.duration`: returns video total time
- `dp.video.paused`: returns whether the video paused
- most [native api](http://www.w3schools.com/tags/ref_av_dom.asp) are supported
- `dp.danmaku`
- `dp.danmaku.send(danmaku, callback: function)`: submit a new danmaku to back end
```js
dp.danmaku.send(
{
text: 'dplayer is amazing',
color: '#b7daff',
type: 'right', // should be `top` `bottom` or `right`
},
function () {
console.log('success');
}
);
```
- `dp.danmaku.draw(danmaku)`: draw a new danmaku to player in real time
```js
dp.danmaku.draw({
text: 'DIYgod is amazing',
color: '#fff',
type: 'top',
});
```
- `dp.danmaku.opacity(percentage: number)`: set danmaku opacity, opacity should between 0 and 1
```js
dp.danmaku.opacity(0.5);
```
- `dp.danmaku.clear()`: clear all danmakus
- `dp.danmaku.hide()`: hide danmaku
- `dp.danmaku.show()`: show danmaku
- `dp.fullScreen`: two type: `web` or `browser`, the default one is `browser`
- `dp.fullScreen.request(type: string)`: request fullscreen
```js
dp.fullScreen.request('web');
```
- `dp.fullScreen.cancel(type: string)`: cancel fullscreen
```js
dp.fullScreen.cancel('web');
```
## Event binding
`dp.on(event, handler)`
```js
dp.on('ended', function () {
console.log('player ended');
});
```
Video events
- abort
- canplay
- canplaythrough
- durationchange
- emptied
- ended
- error
- loadeddata
- loadedmetadata
- loadstart
- mozaudioavailable
- pause
- play
- playing
- progress
- ratechange
- seeked
- seeking
- stalled
- suspend
- timeupdate
- volumechange
- waiting
Player events
- screenshot
- thumbnails_show
- thumbnails_hide
- danmaku_show
- danmaku_hide
- danmaku_clear
- danmaku_loaded
- danmaku_send
- danmaku_opacity
- contextmenu_show
- contextmenu_hide
- notice_show
- notice_hide
- quality_start
- quality_end
- destroy
- resize
- fullscreen
- fullscreen_cancel
- webfullscreen
- webfullscreen_cancel
- subtitle_show
- subtitle_hide
- subtitle_change
## Quality switching
Set video url and video type in `video.quality`, set default quality by `video.defaultQuality`.
<DPlayer :options="{
video: {
quality: [{
name: 'HD',
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}, {
name: 'SD',
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
type: 'normal'
}],
defaultQuality: 0,
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg'
}
}"></DPlayer>
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
quality: [
{
name: 'HD',
url: 'demo.m3u8',
type: 'hls',
},
{
name: 'SD',
url: 'demo.mp4',
type: 'normal',
},
],
defaultQuality: 0,
pic: 'demo.png',
thumbnails: 'thumbnails.jpg',
},
});
```
When using `customType` ([Work with other MSE library](#work-with-other-mse-library)), you should listen for the `destroy` and `quality_end` events to destroy the MSE library instance in a timely manner to avoid memory leaks.
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
quality: [
{
name: 'HD',
url: 'demo_hd.m3u8',
type: 'Hls',
},
{
name: 'SD',
url: 'demo_sd.m3u8',
type: 'Hls',
},
],
defaultQuality: 0,
customType: {
Hls: (video, player) => {
const hls = new window.Hls();
hls.loadSource(video.src);
hls.attachMedia(video);
hls.sessionId = crypto.randomUUID();
player.sessionId = hls.sessionId;
player.events.on('destroy', () => {
hls.destroy();
});
player.events.on('quality_end', () => {
if (hls.sessionId !== player.sessionId) {
hls.destroy();
}
});
},
},
},
});
```
## Danmaku
### Danmaku API
`danmaku.api`
<!-- **Ready-made API**
url: https://api.prprpr.me/dplayer/ -->
Daily backup data: [DPlayer-data](https://github.com/DIYgod/DPlayer-data)
**Setting up yourself**
[DPlayer-node](https://github.com/MoePlayer/DPlayer-node)
### bilibili danmaku
`danmaku.addition`
API: <https://api.prprpr.me/dplayer/v3/bilibili?aid=[aid]>
```js
const option = {
danmaku: {
// ...
addition: ['https://api.prprpr.me/dplayer/v3/bilibili?aid=[aid]'],
},
};
```
## MSE support
### HLS
It requires the library [hls.js](https://github.com/video-dev/hls.js) and it should be loaded before `DPlayer.min.js`.
<DPlayer :options="{
video: {
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="hls.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: 'hls',
},
pluginOptions: {
hls: {
// hls config
},
},
});
console.log(dp.plugins.hls); // Hls instance
```
```js
// another way, use customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: 'customHls',
customType: {
customHls: function (video, player) {
const hls = new Hls();
hls.loadSource(video.src);
hls.attachMedia(video);
},
},
},
});
```
### MPEG DASH
It requires the library [dash.js](https://github.com/Dash-Industry-Forum/dash.js) and it should be loaded before `DPlayer.min.js`.
```html
<div id="dplayer"></div>
<script src="dash.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.mpd',
type: 'dash',
},
pluginOptions: {
dash: {
// dash config
},
},
});
console.log(dp.plugins.dash); // Dash instance
```
```js
// another way, use customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.mpd',
type: 'customDash',
customType: {
customDash: function (video, player) {
dashjs.MediaPlayer().create().initialize(video, video.src, false);
},
},
},
});
```
### MPEG DASH (Shaka)
It requires the library [shaka-player](https://github.com/google/shaka-player) and it should be loaded before `DPlayer.min.js`.
```html
<div id="dplayer"></div>
<script src="shaka-player.compiled.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
screenshot: true,
video: {
url: 'demo.mpd',
type: 'shakaDash',
customType: {
shakaDash: function (video, player) {
var src = video.src;
var playerShaka = new shaka.Player(video); // 将会修改 video.src
playerShaka.load(src);
},
},
},
});
```
### FLV
It requires the library [flv.js](https://github.com/Bilibili/flv.js) and it should be loaded before `DPlayer.min.js`.
<DPlayer :options="{
video: {
url: 'https://api.dogecloud.com/player/get.flv?vcode=5ac682e6f8231991&userId=17&ext=.flv',
type: 'flv'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="flv.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.flv',
type: 'flv',
},
pluginOptions: {
flv: {
// refer to https://github.com/bilibili/flv.js/blob/master/docs/api.md#flvjscreateplayer
mediaDataSource: {
// mediaDataSource config
},
config: {
// config
},
},
},
});
console.log(dp.plugins.flv); // flv instance
```
```js
// another way, use customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.flv',
type: 'customFlv',
customType: {
customFlv: function (video, player) {
const flvPlayer = flvjs.createPlayer({
type: 'flv',
url: video.src,
});
flvPlayer.attachMediaElement(video);
flvPlayer.load();
},
},
},
});
```
### WebTorrent
It requires the library [webtorrent](https://github.com/webtorrent/webtorrent) and it should be loaded before `DPlayer.min.js`.
<DPlayer :options="{
video: {
url: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
type: 'webtorrent'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="webtorrent.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'magnet:demo',
type: 'webtorrent',
},
pluginOptions: {
webtorrent: {
// webtorrent config
},
},
});
console.log(dp.plugins.webtorrent); // WebTorrent instance
```
```js
// another way, use customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'magnet:demo',
type: 'customWebTorrent',
customType: {
customWebTorrent: function (video, player) {
player.container.classList.add('dplayer-loading');
const client = new WebTorrent();
const torrentId = video.src;
client.add(torrentId, (torrent) => {
const file = torrent.files.find((file) => file.name.endsWith('.mp4'));
file.renderTo(
video,
{
autoplay: player.options.autoplay,
},
() => {
player.container.classList.remove('dplayer-loading');
}
);
});
},
},
},
});
```
### Work with other MSE library
DPlayer can work with any MSE library via `customType` option.
```html
<div id="dplayer"></div>
<script src="https://cdn.jsdelivr.net/npm/cdnbye@latest"></script>
<script src="DPlayer.min.js"></script>
```
```js
var type = 'normal';
if (Hls.isSupported() && Hls.WEBRTC_SUPPORT) {
type = 'customHls';
}
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: type,
customType: {
customHls: function (video, player) {
const hls = new Hls({
debug: false,
// Other hlsjsConfig options provided by hls.js
p2pConfig: {
live: false,
// Other p2pConfig options provided by CDNBye http://www.cdnbye.com/en/
},
});
hls.loadSource(video.src);
hls.attachMedia(video);
},
},
},
});
```
## Live
You can use DPlayer in live, but if you want live danmaku, you should prepare a WebSocket backend yourself.
<DPlayer :options="{
live: true,
video: {
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}
}"></DPlayer>
Init player:
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
live: true,
danmaku: true,
apiBackend: {
read: function (options) {
console.log('Pretend to connect WebSocket');
options.success([]);
},
send: function (options) {
console.log('Pretend to send danmaku via WebSocket', options.data);
options.success();
},
},
video: {
url: 'demo.m3u8',
type: 'hls',
},
});
```
Draw danmaku after getting a danmaku via WebSocket:
```js
const danmaku = {
text: 'Get a danmaku via WebSocket',
color: '#fff',
type: 'right',
};
dp.danmaku.draw(danmaku);
```
## FAQ
### Why can't player be full screen?
If player is contained in a iframe, try adding the `allowfullscreen` attribute to the iframe.
For full browser support it should look like this:
```html
<iframe src="example.com" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen"></iframe>
```
### Why can't player autoplay in some mobile browsers?
Most mobile browsers forbid video autoplay, you wont be able to achieve it without hacks.
================================================
FILE: docs/package.json
================================================
{
"name": "docs",
"scripts": {
"docs:dev": "vuepress dev",
"docs:build": "vuepress build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@vuepress/plugin-back-to-top": "^1.9.10",
"@vuepress/plugin-google-analytics": "^1.9.10",
"vuepress": "^1.9.10",
"vuepress-plugin-umami": "^0.0.4"
}
}
================================================
FILE: docs/support.md
================================================
---
sidebar: auto
---
# Sponsor DPlayer Development
DPlayer is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
If you run a business and are using DPlayer in a revenue-generating product, it makes business sense to sponsor DPlayer development: it ensures the project that your product relies on stays healthy and actively maintained.
If you are an individual user and have enjoyed the productivity of using DPlayer, consider donating as a sign of appreciation - like buying me coffee once in a while :)
You can support DPlayer via donations.
### Recurring Donation
Recurring donors will be rewarded via express issue response, or even have your name displayed on our GitHub page and website.
- Become a Sponser on [GitHub](https://github.com/sponsors/DIYgod)
- Become a Sponser on [Patreon](https://www.patreon.com/DIYgod)
- Become a Sponser on [爱发电](https://afdian.net/@diygod)
- Contact us directly: i@diygod.me
### One-time Donation
We accept donations via the following ways:
- [WeChat Pay](https://diygod.me/images/wx.jpg)
- [Alipay](https://diygod.me/images/zfb.jpg)
- [Paypal](https://www.paypal.me/DIYgod)
## Sponsors
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
<img width="222px" src="hhttps://player.dogecloud.com/img/logo_with_product3.png">
</a>
## DPlayer contributors
This project exists thanks to all the people who contribute.
<a href="https://github.com/MoePlayer/DPlayer/graphs/contributors"><img src="https://opencollective.com/DPlayer/contributors.svg?width=890" /></a>
================================================
FILE: docs/zh/README.md
================================================
---
home: true
actionText: Get Started →
actionLink: /zh/guide/
footer: MIT Licensed | Made with love by DIYgod
---
<div>
<DPlayer :immediate="true"></DPlayer>
</div>
<div class="hero custom"><p class="action"><router-link to="/zh/guide/" class="nav-link action-button">快速上手 →</router-link></p></div>
================================================
FILE: docs/zh/ecosystem.md
================================================
---
sidebar: auto
---
# 生态
让 DPlayer 变得更好,请随意在 [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31) 提交你的项目和产品
## 帮助
### 提交 issue
- [MoePlayer/DPlayer/issues](https://github.com/MoePlayer/DPlayer/issues)
## 相关项目
### 工具
- [DPlayer-thumbnails](https://github.com/MoePlayer/DPlayer-thumbnails): generate video thumbnails
### 弹幕接口
- [DPlayer-node](https://github.com/MoePlayer/DPlayer-node): Node.js
- [laravel-danmaku](https://github.com/MoePlayer/laravel-danmaku): PHP
- [dplayer-live-backend](https://github.com/Izumi-kun/dplayer-live-backend): Node.js, WebSocket live backend
- [RailsGun](https://github.com/MoePlayer/RailsGun): Ruby
### 插件
- [DPlayer-for-typecho](https://github.com/volio/DPlayer-for-typecho): Typecho
- [Hexo-tag-dplayer](https://github.com/NextMoe/hexo-tag-dplayer): Hexo
- [DPlayer_for_Z-BlogPHP](https://github.com/fghrsh/DPlayer_for_Z-BlogPHP): Z-BlogPHP
- [DPlayer for Discuz!](https://coding.net/u/Click_04/p/video/git): Discuz!
- [DPlayer for WordPress](https://github.com/BlueCocoa/DPlayer-WordPress): WordPress
- [DPlayerHandle](https://github.com/kn007/DPlayerHandle): WordPress
- [Selection](https://github.com/GreatSatan79/Selection): WordPress
- [Vue-DPlayer](https://github.com/sinchang/vue-dplayer): Vue
- [react-dplayer](https://github.com/hnsylitao/react-dplayer): React
- [rc-dplayer](https://github.com/tianfeng98/rc-dplayer): React
### 其他
- [DPlayer-Lite](https://github.com/kn007/DPlayer-Lite): lite version
- [hlsjs-p2p-engine](https://github.com/cdnbye/hlsjs-p2p-engine)
## 谁在用 DPlayer?
- [学习强国](https://itunes.apple.com/cn/app/%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD/id1426355645?mt=8): “学习强国”学习平台精心打造的手机客户端
- [小红书](https://www.xiaohongshu.com/): 中国最大的生活社区分享平台,同时也是发现全球好物的电商平台
- [极客时间](https://time.geekbang.org/): 极客邦科技出品的一款 IT 内容知识服务 App
- [嘀哩嘀哩](http://www.dilidili.wang/): 兴趣使然的无名小站(D 站)
- [银色子弹](https://www.sbsub.com/): 银色子弹,简称银弹,由多数柯南热爱者聚集在一起的组织
- [浙江大学 CC98 论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
- [纸飞机南航青年网络社区](http://my.nuaa.edu.cn/video-video.html): 南京航空航天大学门户网站
- [otomads](https://otomads.com/): 专注于音 MAD 的视频弹幕网站
- [Cloudreve](https://github.com/HFO4/Cloudreve): 基于 ThinkPHP 构建的网盘系统
- [arozos](https://github.com/tobychui/arozos): General purposed Web Desktop Operating Platform / OS for Raspberry Pis
- [新东方云教室](https://roombox.xdf.cn/)
- [BBHouse](https://github.com/endcloud/bbhouse-tauri): A Bilibili Cross-Platform Desktop Client Powered By Tauri
- [Tampermonkey 阿里云盘](https://greasyfork.org/zh-CN/scripts/425955-%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98)
- [arozos](https://github.com/tobychui/arozos)
- [GBCLStudio/fof-upload-qcloud](https://github.com/GBCLStudio/FoF-Upload-Qcloud)
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31)
================================================
FILE: docs/zh/guide.md
================================================
---
sidebar: auto
---
# 指南
# DPlayer
🍭 Wow, such a lovely HTML5 danmaku video player
<DPlayer :immediate="true"></DPlayer>
## Special Thanks
### Sponsors
<div>
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
<img height="60px" src="https://player.dogecloud.com/img/logo_with_product3.png">
</a>
</div>
## 安装
使用 npm:
```
npm install dplayer --save
```
使用 Yarn:
```
yarn add dplayer
```
## 快速开始
我们先尝试初始化一个最简单的 DPlayer
加载播放器文件:
```html
<div id="dplayer"></div>
<script src="DPlayer.min.js"></script>
```
或者使用模块管理器:
```js
import DPlayer from 'dplayer';
const dp = new DPlayer(options);
```
在 js 里初始化:
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.mp4',
},
});
```
一个最简单的 DPlayer 就初始化好了,它只有最基本的视频播放功能
## 参数
DPlayer 有丰富的参数可以自定义你的播放器实例
| 名称 | 默认值 | 描述 |
| -------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------- |
| container | document.querySelector('.dplayer') | 播放器容器元素 |
| live | false | 开启直播模式, 见[#直播](#直播) |
| autoplay | false | 视频自动播放 |
| theme | '#b7daff' | 主题色 |
| loop | false | 视频循环播放 |
| lang | navigator.language.toLowerCase() | 可选值: 'en', 'zh-cn', 'zh-tw' |
| screenshot | false | 开启截图,如果开启,视频和视频封面需要允许跨域 |
| hotkey | true | 开启热键,支持快进、快退、音量控制、播放暂停 |
| airplay | false | 在 Safari 中开启 AirPlay |
| chromecast | false | 启用 Chromecast |
| preload | 'auto' | 视频预加载,可选值: 'none', 'metadata', 'auto' |
| volume | 0.7 | 默认音量,请注意播放器会记忆用户设置,用户手动设置音量后默认音量即失效 |
| playbackSpeed | [0.5, 0.75, 1, 1.25, 1.5, 2] | 可选的播放速率,可以设置成自定义的数组 |
| logo | - | 在左上角展示一个 logo,你可以通过 CSS 调整它的大小和位置 |
| apiBackend | - | 自定义获取和发送弹幕行为,见[#直播](#直播) |
| preventClickToggle | false | 阻止点击播放器时候自动切换播放/暂停 |
| video | - | 视频信息 |
| video.quality | - | 见[#清晰度切换](#清晰度切换) |
| video.defaultQuality | - | 见[#清晰度切换](#清晰度切换) |
| video.url | - | 视频链接 |
| video.pic | - | 视频封面 |
| video.thumbnails | - | 视频缩略图,可以使用 [DPlayer-thumbnails](https://github.com/MoePlayer/DPlayer-thumbnails) 生成 |
| video.type | 'auto' | 可选值: 'auto', 'hls', 'flv', 'dash', 'webtorrent', 'normal' 或其他自定义类型, 见[#MSE 支持](#mse-支持) |
| video.customType | - | 自定义类型, 见[#MSE 支持](#mse-支持) |
| subtitle | - | 外挂字幕 |
| subtitle.url | `required` | 字幕链接 |
| subtitle.type | 'webvtt' | 字幕类型,可选值: 'webvtt', 'ass',目前只支持 webvtt |
| subtitle.fontSize | '20px' | 字幕字号 |
| subtitle.bottom | '40px' | 字幕距离播放器底部的距离,取值形如: '10px' '10%' |
| subtitle.color | '#fff' | 字幕颜色 |
| danmaku | - | 显示弹幕 |
| danmaku.id | `required` | 弹幕池 id,必须唯一 |
| danmaku.api | `required` | 见[#弹幕接口](#弹幕接口) |
| danmaku.token | - | 弹幕后端验证 token |
| danmaku.maximum | - | 弹幕最大数量 |
| danmaku.addition | - | 额外外挂弹幕,见[#bilibili 弹幕](#bilibili-弹幕) |
| danmaku.user | 'DIYgod' | 弹幕用户名 |
| danmaku.bottom | - | 弹幕距离播放器底部的距离,防止遮挡字幕,取值形如: '10px' '10%' |
| danmaku.unlimited | false | 海量弹幕模式,即使重叠也展示全部弹幕,请注意播放器会记忆用户设置,用户手动设置后即失效 |
| danmaku.speedRate | 1 | 弹幕速度倍率,越大速度越快 |
| contextmenu | [] | 自定义右键菜单 |
| highlight | [] | 自定义进度条提示点 |
| mutex | true | 互斥,阻止多个播放器同时播放,当前播放器播放时暂停其他播放器 |
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
autoplay: false,
theme: '#FADFA3',
loop: true,
lang: 'zh-cn',
screenshot: true,
hotkey: true,
preload: 'auto',
logo: 'logo.png',
volume: 0.7,
mutex: true,
video: {
url: 'dplayer.mp4',
pic: 'dplayer.png',
thumbnails: 'thumbnails.jpg',
type: 'auto',
},
subtitle: {
url: 'dplayer.vtt',
type: 'webvtt',
fontSize: '25px',
bottom: '10%',
color: '#b7daff',
},
danmaku: {
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
token: 'tokendemo',
maximum: 1000,
addition: ['https://api.prprpr.me/dplayer/v3/bilibili?aid=4157142'],
user: 'DIYgod',
bottom: '15%',
unlimited: true,
speedRate: 0.5,
},
contextmenu: [
{
text: 'custom1',
link: 'https://github.com/DIYgod/DPlayer',
},
{
text: 'custom2',
click: (player) => {
console.log(player);
},
},
],
highlight: [
{
time: 20,
text: '这是第 20 秒',
},
{
time: 120,
text: '这是 2 分钟',
},
],
});
```
## API
- `dp.play()`: 播放视频
- `dp.pause()`: 暂停视频
- `dp.seek(time: number)`: 跳转到特定时间
```js
dp.seek(100);
```
- `dp.toggle()`: 切换播放和暂停
- `dp.on(event: string, handler: function)`: 绑定视频和播放器事件,见[#事件绑定](#事件绑定)
- `dp.switchVideo(video, danmaku)`: 切换到其他视频
```js
dp.switchVideo(
{
url: 'second.mp4',
pic: 'second.png',
thumbnails: 'second.jpg',
},
{
id: 'test',
api: 'https://api.prprpr.me/dplayer/',
maximum: 3000,
user: 'DIYgod',
}
);
```
- `dp.notice(text: string, time: number)`: 显示通知,时间的单位为毫秒,默认时间 2000 毫秒,默认透明度 0.8
- `dp.switchQuality(index: number)`: 切换清晰度
- `dp.destroy()`: 销毁播放器
- `dp.speed(rate: number)`: 设置视频速度
- `dp.volume(percentage: number, nostorage: boolean, nonotice: boolean)`: 设置视频音量
```js
dp.volume(0.1, true, false);
```
- `dp.video`: 原生 video
- `dp.video.currentTime`: 返回视频当前播放时间
- `dp.video.duration`: 返回视频总时间
- `dp.video.paused`: 返回视频是否暂停
- 支持大多数[原生 video 接口](http://www.w3schools.com/tags/ref_av_dom.asp)
- `dp.danmaku`
- `dp.danmaku.send(danmaku, callback: function)`: 提交一个新弹幕
```js
dp.danmaku.send(
{
text: 'dplayer is amazing',
color: '#b7daff',
type: 'right', // should be `top` `bottom` or `right`
},
function () {
console.log('success');
}
);
```
- `dp.danmaku.draw(danmaku)`: 实时绘制一个新弹幕
```js
dp.danmaku.draw({
text: 'DIYgod is amazing',
color: '#fff',
type: 'top',
});
```
- `dp.danmaku.opacity(percentage: number)`: 设置弹幕透明度,透明度值在 0 到 1 之间
```js
dp.danmaku.opacity(0.5);
```
- `dp.danmaku.clear()`: 清除所有弹幕
- `dp.danmaku.hide()`: 隐藏弹幕
- `dp.danmaku.show()`: 显示弹幕
- `dp.fullScreen`: 两个类型:`web` 和 `browser`,默认类型是 `browser`
- `dp.fullScreen.request(type: string)`: 进入全屏
```js
dp.fullScreen.request('web');
```
- `dp.fullScreen.cancel(type: string)`: 退出全屏
```js
dp.fullScreen.cancel('web');
```
## 事件绑定
`dp.on(event, handler)`
```js
dp.on('ended', function () {
console.log('player ended');
});
```
视频事件
- abort
- canplay
- canplaythrough
- durationchange
- emptied
- ended
- error
- loadeddata
- loadedmetadata
- loadstart
- mozaudioavailable
- pause
- play
- playing
- progress
- ratechange
- seeked
- seeking
- stalled
- suspend
- timeupdate
- volumechange
- waiting
播放器事件
- screenshot
- thumbnails_show
- thumbnails_hide
- danmaku_show
- danmaku_hide
- danmaku_clear
- danmaku_loaded
- danmaku_send
- danmaku_opacity
- contextmenu_show
- contextmenu_hide
- notice_show
- notice_hide
- quality_start
- quality_end
- destroy
- resize
- fullscreen
- fullscreen_cancel
- subtitle_show
- subtitle_hide
- subtitle_change
## 清晰度切换
在 `video.quality` 里设置不同清晰度的视频链接和类型,`video.defaultQuality` 设置默认清晰度
<DPlayer :options="{
video: {
quality: [{
name: 'HD',
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}, {
name: 'SD',
url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
type: 'normal'
}],
defaultQuality: 0,
pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg'
}
}"></DPlayer>
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
quality: [
{
name: 'HD',
url: 'demo.m3u8',
type: 'hls',
},
{
name: 'SD',
url: 'demo.mp4',
type: 'normal',
},
],
defaultQuality: 0,
pic: 'demo.png',
thumbnails: 'thumbnails.jpg',
},
});
```
在使用 `customType` [配合其他 MSE 库使用](#配合其他-mse-库使用)时,需要监听 `destroy` 和 `quality_end` 事件及时销毁 MSE 库实例,避免内存泄漏
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
quality: [
{
name: 'HD',
url: 'demo_hd.m3u8',
type: 'Hls',
},
{
name: 'SD',
url: 'demo_sd.m3u8',
type: 'Hls',
},
],
defaultQuality: 0,
customType: {
Hls: (video, player) => {
const hls = new window.Hls();
hls.loadSource(video.src);
hls.attachMedia(video);
hls.sessionId = crypto.randomUUID();
player.sessionId = hls.sessionId;
player.events.on('destroy', () => {
hls.destroy();
});
player.events.on('quality_end', () => {
if (hls.sessionId !== player.sessionId) {
hls.destroy();
}
});
},
},
},
});
```
## 弹幕
### 弹幕接口
`danmaku.api`
<!-- **现成的接口**
链接: https://api.prprpr.me/dplayer/ -->
每日备份: [DPlayer-data](https://github.com/DIYgod/DPlayer-data)
**自己搭建**
[DPlayer-node](https://github.com/MoePlayer/DPlayer-node)
### bilibili 弹幕
`danmaku.addition`
API: <https://api.prprpr.me/dplayer/v3/bilibili?aid=[aid]>
```js
const option = {
danmaku: {
// ...
addition: ['https://api.prprpr.me/dplayer/v3/bilibili?aid=[aid]'],
},
};
```
## MSE 支持
### HLS
需要在 `DPlayer.min.js` 前面加载 [hls.js](https://github.com/video-dev/hls.js)。
<DPlayer :options="{
video: {
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="hls.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: 'hls',
},
pluginOptions: {
hls: {
// hls config
},
},
});
console.log(dp.plugins.hls); // Hls 实例
```
```js
// 另一种方式,使用 customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: 'customHls',
customType: {
customHls: function (video, player) {
const hls = new Hls();
hls.loadSource(video.src);
hls.attachMedia(video);
},
},
},
});
```
### MPEG DASH
需要在 `DPlayer.min.js` 前面加载 [dash.js](https://github.com/Dash-Industry-Forum/dash.js)。
```html
<div id="dplayer"></div>
<script src="dash.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.mpd',
type: 'dash',
},
pluginOptions: {
dash: {
// dash config
},
},
});
console.log(dp.plugins.dash); // Dash 实例
```
```js
// 另一种方式,使用 customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.mpd',
type: 'customDash',
customType: {
customDash: function (video, player) {
dashjs.MediaPlayer().create().initialize(video, video.src, false);
},
},
},
});
```
### MPEG DASH (Shaka)
需要在 `DPlayer.min.js` 前面加载 [shaka-player.compiled.js](https://github.com/google/shaka-player)。
```html
<div id="dplayer"></div>
<script src="shaka-player.compiled.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
screenshot: true,
video: {
url: 'demo.mpd',
type: 'shakaDash',
customType: {
shakaDash: function (video, player) {
var src = video.src;
var playerShaka = new shaka.Player(video); // 将会修改 video.src
playerShaka.load(src);
},
},
},
});
```
### FLV
需要在 `DPlayer.min.js` 前面加载 [flv.js](https://github.com/Bilibili/flv.js)。
<DPlayer :options="{
video: {
url: 'https://api.dogecloud.com/player/get.flv?vcode=5ac682e6f8231991&userId=17&ext=.flv',
type: 'flv'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="flv.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.flv',
type: 'flv',
},
pluginOptions: {
flv: {
// refer to https://github.com/bilibili/flv.js/blob/master/docs/api.md#flvjscreateplayer
mediaDataSource: {
// mediaDataSource config
},
config: {
// config
},
},
},
});
console.log(dp.plugins.flv); // flv 实例
```
```js
// 另一种方式,使用 customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.flv',
type: 'customFlv',
customType: {
customFlv: function (video, player) {
const flvPlayer = flvjs.createPlayer({
type: 'flv',
url: video.src,
});
flvPlayer.attachMediaElement(video);
flvPlayer.load();
},
},
},
});
```
### WebTorrent
需要在 `DPlayer.min.js` 前面加载 [webtorrent](https://github.com/webtorrent/webtorrent)。
<DPlayer :options="{
video: {
url: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
type: 'webtorrent'
}
}"></DPlayer>
```html
<div id="dplayer"></div>
<script src="webtorrent.min.js"></script>
<script src="DPlayer.min.js"></script>
```
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'magnet:demo',
type: 'webtorrent',
},
pluginOptions: {
webtorrent: {
// webtorrent config
},
},
});
console.log(dp.plugins.webtorrent); // WebTorrent 实例
```
```js
// 另一种方式,使用 customType
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'magnet:demo',
type: 'customWebTorrent',
customType: {
customWebTorrent: function (video, player) {
player.container.classList.add('dplayer-loading');
const client = new WebTorrent();
const torrentId = video.src;
client.add(torrentId, (torrent) => {
const file = torrent.files.find((file) => file.name.endsWith('.mp4'));
file.renderTo(
video,
{
autoplay: player.options.autoplay,
},
() => {
player.container.classList.remove('dplayer-loading');
}
);
});
},
},
},
});
```
### 配合其他 MSE 库使用
DPlayer 可以通过 `customType` 参数与任何 MSE 库一起使用,例如支持 P2P 插件:
```html
<div id="dplayer"></div>
<script src="https://cdn.jsdelivr.net/npm/cdnbye@latest"></script>
<script src="DPlayer.min.js"></script>
```
```js
var type = 'normal';
if (Hls.isSupported() && Hls.WEBRTC_SUPPORT) {
type = 'customHls';
}
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: 'demo.m3u8',
type: type,
customType: {
customHls: function (video, player) {
const hls = new Hls({
debug: false,
// Other hlsjsConfig options provided by hls.js
p2pConfig: {
live: false, // 如果是直播设为true
// Other p2pConfig options provided by CDNBye http://www.cdnbye.com/cn/
},
});
hls.loadSource(video.src);
hls.attachMedia(video);
},
},
},
});
```
## 直播
你可以把 DPlayer 用在直播当中,但如果你想要直播弹幕,你需要自己准备一个 WebSocket 后端。
<DPlayer :options="{
live: true,
video: {
url: 'https://api.dogecloud.com/player/get.m3u8?vcode=5ac682e6f8231991&userId=17&ext=.m3u8',
type: 'hls'
}
}"></DPlayer>
初始化播放器:
```js
const dp = new DPlayer({
container: document.getElementById('dplayer'),
live: true,
danmaku: true,
apiBackend: {
read: function (options) {
console.log('Pretend to connect WebSocket');
options.success([]);
},
send: function (options) {
console.log('Pretend to send danmaku via WebSocket', options.data);
options.success();
},
},
video: {
url: 'demo.m3u8',
type: 'hls',
},
});
```
通过 WebSocket 获取到弹幕之后,通过 `dp.danmaku.draw` 绘制弹幕:
```js
const danmaku = {
text: 'Get a danmaku via WebSocket',
color: '#fff',
type: 'right',
};
dp.danmaku.draw(danmaku);
```
## 常见问题
### 为什么播放器不能全屏?
如果播放器被包含在 iframe 里,尝试在 iframe 上添加 `allowfullscreen` 属性。
为了完善的浏览器兼容性,它应该是这样:
```html
<iframe src="example.com" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen"></iframe>
```
### 为什么播放器不能在手机上自动播放?
大多数移动端浏览器禁止了视频自动播放。
================================================
FILE: docs/zh/support.md
================================================
---
sidebar: auto
---
# 赞助 DPlayer 的研发
DPlayer 是采用 MIT 许可的开源项目,使用完全免费。 但是随着项目规模的增长,也需要有相应的资金支持才能持续项目的维护的开发。
如果你是企业经营者并且将 DPlayer 用在商业产品中,那么赞助 DPlayer 有商业上的益处:可以让你的产品所依赖的框架保持健康并得到积极的维护。
如果你是个人开发者并且享受 DPlayer 带来的高开发效率,可以用捐助来表示你的谢意 —— 比如偶尔给我买杯咖啡 :)
你可以通过下列的方法来赞助 DPlayer 的开发.
## 周期性赞助
- 通过 [GitHub](https://github.com/sponsors/DIYgod) 赞助
- 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助
- 通过 [爱发电](https://afdian.net/@diygod) 赞助
- 给我们发邮件联系赞助事宜: <i@diygod.me>
## 一次性赞助
我们通过以下方式接受赞助:
- [微信支付](https://diygod.me/images/wx.jpg)
- [支付宝](https://diygod.me/images/zfb.jpg)
- [Paypal](https://www.paypal.me/DIYgod)
## 赞助商
<div>
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
<img height="60px" src="https://player.dogecloud.com/img/logo_with_product3.png">
</a>
</div>
## DPlayer 贡献者
感谢所有贡献者。
<a href="https://github.com/MoePlayer/DPlayer/graphs/contributors"><img src="https://opencollective.com/DPlayer/contributors.svg?width=890" /></a>
================================================
FILE: package.json
================================================
{
"name": "dplayer",
"version": "1.27.1",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"scripts": {
"start": "npm run dev",
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.config.js --progress",
"dev": "cross-env NODE_ENV=development webpack serve --config webpack/dev.config.js",
"test": "",
"format": "prettier \"**/*.{js,json,md}\" --write",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"prepare": "husky install"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
},
"files": [
"dist"
],
"repository": {
"url": "git+https://github.com/DIYgod/DPlayer.git",
"type": "git"
},
"keywords": [
"player",
"danmaku",
"video",
"html5"
],
"author": "DIYgod",
"license": "MIT",
"bugs": {
"url": "https://github.com/DIYgod/DPlayer/issues"
},
"homepage": "https://github.com/DIYgod/DPlayer#readme",
"devDependencies": {
"@babel/core": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@vuepress/plugin-pwa": "1.9.9",
"art-template": "4.13.2",
"art-template-loader": "1.4.3",
"autoprefixer": "^10.4.15",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.0",
"css-loader": "^6.8.1",
"cssnano": "^6.0.1",
"exports-loader": "^4.0.0",
"file-loader": "^6.0.0",
"git-revision-webpack-plugin": "^5.0.0",
"husky": "^8.0.3",
"less": "^4.2.0",
"less-loader": "^11.1.3",
"lint-staged": "^13.3.0",
"mini-css-extract-plugin": "2.7.6",
"postcss": "^8.4.27",
"postcss-loader": "^7.3.3",
"postcss-preset-env": "^9.1.1",
"prettier": "^3.0.1",
"prettier-check": "^2.0.0",
"pretty-quick": "^3.0.0",
"strip-loader": "^0.1.2",
"style-loader": "^3.3.3",
"svg-inline-loader": "0.8.2",
"template-string-optimize-loader": "^3.0.0",
"url-loader": "^4.1.0",
"webpack": "^5.88.2",
"webpack-cli": "5.1.4",
"webpack-dev-server": "^4.15.1",
"yorkie": "^2.0.0"
},
"dependencies": {
"axios": "1.4.0",
"balloon-css": "^1.0.3",
"promise-polyfill": "8.3.0"
}
}
================================================
FILE: src/css/balloon.less
================================================
@import '../../node_modules/balloon-css/balloon.css';
[data-balloon]:before {
display: none;
}
[data-balloon]:after {
padding: 0.3em 0.7em;
background: rgba(17, 17, 17, 0.7);
}
[data-balloon][data-balloon-pos="up"]:after {
margin-bottom: 0;
}
================================================
FILE: src/css/bezel.less
================================================
.dplayer-bezel {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
font-size: 22px;
color: #fff;
pointer-events: none;
.dplayer-bezel-icon {
position: absolute;
top: 50%;
left: 50%;
margin: -26px 0 0 -26px;
height: 52px;
width: 52px;
padding: 12px;
box-sizing: border-box;
background: rgba(0, 0, 0, .5);
border-radius: 50%;
opacity: 0;
pointer-events: none;
&.dplayer-bezel-transition {
animation: bezel-hide .5s linear;
}
@keyframes bezel-hide {
from {
opacity: 1;
transform: scale(1);
}
to {
opacity: 0;
transform: scale(2);
}
}
}
.dplayer-danloading {
position: absolute;
top: 50%;
margin-top: -7px;
width: 100%;
text-align: center;
font-size: 14px;
line-height: 14px;
animation: my-face 5s infinite ease-in-out;
}
.diplayer-loading-icon {
display: none;
position: absolute;
top: 50%;
left: 50%;
margin: -18px 0 0 -18px;
height: 36px;
width: 36px;
pointer-events: none;
.diplayer-loading-hide {
display: none;
}
.diplayer-loading-dot {
animation: diplayer-loading-dot-fade .8s ease infinite;
opacity: 0;
transform-origin: 4px 4px;
each(range(7), {
&.diplayer-loading-dot-@{value} {
animation-delay: (@value * 0.1s);
}
});
}
@keyframes diplayer-loading-dot-fade {
0% {
opacity: .7;
transform: scale(1.2, 1.2)
}
50% {
opacity: .25;
transform: scale(.9, .9)
}
to {
opacity: .25;
transform: scale(.85, .85)
}
}
}
}
================================================
FILE: src/css/controller.less
================================================
.dplayer-controller-mask {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom;
height: 98px;
width: 100%;
position: absolute;
bottom: 0;
transition: all 0.3s ease;
}
.dplayer-controller {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 41px;
padding: 0 20px;
user-select: none;
transition: all 0.3s ease;
&.dplayer-controller-comment {
.dplayer-icons {
display: none;
}
.dplayer-icons.dplayer-comment-box {
display: block;
}
}
.dplayer-bar-wrap {
padding: 5px 0;
cursor: pointer;
position: absolute;
bottom: 33px;
width: calc(100% - 40px);
height: 3px;
&:hover {
.dplayer-bar .dplayer-played .dplayer-thumb {
transform: scale(1);
}
.dplayer-highlight {
display: block;
width: 8px;
transform: translateX(-4px);
top: 4px;
height: 40%;
}
}
.dplayer-highlight {
z-index: 12;
position: absolute;
top: 5px;
width: 6px;
height: 20%;
border-radius: 6px;
background-color: #fff;
text-align: center;
transform: translateX(-3px);
transition: all .2s ease-in-out;
&:hover {
.dplayer-highlight-text {
display: block;
}
&~.dplayer-bar-preview {
opacity: 0;
}
&~.dplayer-bar-time {
opacity: 0;
}
}
.dplayer-highlight-text {
display: none;
position: absolute;
left: 50%;
top: -24px;
padding: 5px 8px;
background-color: rgba(0, 0, 0, .62);
color: #fff;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
transform: translateX(-50%);
}
}
.dplayer-bar-preview {
position: absolute;
background: #fff;
pointer-events: none;
display: none;
background-size: 16000px 100%;
}
.dplayer-bar-preview-canvas {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
pointer-events: none;
}
.dplayer-bar-time {
&.hidden {
opacity: 0;
}
position: absolute;
left: 0px;
top: -20px;
border-radius: 4px;
padding: 5px 7px;
background-color: rgba(0, 0, 0, 0.62);
color: #fff;
font-size: 12px;
text-align: center;
opacity: 1;
transition: opacity .1s ease-in-out;
word-wrap: normal;
word-break: normal;
z-index: 2;
pointer-events: none;
}
.dplayer-bar {
position: relative;
height: 3px;
width: 100%;
background: rgba(255, 255, 255, .2);
cursor: pointer;
.dplayer-loaded {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: rgba(255, 255, 255, .4);
height: 3px;
transition: all 0.5s ease;
will-change: width;
}
.dplayer-played {
position: absolute;
left: 0;
top: 0;
bottom: 0;
height: 3px;
will-change: width;
.dplayer-thumb {
position: absolute;
top: 0;
right: 5px;
margin-top: -4px;
margin-right: -10px;
height: 11px;
width: 11px;
border-radius: 50%;
cursor: pointer;
transition: all .3s ease-in-out;
transform: scale(0);
}
}
}
}
.dplayer-icons {
height: 38px;
position: absolute;
bottom: 0;
&.dplayer-comment-box {
display: none;
position: absolute;
transition: all .3s ease-in-out;
z-index: 2;
height: 38px;
bottom: 0;
left: 20px;
right: 20px;
color: #fff;
.dplayer-icon {
padding: 7px;
}
.dplayer-comment-setting-icon {
position: absolute;
left: 0;
top: 0;
}
.dplayer-send-icon {
position: absolute;
right: 0;
top: 0;
}
.dplayer-comment-setting-box {
position: absolute;
background: rgba(28, 28, 28, 0.9);
bottom: 41px;
left: 0;
box-shadow: 0 0 25px rgba(0, 0, 0, .3);
border-radius: 4px;
padding: 10px 10px 16px;
font-size: 14px;
width: 204px;
transition: all .3s ease-in-out;
transform: scale(0);
&.dplayer-comment-setting-open {
transform: scale(1);
}
input[type=radio] {
display: none;
}
label {
cursor: pointer;
}
.dplayer-comment-setting-title {
font-size: 13px;
color: #fff;
line-height: 30px;
}
.dplayer-comment-setting-type {
font-size: 0;
.dplayer-comment-setting-title {
margin-bottom: 6px;
}
label {
&:nth-child(2) {
span {
border-radius: 4px 0 0 4px;
}
}
&:nth-child(4) {
span {
border-radius: 0 4px 4px 0;
}
}
}
span {
width: 33%;
padding: 4px 6px;
line-height: 16px;
display: inline-block;
font-size: 12px;
color: #fff;
border: 1px solid #fff;
margin-right: -1px;
box-sizing: border-box;
text-align: center;
cursor: pointer;
}
input:checked+span {
background: #E4E4E6;
color: #1c1c1c;
}
}
.dplayer-comment-setting-color {
font-size: 0;
label {
font-size: 0;
padding: 6px;
display: inline-block;
}
span {
width: 22px;
height: 22px;
display: inline-block;
border-radius: 50%;
box-sizing: border-box;
cursor: pointer;
&:hover {
animation: my-face 5s infinite ease-in-out;
}
}
}
}
.dplayer-comment-input {
outline: none;
border: none;
padding: 8px 31px;
font-size: 14px;
line-height: 18px;
text-align: center;
border-radius: 4px;
background: none;
margin: 0;
height: 100%;
box-sizing: border-box;
width: 100%;
color: #fff;
&::placeholder {
color: #fff;
opacity: 0.8;
}
&::-ms-clear {
display: none;
}
}
}
&.dplayer-icons-left {
.dplayer-icon {
padding: 7px;
}
}
&.dplayer-icons-right {
right: 20px;
.dplayer-icon {
padding: 8px;
}
}
.dplayer-time,
.dplayer-live-badge {
line-height: 38px;
color: #eee;
text-shadow: 0 0 2px rgba(0, 0, 0, .5);
vertical-align: middle;
font-size: 13px;
cursor: default;
}
.dplayer-live-dot {
display: inline-block;
width: 6px;
height: 6px;
vertical-align: 4%;
margin-right: 5px;
content: '';
border-radius: 6px;
}
.dplayer-icon {
width: 40px;
height: 100%;
border: none;
background-color: transparent;
outline: none;
cursor: pointer;
vertical-align: middle;
box-sizing: border-box;
display: inline-block;
.dplayer-icon-content {
transition: all .2s ease-in-out;
opacity: .8;
}
&:hover {
.dplayer-icon-content {
opacity: 1;
}
}
&.dplayer-quality-icon {
color: #fff;
width: auto;
line-height: 22px;
font-size: 14px;
}
&.dplayer-comment-icon {
padding: 10px 9px 9px;
}
&.dplayer-setting-icon {
padding-top: 8.5px;
}
&.dplayer-volume-icon {
width: 43px;
}
}
.dplayer-volume {
position: relative;
display: inline-block;
cursor: pointer;
height: 100%;
&:hover {
.dplayer-volume-bar-wrap .dplayer-volume-bar {
width: 45px;
}
.dplayer-volume-bar-wrap .dplayer-volume-bar .dplayer-volume-bar-inner .dplayer-thumb {
transform: scale(1);
}
}
&.dplayer-volume-active {
.dplayer-volume-bar-wrap .dplayer-volume-bar {
width: 45px;
}
.dplayer-volume-bar-wrap .dplayer-volume-bar .dplayer-volume-bar-inner .dplayer-thumb {
transform: scale(1);
}
}
.dplayer-volume-bar-wrap {
display: inline-block;
margin: 0 10px 0 -5px;
vertical-align: middle;
height: 100%;
.dplayer-volume-bar {
position: relative;
top: 17px;
width: 0;
height: 3px;
background: #aaa;
transition: all 0.3s ease-in-out;
.dplayer-volume-bar-inner {
position: absolute;
bottom: 0;
left: 0;
height: 100%;
transition: all 0.1s ease;
will-change: width;
.dplayer-thumb {
position: absolute;
top: 0;
right: 5px;
margin-top: -4px;
margin-right: -10px;
height: 11px;
width: 11px;
border-radius: 50%;
cursor: pointer;
transition: all .3s ease-in-out;
transform: scale(0);
}
}
}
}
}
.dplayer-subtitle-btn {
display: inline-block;
height: 100%;
}
.dplayer-subtitles {
display: inline-block;
height: 100%;
.dplayer-subtitles-box {
position: absolute;
right: 0;
bottom: 50px;
transform: scale(0);
width: fit-content;
max-width: 240px;
min-width: 120px;
border-radius: 2px;
background: rgba(28, 28, 28, 0.9);
padding: 7px 0;
transition: all .3s ease-in-out;
overflow: auto;
z-index: 2;
&.dplayer-subtitles-panel {
display: block;
}
&.dplayer-subtitles-box-open {
transform: scale(1);
}
}
.dplayer-subtitles-item {
height: 30px;
padding: 5px 10px;
box-sizing: border-box;
cursor: pointer;
position: relative;
&:hover {
background-color: rgba(255, 255, 255, .1);
}
}
}
.dplayer-setting {
display: inline-block;
height: 100%;
.dplayer-setting-box {
position: absolute;
right: 0;
bottom: 50px;
transform: scale(0);
width: 150px;
border-radius: 2px;
background: rgba(28, 28, 28, 0.9);
padding: 7px 0;
transition: all .3s ease-in-out;
overflow: hidden;
z-index: 2;
&>div {
display: none;
&.dplayer-setting-origin-panel {
display: block;
}
}
&.dplayer-setting-box-open {
transform: scale(1);
}
&.dplayer-setting-box-narrow {
width: 70px;
text-align: center;
}
&.dplayer-setting-box-speed {
.dplayer-setting-origin-panel {
display: none;
}
.dplayer-setting-speed-panel {
display: block;
}
}
}
.dplayer-setting-item,
.dplayer-setting-speed-item {
height: 30px;
padding: 5px 10px;
box-sizing: border-box;
cursor: pointer;
position: relative;
&:hover {
background-color: rgba(255, 255, 255, .1);
}
}
.dplayer-setting-danmaku {
padding: 5px 0;
.dplayer-label {
padding: 0 10px;
display: inline;
}
&:hover {
.dplayer-label {
display: none;
}
.dplayer-danmaku-bar-wrap {
display: inline-block;
}
}
&.dplayer-setting-danmaku-active {
.dplayer-label {
display: none;
}
.dplayer-danmaku-bar-wrap {
display: inline-block;
}
}
.dplayer-danmaku-bar-wrap {
padding: 0 10px;
box-sizing: border-box;
display: none;
vertical-align: middle;
height: 100%;
width: 100%;
.dplayer-danmaku-bar {
position: relative;
top: 8.5px;
width: 100%;
height: 3px;
background: #fff;
transition: all 0.3s ease-in-out;
.dplayer-danmaku-bar-inner {
position: absolute;
bottom: 0;
left: 0;
height: 100%;
transition: all 0.1s ease;
background: #aaa;
will-change: width;
.dplayer-thumb {
position: absolute;
top: 0;
right: 5px;
margin-top: -4px;
margin-right: -10px;
height: 11px;
width: 11px;
border-radius: 50%;
cursor: pointer;
transition: all .3s ease-in-out;
background: #aaa;
}
}
}
}
}
}
.dplayer-full {
display: inline-block;
height: 100%;
position: relative;
&:hover {
.dplayer-full-in-icon {
display: block;
}
}
.dplayer-full-in-icon {
position: absolute;
top: -30px;
z-index: 1;
display: none;
}
}
.dplayer-quality {
position: relative;
display: inline-block;
height: 100%;
z-index: 2;
&:hover {
.dplayer-quality-list {
display: block;
}
.dplayer-quality-mask {
display: block;
}
}
.dplayer-quality-mask {
display: none;
position: absolute;
bottom: 38px;
left: -18px;
width: 80px;
padding-bottom: 12px;
}
.dplayer-quality-list {
display: none;
font-size: 12px;
width: 80px;
border-radius: 2px;
background: rgba(28, 28, 28, 0.9);
padding: 5px 0;
transition: all .3s ease-in-out;
overflow: hidden;
color: #fff;
text-align: center;
}
.dplayer-quality-item {
height: 25px;
box-sizing: border-box;
cursor: pointer;
line-height: 25px;
&:hover {
background-color: rgba(255, 255, 255, .1);
}
}
}
.dplayer-comment {
display: inline-block;
height: 100%;
}
.dplayer-label {
color: #eee;
font-size: 13px;
display: inline-block;
vertical-align: middle;
white-space: nowrap;
}
.dplayer-toggle {
width: 32px;
height: 20px;
text-align: center;
font-size: 0;
vertical-align: middle;
position: absolute;
top: 5px;
right: 10px;
input {
max-height: 0;
max-width: 0;
display: none;
}
input+label {
display: inline-block;
position: relative;
box-shadow: rgb(223, 223, 223) 0 0 0 0 inset;
border: 1px solid rgb(223, 223, 223);
height: 20px;
width: 32px;
border-radius: 10px;
box-sizing: border-box;
cursor: pointer;
transition: .2s ease-in-out;
}
input+label:before {
content: "";
position: absolute;
display: block;
height: 18px;
width: 18px;
top: 0;
left: 0;
border-radius: 15px;
transition: .2s ease-in-out;
}
input+label:after {
content: "";
position: absolute;
display: block;
left: 0;
top: 0;
border-radius: 15px;
background: #fff;
transition: .2s ease-in-out;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
height: 18px;
width: 18px;
}
input:checked+label {
border-color: rgba(255, 255, 255, 0.5);
}
input:checked+label:before {
width: 30px;
background: rgba(255, 255, 255, 0.5);
}
input:checked+label:after {
left: 12px;
}
}
}
}
.dplayer-mobile-play {
display: none;
width: 50px;
height: 50px;
border: none;
background-color: transparent;
outline: none;
cursor: pointer;
box-sizing: border-box;
position: absolute;
bottom: 0;
opacity: 0.8;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
================================================
FILE: src/css/danmaku.less
================================================
.dplayer-danmaku {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
font-size: 22px;
color: #fff;
.dplayer-danmaku-item {
display: inline-block;
pointer-events: none;
user-select: none;
cursor: default;
white-space: nowrap;
text-shadow: 0.5px 0.5px 0.5px rgba(0, 0, 0, 0.5);
&--demo {
position: absolute;
visibility: hidden;
}
}
.dplayer-danmaku-right {
position: absolute;
right: 0;
transform: translateX(100%);
&.dplayer-danmaku-move {
will-change: transform;
animation-name: danmaku;
animation-timing-function: linear;
animation-play-state: paused;
}
}
@keyframes danmaku {
from {
transform: translateX(100%);
}
}
.dplayer-danmaku-top,
.dplayer-danmaku-bottom {
position: absolute;
width: 100%;
text-align: center;
visibility: hidden;
&.dplayer-danmaku-move {
will-change: visibility;
animation-name: danmaku-center;
animation-timing-function: linear;
animation-play-state: paused;
}
}
@keyframes danmaku-center {
from {
visibility: visible;
}
to {
visibility: visible;
}
}
}
================================================
FILE: src/css/global.less
================================================
@keyframes my-face {
2% {
transform: translate(0, 1.5px) rotate(1.5deg);
}
4% {
transform: translate(0, -1.5px) rotate(-0.5deg);
}
6% {
transform: translate(0, 1.5px) rotate(-1.5deg);
}
8% {
transform: translate(0, -1.5px) rotate(-1.5deg);
}
10% {
transform: translate(0, 2.5px) rotate(1.5deg);
}
12% {
transform: translate(0, -0.5px) rotate(1.5deg);
}
14% {
transform: translate(0, -1.5px) rotate(1.5deg);
}
16% {
transform: translate(0, -0.5px) rotate(-1.5deg);
}
18% {
transform: translate(0, 0.5px) rotate(-1.5deg);
}
20% {
transform: translate(0, -1.5px) rotate(2.5deg);
}
22% {
transform: translate(0, 0.5px) rotate(-1.5deg);
}
24% {
transform: translate(0, 1.5px) rotate(1.5deg);
}
26% {
transform: translate(0, 0.5px) rotate(0.5deg);
}
28% {
transform: translate(0, 0.5px) rotate(1.5deg);
}
30% {
transform: translate(0, -0.5px) rotate(2.5deg);
}
32% {
transform: translate(0, 1.5px) rotate(-0.5deg);
}
34% {
transform: translate(0, 1.5px) rotate(-0.5deg);
}
36% {
transform: translate(0, -1.5px) rotate(2.5deg);
}
38% {
transform: translate(0, 1.5px) rotate(-1.5deg);
}
40% {
transform: translate(0, -0.5px) rotate(2.5deg);
}
42% {
transform: translate(0, 2.5px) rotate(-1.5deg);
}
44% {
transform: translate(0, 1.5px) rotate(0.5deg);
}
46% {
transform: translate(0, -1.5px) rotate(2.5deg);
}
48% {
transform: translate(0, -0.5px) rotate(0.5deg);
}
50% {
transform: translate(0, 0.5px) rotate(0.5deg);
}
52% {
transform: translate(0, 2.5px) rotate(2.5deg);
}
54% {
transform: translate(0, -1.5px) rotate(1.5deg);
}
56% {
transform: translate(0, 2.5px) rotate(2.5deg);
}
58% {
transform: translate(0, 0.5px) rotate(2.5deg);
}
60% {
transform: translate(0, 2.5px) rotate(2.5deg);
}
62% {
transform: translate(0, -0.5px) rotate(2.5deg);
}
64% {
transform: translate(0, -0.5px) rotate(1.5deg);
}
66% {
transform: translate(0, 1.5px) rotate(-0.5deg);
}
68% {
transform: translate(0, -1.5px) rotate(-0.5deg);
}
70% {
transform: translate(0, 1.5px) rotate(0.5deg);
}
72% {
transform: translate(0, 2.5px) rotate(1.5deg);
}
74% {
transform: translate(0, -0.5px) rotate(0.5deg);
}
76% {
transform: translate(0, -0.5px) rotate(2.5deg);
}
78% {
transform: translate(0, -0.5px) rotate(1.5deg);
}
80% {
transform: translate(0, 1.5px) rotate(1.5deg);
}
82% {
transform: translate(0, -0.5px) rotate(0.5deg);
}
84% {
transform: translate(0, 1.5px) rotate(2.5deg);
}
86% {
transform: translate(0, -1.5px) rotate(-1.5deg);
}
88% {
transform: translate(0, -0.5px) rotate(2.5deg);
}
90% {
transform: translate(0, 2.5px) rotate(-0.5deg);
}
92% {
transform: translate(0, 0.5px) rotate(-0.5deg);
}
94% {
transform: translate(0, 2.5px) rotate(0.5deg);
}
96% {
transform: translate(0, -0.5px) rotate(1.5deg);
}
98% {
transform: translate(0, -1.5px) rotate(-0.5deg);
}
0%,
100% {
transform: translate(0, 0) rotate(0deg);
}
}
================================================
FILE: src/css/index.less
================================================
@import './global';
@import './player';
@import './balloon';
@import './bezel';
@import './controller';
@import './danmaku';
@import './logo';
@import './menu';
@import './notice';
@import './subtitle';
@import './video';
@import './info-panel';
================================================
FILE: src/css/info-panel.less
================================================
.dplayer-info-panel {
position: absolute;
top: 10px;
left: 10px;
width: 400px;
background: rgba(28, 28, 28, 0.8);
padding: 10px;
color: #fff;
font-size: 12px;
border-radius: 2px;
&-hide {
display: none;
}
.dplayer-info-panel-close {
cursor: pointer;
position: absolute;
right: 10px;
top: 10px;
}
.dplayer-info-panel-item {
& > span {
display: inline-block;
vertical-align: middle;
line-height: 15px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
.dplayer-info-panel-item-title {
width: 100px;
text-align: right;
margin-right: 10px;
}
.dplayer-info-panel-item-data {
width: 260px;
}
}
================================================
FILE: src/css/logo.less
================================================
.dplayer-logo {
pointer-events: none;
position: absolute;
left: 20px;
top: 20px;
max-width: 50px;
max-height: 50px;
img {
max-width: 100%;
max-height: 100%;
background: none;
}
}
================================================
FILE: src/css/menu.less
================================================
.dplayer-menu {
position: absolute;
width: 170px;
border-radius: 2px;
background: rgba(28, 28, 28, 0.85);
padding: 5px 0;
overflow: hidden;
z-index: 3;
display: none;
&.dplayer-menu-show {
display: block;
}
.dplayer-menu-item {
height: 30px;
box-sizing: border-box;
cursor: pointer;
&:hover {
background-color: rgba(255, 255, 255, .1);
}
a {
display: inline-block;
padding: 0 10px;
line-height: 30px;
color: #eee;
font-size: 13px;
display: inline-block;
vertical-align: middle;
width: 100%;
box-sizing: border-box;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
&:hover {
text-decoration: none;
}
}
}
}
================================================
FILE: src/css/notice.less
================================================
.dplayer-notice-list{
position: absolute;
bottom: 60px;
left: 20px;
.dplayer-notice {
border-radius: 2px;
background: rgba(28, 28, 28, 0.9);
transition: all .3s ease-in-out;
overflow: hidden;
color: #fff;
display: table;
pointer-events: none;
animation: showNotice .3s ease 1 forwards;
}
.remove-notice{
animation: removeNotice .3s ease 1 forwards;
}
}
@keyframes showNotice {
from {
padding: 0;
font-size: 0;
margin-top: 0;
}
to {
padding: 7px 20px;
font-size: 14px;
margin-top: 5px;
}
}
@keyframes removeNotice {
0%{
padding: 7px 20px;
font-size: 14px;
margin-top: 5px;
}
20%{
font-size: 12px;
}
21%{
font-size: 0;
padding: 7px 10px;
}
100%{
padding: 0;
margin-top: 0;
font-size: 0;
}
}
================================================
FILE: src/css/player.less
================================================
.dplayer {
position: relative;
overflow: hidden;
user-select: none;
line-height: 1;
* {
box-sizing: content-box;
}
svg {
width: 100%;
height: 100%;
path,
circle {
fill: #fff;
}
}
&:-webkit-full-screen {
width: 100%;
height: 100%;
background: #000;
position: fixed;
z-index: 100000;
left: 0;
top: 0;
margin: 0;
padding: 0;
transform: translate(0, 0);
}
&.dplayer-no-danmaku {
.dplayer-controller .dplayer-icons .dplayer-setting .dplayer-setting-box {
.dplayer-setting-showdan,
.dplayer-setting-danmaku,
.dplayer-setting-danunlimit {
display: none;
}
}
.dplayer-controller .dplayer-icons .dplayer-comment {
display: none;
}
.dplayer-danmaku {
display: none;
}
}
&.dplayer-live {
.dplayer-time {
display: none;
}
.dplayer-bar-wrap {
display: none;
}
.dplayer-setting-speed {
display: none;
}
.dplayer-setting-loop {
display: none;
}
&.dplayer-no-danmaku {
.dplayer-setting {
display: none;
}
}
}
&.dplayer-arrow {
.dplayer-danmaku {
font-size: 18px;
}
.dplayer-icon {
margin: 0 -3px;
}
}
&.dplayer-playing {
.dplayer-danmaku .dplayer-danmaku-move {
animation-play-state: running;
}
@media (min-width: 900px) {
.dplayer-controller-mask {
opacity: 0;
}
.dplayer-controller {
opacity: 0;
}
&:hover {
.dplayer-controller-mask {
opacity: 1;
}
.dplayer-controller {
opacity: 1;
}
}
}
}
&.dplayer-loading {
.dplayer-bezel .diplayer-loading-icon {
display: block;
}
}
&.dplayer-loading,
&.dplayer-paused {
.dplayer-danmaku,
.dplayer-danmaku-move {
animation-play-state: paused;
}
}
&.dplayer-hide-controller {
cursor: none;
.dplayer-controller-mask {
opacity: 0;
transform: translateY(100%);
}
.dplayer-controller {
opacity: 0;
transform: translateY(100%);
}
}
&.dplayer-show-controller {
.dplayer-controller-mask {
opacity: 1;
}
.dplayer-controller {
opacity: 1;
}
}
&.dplayer-fulled {
position: fixed;
z-index: 100000;
left: 0;
top: 0;
width: 100% !important;
height: 100% !important;
}
&.dplayer-mobile {
.dplayer-controller .dplayer-icons {
.dplayer-volume,
.dplayer-camera-icon,
.dplayer-airplay-icon,
.dplayer-chromecast-icon,
.dplayer-play-icon {
display: none;
}
.dplayer-full .dplayer-full-in-icon {
position: static;
display: inline-block;
}
}
.dplayer-bar-time {
display: none;
}
&.dplayer-hide-controller {
.dplayer-mobile-play {
display: none;
}
}
.dplayer-mobile-play {
display: block;
}
}
}
// To hide scroll bar, apply this class to <body>
.dplayer-web-fullscreen-fix {
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
}
================================================
FILE: src/css/subtitle.less
================================================
.dplayer-subtitle {
position: absolute;
bottom: 40px;
width: 90%;
left: 5%;
text-align: center;
color: #fff;
text-shadow: 0.5px 0.5px 0.5px rgba(0, 0, 0, 0.5);
font-size: 20px;
&.dplayer-subtitle-hide {
display: none;
}
}
================================================
FILE: src/css/video.less
================================================
.dplayer-mask {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
display: none;
&.dplayer-mask-show {
display: block;
}
}
.dplayer-video-wrap {
position: relative;
background: #000;
font-size: 0;
width: 100%;
height: 100%;
.dplayer-video {
width: 100%;
height: 100%;
display: none;
}
.dplayer-video-current {
display: block;
}
.dplayer-video-prepare {
display: none;
}
}
================================================
FILE: src/js/api.js
================================================
import axios from 'axios';
export default {
send: (options) => {
axios
.post(options.url, options.data)
.then((response) => {
const data = response.data;
if (!data || data.code !== 0) {
options.error && options.error(data && data.msg);
return;
}
options.success && options.success(data);
})
.catch((e) => {
console.error(e);
options.error && options.error();
});
},
read: (options) => {
axios
.get(options.url)
.then((response) => {
const data = response.data;
if (!data || data.code !== 0) {
options.error && options.error(data && data.msg);
return;
}
options.success &&
options.success(
data.data.map((item) => ({
time: item[0],
type: item[1],
color: item[2],
author: item[3],
text: item[4],
}))
);
})
.catch((e) => {
console.error(e);
options.error && options.error();
});
},
};
================================================
FILE: src/js/bar.js
================================================
class Bar {
constructor(template) {
this.elements = {};
this.elements.volume = template.volumeBar;
this.elements.played = template.playedBar;
this.elements.loaded = template.loadedBar;
this.elements.danmaku = template.danmakuOpacityBar;
}
/**
* Update progress
*
* @param {String} type - Point out which bar it is
* @param {Number} percentage
* @param {String} direction - Point out the direction of this bar, Should be height or width
*/
set(type, percentage, direction) {
percentage = Math.max(percentage, 0);
percentage = Math.min(percentage, 1);
this.elements[type].style[direction] = percentage * 100 + '%';
}
get(type) {
return parseFloat(this.elements[type].style.width) / 100;
}
}
export default Bar;
================================================
FILE: src/js/bezel.js
================================================
class Bezel {
constructor(container) {
this.container = container;
this.container.addEventListener('animationend', () => {
this.container.classList.remove('dplayer-bezel-transition');
});
}
switch(icon) {
this.container.innerHTML = icon;
this.container.classList.add('dplayer-bezel-transition');
}
}
export default Bezel;
================================================
FILE: src/js/comment.js
================================================
import utils from './utils';
class Comment {
constructor(player) {
this.player = player;
this.player.template.mask.addEventListener('click', () => {
this.hide();
});
this.player.template.commentButton.addEventListener('click', () => {
this.show();
});
this.player.template.commentSettingButton.addEventListener('click', () => {
this.toggleSetting();
});
this.player.template.commentColorSettingBox.addEventListener('click', () => {
const sele = this.player.template.commentColorSettingBox.querySelector('input:checked+span');
if (sele) {
const color = this.player.template.commentColorSettingBox.querySelector('input:checked').value;
this.player.template.commentSettingFill.style.fill = color;
this.player.template.commentInput.style.color = color;
this.player.template.commentSendFill.style.fill = color;
}
});
this.player.template.commentInput.addEventListener('click', () => {
this.hideSetting();
});
this.player.template.commentInput.addEventListener('keydown', (e) => {
const event = e || window.event;
if (event.keyCode === 13) {
this.send();
}
});
this.player.template.commentSendButton.addEventListener('click', () => {
this.send();
});
}
show() {
this.player.controller.disableAutoHide = true;
this.player.template.controller.classList.add('dplayer-controller-comment');
this.player.template.mask.classList.add('dplayer-mask-show');
this.player.container.classList.add('dplayer-show-controller');
this.player.template.commentInput.focus();
}
hide() {
this.player.template.controller.classList.remove('dplayer-controller-comment');
this.player.template.mask.classList.remove('dplayer-mask-show');
this.player.container.classList.remove('dplayer-show-controller');
this.player.controller.disableAutoHide = false;
this.hideSetting();
}
showSetting() {
this.player.template.commentSettingBox.classList.add('dplayer-comment-setting-open');
}
hideSetting() {
this.player.template.commentSettingBox.classList.remove('dplayer-comment-setting-open');
}
toggleSetting() {
if (this.player.template.commentSettingBox.classList.contains('dplayer-comment-setting-open')) {
this.hideSetting();
} else {
this.showSetting();
}
}
send() {
this.player.template.commentInput.blur();
// text can't be empty
if (!this.player.template.commentInput.value.replace(/^\s+|\s+$/g, '')) {
this.player.notice(this.player.tran('please-input-danmaku'));
return;
}
this.player.danmaku.send(
{
text: this.player.template.commentInput.value,
color: utils.color2Number(this.player.container.querySelector('.dplayer-comment-setting-color input:checked').value),
type: parseInt(this.player.container.querySelector('.dplayer-comment-setting-type input:checked').value),
},
() => {
this.player.template.commentInput.value = '';
this.hide();
}
);
}
}
export default Comment;
================================================
FILE: src/js/contextmenu.js
================================================
class ContextMenu {
constructor(player) {
this.player = player;
this.shown = false;
Array.prototype.slice.call(this.player.template.menuItem).forEach((item, index) => {
if (this.player.options.contextmenu[index].click) {
item.addEventListener('click', () => {
this.player.options.contextmenu[index].click(this.player);
this.hide();
});
}
});
this.contextmenuHandler = (e) => {
if (this.shown) {
this.hide();
return;
}
const event = e || window.event;
event.preventDefault();
const clientRect = this.player.container.getBoundingClientRect();
this.show(event.clientX - clientRect.left, event.clientY - clientRect.top);
this.player.template.mask.addEventListener('click', () => {
this.hide();
});
};
this.player.container.addEventListener('contextmenu', this.contextmenuHandler);
}
show(x, y) {
this.player.template.menu.classList.add('dplayer-menu-show');
const clientRect = this.player.container.getBoundingClientRect();
if (x + this.player.template.menu.offsetWidth >= clientRect.width) {
this.player.template.menu.style.right = clientRect.width - x + 'px';
this.player.template.menu.style.left = 'initial';
} else {
this.player.template.menu.style.left = x + 'px';
this.player.template.menu.style.right = 'initial';
}
if (y + this.player.template.menu.offsetHeight >= clientRect.height) {
this.player.template.menu.style.bottom = clientRect.height - y + 'px';
this.player.template.menu.style.top = 'initial';
} else {
this.player.template.menu.style.top = y + 'px';
this.player.template.menu.style.bottom = 'initial';
}
this.player.template.mask.classList.add('dplayer-mask-show');
this.shown = true;
this.player.events.trigger('contextmenu_show');
}
hide() {
this.player.template.mask.classList.remove('dplayer-mask-show');
this.player.template.menu.classList.remove('dplayer-menu-show');
this.shown = false;
this.player.events.trigger('contextmenu_hide');
}
destroy() {
this.player.container.removeEventListener('contextmenu', this.contextmenuHandler);
}
}
export default ContextMenu;
================================================
FILE: src/js/controller.js
================================================
import utils from './utils';
import Thumbnails from './thumbnails';
import Icons from './icons';
let cast;
let runOnce = true;
let isCasting = false;
class Controller {
constructor(player) {
this.player = player;
this.autoHideTimer = 0;
if (!utils.isMobile) {
this.setAutoHideHandler = this.setAutoHide.bind(this);
this.player.container.addEventListener('mousemove', this.setAutoHideHandler);
this.player.container.addEventListener('click', this.setAutoHideHandler);
this.player.on('play', this.setAutoHideHandler);
this.player.on('pause', this.setAutoHideHandler);
}
this.initPlayButton();
this.initThumbnails();
this.initPlayedBar();
this.initFullButton();
this.initQualityButton();
this.initScreenshotButton();
// if subtitle url not array, not init old single subtitle button
if (this.player.options.subtitle) {
if (typeof this.player.options.subtitle.url === 'string') {
this.initSubtitleButton();
}
}
this.initHighlights();
this.initAirplayButton();
this.initChromecastButton();
if (!utils.isMobile) {
this.initVolumeButton();
}
}
initPlayButton() {
this.player.template.playButton.addEventListener('click', () => {
this.player.toggle();
});
this.player.template.mobilePlayButton.addEventListener('click', () => {
this.player.toggle();
});
if (!utils.isMobile) {
if (!this.player.options.preventClickToggle) {
this.player.template.videoWrap.addEventListener('click', () => {
this.player.toggle();
});
this.player.template.controllerMask.addEventListener('click', () => {
this.player.toggle();
});
}
} else {
this.player.template.videoWrap.addEventListener('click', () => {
this.toggle();
});
this.player.template.controllerMask.addEventListener('click', () => {
this.toggle();
});
}
}
initHighlights() {
this.player.on('durationchange', () => {
if (this.player.video.duration !== 1 && this.player.video.duration !== Infinity) {
if (this.player.options.highlight) {
const highlights = this.player.template.playedBarWrap.querySelectorAll('.dplayer-highlight');
[].slice.call(highlights, 0).forEach((item) => {
this.player.template.playedBarWrap.removeChild(item);
});
for (let i = 0; i < this.player.options.highlight.length; i++) {
if (!this.player.options.highlight[i].text || !this.player.options.highlight[i].time) {
continue;
}
const p = document.createElement('div');
p.classList.add('dplayer-highlight');
p.style.left = (this.player.options.highlight[i].time / this.player.video.duration) * 100 + '%';
p.innerHTML = '<span class="dplayer-highlight-text">' + this.player.options.highlight[i].text + '</span>';
this.player.template.playedBarWrap.insertBefore(p, this.player.template.playedBarTime);
}
}
}
});
}
initThumbnails() {
if (this.player.options.video.thumbnails) {
this.thumbnails = new Thumbnails({
container: this.player.template.barPreview,
barWidth: this.player.template.barWrap.offsetWidth,
url: this.player.options.video.thumbnails,
events: this.player.events,
});
this.player.on('loadedmetadata', () => {
this.thumbnails.resize(160, (this.player.video.videoHeight / this.player.video.videoWidth) * 160, this.player.template.barWrap.offsetWidth);
});
}
}
initPlayedBar() {
const thumbMove = (e) => {
let percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getBoundingClientRectViewLeft(this.player.template.playedBarWrap)) / this.player.template.playedBarWrap.clientWidth;
percentage = Math.max(percentage, 0);
percentage = Math.min(percentage, 1);
this.player.bar.set('played', percentage, 'width');
this.player.template.ptime.innerHTML = utils.secondToTime(percentage * this.player.video.duration);
};
const thumbUp = (e) => {
document.removeEventListener(utils.nameMap.dragEnd, thumbUp);
document.removeEventListener(utils.nameMap.dragMove, thumbMove);
let percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getBoundingClientRectViewLeft(this.player.template.playedBarWrap)) / this.player.template.playedBarWrap.clientWidth;
percentage = Math.max(percentage, 0);
percentage = Math.min(percentage, 1);
this.player.bar.set('played', percentage, 'width');
this.player.seek(this.player.bar.get('played') * this.player.video.duration);
this.player.moveBar = false;
};
this.player.template.playedBarWrap.addEventListener(utils.nameMap.dragStart, () => {
this.player.moveBar = true;
document.addEventListener(utils.nameMap.dragMove, thumbMove);
document.addEventListener(utils.nameMap.dragEnd, thumbUp);
});
this.player.template.playedBarWrap.addEventListener(utils.nameMap.dragMove, (e) => {
if (this.player.video.duration) {
const px = this.player.template.playedBarWrap.getBoundingClientRect().left;
const tx = (e.clientX || e.changedTouches[0].clientX) - px;
if (tx < 0 || tx > this.player.template.playedBarWrap.offsetWidth) {
return;
}
const time = this.player.video.duration * (tx / this.player.template.playedBarWrap.offsetWidth);
if (utils.isMobile) {
this.thumbnails && this.thumbnails.show();
}
this.thumbnails && this.thumbnails.move(tx);
this.player.template.playedBarTime.style.left = `${tx - (time >= 3600 ? 25 : 20)}px`;
this.player.template.playedBarTime.innerText = utils.secondToTime(time);
this.player.template.playedBarTime.classList.remove('hidden');
}
});
this.player.template.playedBarWrap.addEventListener(utils.nameMap.dragEnd, () => {
if (utils.isMobile) {
this.thumbnails && this.thumbnails.hide();
}
});
if (!utils.isMobile) {
this.player.template.playedBarWrap.addEventListener('mouseenter', () => {
if (this.player.video.duration) {
this.thumbnails && this.thumbnails.show();
this.player.template.playedBarTime.classList.remove('hidden');
}
});
this.player.template.playedBarWrap.addEventListener('mouseleave', () => {
if (this.player.video.duration) {
this.thumbnails && this.thumbnails.hide();
this.player.template.playedBarTime.classList.add('hidden');
}
});
}
}
initFullButton() {
this.player.template.browserFullButton.addEventListener('click', () => {
this.player.fullScreen.toggle('browser');
});
this.player.template.webFullButton.addEventListener('click', () => {
this.player.fullScreen.toggle('web');
});
}
initVolumeButton() {
const vWidth = 35;
const volumeMove = (event) => {
const e = event || window.event;
const percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap) - 5.5) / vWidth;
this.player.volume(percentage);
};
const volumeUp = () => {
document.removeEventListener(utils.nameMap.dragEnd, volumeUp);
document.removeEventListener(utils.nameMap.dragMove, volumeMove);
this.player.template.volumeButton.classList.remove('dplayer-volume-active');
};
this.player.template.volumeBarWrapWrap.addEventListener('click', (event) => {
const e = event || window.event;
const percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap) - 5.5) / vWidth;
this.player.volume(percentage);
});
this.player.template.volumeBarWrapWrap.addEventListener(utils.nameMap.dragStart, () => {
document.addEventListener(utils.nameMap.dragMove, volumeMove);
document.addEventListener(utils.nameMap.dragEnd, volumeUp);
this.player.template.volumeButton.classList.add('dplayer-volume-active');
});
this.player.template.volumeButtonIcon.addEventListener('click', () => {
if (this.player.video.muted) {
this.player.video.muted = false;
this.player.switchVolumeIcon();
this.player.bar.set('
gitextract_j1tz1t__/
├── .github/
│ ├── FUNDING.yml
│ └── ISSUE_TEMPLATE.md
├── .gitignore
├── .husky/
│ └── pre-commit
├── .prettierignore
├── .prettierrc
├── .travis.yml
├── LICENSE
├── README.md
├── demo/
│ ├── demo.css
│ ├── demo.js
│ ├── index.html
│ └── modernizr.js
├── docs/
│ ├── .vuepress/
│ │ ├── components/
│ │ │ └── DPlayer.vue
│ │ ├── config.js
│ │ ├── styles/
│ │ │ ├── index.styl
│ │ │ └── palette.styl
│ │ └── theme/
│ │ ├── components/
│ │ │ └── CarbonAds.vue
│ │ ├── index.js
│ │ ├── layouts/
│ │ │ └── Layout.vue
│ │ └── package.json
│ ├── README.md
│ ├── ecosystem.md
│ ├── guide.md
│ ├── package.json
│ ├── support.md
│ └── zh/
│ ├── README.md
│ ├── ecosystem.md
│ ├── guide.md
│ └── support.md
├── package.json
├── src/
│ ├── css/
│ │ ├── balloon.less
│ │ ├── bezel.less
│ │ ├── controller.less
│ │ ├── danmaku.less
│ │ ├── global.less
│ │ ├── index.less
│ │ ├── info-panel.less
│ │ ├── logo.less
│ │ ├── menu.less
│ │ ├── notice.less
│ │ ├── player.less
│ │ ├── subtitle.less
│ │ └── video.less
│ ├── js/
│ │ ├── api.js
│ │ ├── bar.js
│ │ ├── bezel.js
│ │ ├── comment.js
│ │ ├── contextmenu.js
│ │ ├── controller.js
│ │ ├── danmaku.js
│ │ ├── events.js
│ │ ├── fullscreen.js
│ │ ├── hotkey.js
│ │ ├── i18n.js
│ │ ├── icons.js
│ │ ├── index.js
│ │ ├── info-panel.js
│ │ ├── options.js
│ │ ├── player.js
│ │ ├── setting.js
│ │ ├── subtitle.js
│ │ ├── subtitles.js
│ │ ├── template.js
│ │ ├── thumbnails.js
│ │ ├── timer.js
│ │ ├── user.js
│ │ └── utils.js
│ └── template/
│ ├── player.art
│ └── video.art
├── tea.yaml
└── webpack/
├── dev.config.js
└── prod.config.js
SYMBOL INDEX (169 symbols across 22 files)
FILE: demo/demo.js
function animate (line 5) | function animate() {
function handleEvent (line 17) | function handleEvent() {
function initPlayers (line 38) | function initPlayers() {
function clearPlayers (line 259) | function clearPlayers() {
function switchDPlayer (line 266) | function switchDPlayer() {
FILE: demo/modernizr.js
function is (line 209) | function is(obj, type) {
function testRunner (line 220) | function testRunner() {
function setClasses (line 342) | function setClasses(classes) {
function createElement (line 382) | function createElement() {
function cssToDOM (line 566) | function cssToDOM(name) {
function contains (line 696) | function contains(str, substr) {
function fnBind (line 712) | function fnBind(fn, that) {
function testDOMProps (line 731) | function testDOMProps(props, obj, elem) {
function domToCSS (line 798) | function domToCSS(name) {
function computedStyle (line 817) | function computedStyle(elem, pseudo, prop) {
function getBody (line 853) | function getBody() {
function injectElementWithStyles (line 880) | function injectElementWithStyles(rule, callback, nodes, testnames) {
function nativeTestProps (line 956) | function nativeTestProps(props, value) {
function testProps (line 997) | function testProps(props, prefixed, value, skipValueTest) {
function testPropsAll (line 1093) | function testPropsAll(prop, prefixed, elem, value, skipValueTest) {
function testAllProps (line 1259) | function testAllProps(prop, value, skipValueTest) {
FILE: src/js/bar.js
class Bar (line 1) | class Bar {
method constructor (line 2) | constructor(template) {
method set (line 17) | set(type, percentage, direction) {
method get (line 23) | get(type) {
FILE: src/js/bezel.js
class Bezel (line 1) | class Bezel {
method constructor (line 2) | constructor(container) {
method switch (line 10) | switch(icon) {
FILE: src/js/comment.js
class Comment (line 3) | class Comment {
method constructor (line 4) | constructor(player) {
method show (line 42) | show() {
method hide (line 50) | hide() {
method showSetting (line 58) | showSetting() {
method hideSetting (line 62) | hideSetting() {
method toggleSetting (line 66) | toggleSetting() {
method send (line 74) | send() {
FILE: src/js/contextmenu.js
class ContextMenu (line 1) | class ContextMenu {
method constructor (line 2) | constructor(player) {
method show (line 34) | show(x, y) {
method hide (line 59) | hide() {
method destroy (line 67) | destroy() {
FILE: src/js/controller.js
class Controller (line 9) | class Controller {
method constructor (line 10) | constructor(player) {
method initPlayButton (line 42) | initPlayButton() {
method initHighlights (line 70) | initHighlights() {
method initThumbnails (line 93) | initThumbnails() {
method initPlayedBar (line 108) | initPlayedBar() {
method initFullButton (line 175) | initFullButton() {
method initVolumeButton (line 185) | initVolumeButton() {
method initQualityButton (line 222) | initQualityButton() {
method initScreenshotButton (line 232) | initScreenshotButton() {
method initAirplayButton (line 257) | initAirplayButton() {
method initChromecast (line 286) | initChromecast() {
method initChromecastButton (line 310) | initChromecastButton() {
method initSubtitleButton (line 366) | initSubtitleButton() {
method setAutoHide (line 383) | setAutoHide() {
method show (line 393) | show() {
method hide (line 397) | hide() {
method isShow (line 403) | isShow() {
method toggle (line 407) | toggle() {
method destroy (line 415) | destroy() {
FILE: src/js/danmaku.js
class Danmaku (line 3) | class Danmaku {
method constructor (line 4) | constructor(options) {
method load (line 24) | load() {
method reload (line 47) | reload(newAPI) {
method _readAllEndpoints (line 57) | _readAllEndpoints(endpoints, callback) {
method send (line 85) | send(dan, callback) {
method frame (line 117) | frame() {
method opacity (line 132) | opacity(percentage) {
method draw (line 153) | draw(dan) {
method play (line 271) | play() {
method pause (line 275) | pause() {
method _measure (line 279) | _measure(text) {
method seek (line 288) | seek() {
method clear (line 299) | clear() {
method htmlEncode (line 311) | htmlEncode(str) {
method resize (line 315) | resize() {
method hide (line 323) | hide() {
method show (line 331) | show() {
method unlimit (line 339) | unlimit(boolean) {
method speed (line 343) | speed(rate) {
method _danAnimation (line 347) | _danAnimation(position) {
FILE: src/js/events.js
class Events (line 1) | class Events {
method constructor (line 2) | constructor() {
method on (line 58) | on(name, callback) {
method trigger (line 67) | trigger(name, info) {
method type (line 75) | type(name) {
FILE: src/js/fullscreen.js
class FullScreen (line 3) | class FullScreen {
method constructor (line 4) | constructor(player) {
method isFullScreen (line 48) | isFullScreen(type = 'browser') {
method request (line 57) | request(type = 'browser') {
method cancel (line 93) | cancel(type = 'browser') {
method toggle (line 118) | toggle(type = 'browser') {
method destroy (line 126) | destroy() {
FILE: src/js/hotkey.js
class HotKey (line 1) | class HotKey {
method constructor (line 2) | constructor(player) {
method doHotKey (line 13) | doHotKey(e) {
method cancelFullScreen (line 56) | cancelFullScreen(e) {
method destroy (line 67) | destroy() {
FILE: src/js/i18n.js
function i18n (line 10) | function i18n(lang) {
FILE: src/js/info-panel.js
class InfoPanel (line 3) | class InfoPanel {
method constructor (line 4) | constructor(player) {
method show (line 15) | show() {
method hide (line 23) | hide() {
method triggle (line 29) | triggle() {
method update (line 37) | update() {
method fps (line 50) | fps(value) {
FILE: src/js/player.js
class DPlayer (line 28) | class DPlayer {
method constructor (line 35) | constructor(options) {
method seek (line 194) | seek(time) {
method play (line 218) | play(fromNative) {
method pause (line 253) | pause(fromNative) {
method switchVolumeIcon (line 274) | switchVolumeIcon() {
method volume (line 287) | volume(percentage, nostorage, nonotice) {
method toggle (line 315) | toggle() {
method on (line 326) | on(name, callback) {
method switchVideo (line 336) | switchVideo(video, danmakuAPI) {
method initMSE (line 360) | initMSE(video, type) {
method initVideo (line 515) | initVideo(video, type) {
method switchQuality (line 601) | switchQuality(index) {
method notice (line 673) | notice(text, time = 2000, opacity = 0.8, id) {
method resize (line 710) | resize() {
method speed (line 720) | speed(rate) {
method destroy (line 724) | destroy() {
method version (line 739) | static get version() {
FILE: src/js/setting.js
class Setting (line 3) | class Setting {
method constructor (line 4) | constructor(player) {
method hide (line 111) | hide() {
method show (line 122) | show() {
FILE: src/js/subtitle.js
class Subtitle (line 1) | class Subtitle {
method constructor (line 2) | constructor(container, video, options, events) {
method init (line 11) | init() {
method show (line 36) | show() {
method hide (line 41) | hide() {
method toggle (line 46) | toggle() {
FILE: src/js/subtitles.js
class Subtitles (line 1) | class Subtitles {
method constructor (line 2) | constructor(player) {
method subContainerShow (line 44) | subContainerShow() {
method subContainerHide (line 49) | subContainerHide() {
method hide (line 54) | hide() {
method show (line 60) | show() {
method adaptiveHeight (line 66) | adaptiveHeight() {
FILE: src/js/template.js
class Template (line 5) | class Template {
method constructor (line 6) | constructor(options) {
method init (line 14) | init() {
method NewNotice (line 109) | static NewNotice(text, opacity, id) {
FILE: src/js/thumbnails.js
class Thumbnails (line 1) | class Thumbnails {
method constructor (line 2) | constructor(options) {
method resize (line 9) | resize(width, height, barWrapWidth) {
method show (line 16) | show() {
method move (line 21) | move(position) {
method hide (line 26) | hide() {
FILE: src/js/timer.js
class Timer (line 1) | class Timer {
method constructor (line 2) | constructor(player) {
method init (line 20) | init() {
method initloadingChecker (line 29) | initloadingChecker() {
method initfpsChecker (line 50) | initfpsChecker() {
method initinfoChecker (line 73) | initinfoChecker() {
method enable (line 81) | enable(type) {
method disable (line 89) | disable(type) {
method destroy (line 93) | destroy() {
FILE: src/js/user.js
class User (line 3) | class User {
method constructor (line 4) | constructor(player) {
method init (line 24) | init() {
method get (line 31) | get(key) {
method set (line 35) | set(key, value) {
FILE: src/js/utils.js
method getBoundingClientRectViewLeft (line 52) | getBoundingClientRectViewLeft(element) {
method getScrollPosition (line 74) | getScrollPosition() {
method setScrollPosition (line 81) | setScrollPosition({ left = 0, top = 0 }) {
Condensed preview — 73 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (334K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 63,
"preview": "# These are supported funding model platforms\n\npatreon: DIYgod\n"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 436,
"preview": "中文用户请注意:请尽量用**英文**描述你的 issue,这样能够让尽可能多的人帮到你。\n\nIf you want to report a bug, please provide the following information:\n\n- "
},
{
"path": ".gitignore",
"chars": 107,
"preview": ".idea\nnode_modules\ndemo2\ndocs2\nnpm-debug.log\nDPlayer.log*\nwxw\n.vscode\npackage-lock.json\ndocs/.vuepress/dist"
},
{
"path": ".husky/pre-commit",
"chars": 75,
"preview": "#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\npnpm exec lint-staged\n"
},
{
"path": ".prettierignore",
"chars": 9,
"preview": "dist\ndemo"
},
{
"path": ".prettierrc",
"chars": 127,
"preview": "{\n \"printWidth\": 233,\n \"tabWidth\": 4,\n \"singleQuote\": true,\n \"trailingComma\": \"es5\",\n \"arrowParens\": \"alw"
},
{
"path": ".travis.yml",
"chars": 318,
"preview": "language: node_js\nnode_js:\n - lts/*\nscript:\n - npm run build\n - npm run docs:build\ndeploy:\n provider: pages\n skip-c"
},
{
"path": "LICENSE",
"chars": 1121,
"preview": "The MIT License (MIT)\n\nCopyright (c) DIYgod <diy.d.god@gmail.com> (https://www.anotherhome.net/)\n\nPermission is hereby g"
},
{
"path": "README.md",
"chars": 6163,
"preview": "<p align=\"center\">\n<img src=\"https://i.imgur.com/LnPvZvO.png\" alt=\"ADPlayer\" width=\"100\">\n</p>\n<h1 align=\"center\">DPlaye"
},
{
"path": "demo/demo.css",
"chars": 4288,
"preview": "body {\n max-width: 700px;\n margin: 0 auto;\n padding: 45px 10px;\n position: relative;\n}\n\n.show-dialog {\n c"
},
{
"path": "demo/demo.js",
"chars": 10391,
"preview": "// stats.js: JavaScript Performance Monitor\nconst stats = new Stats();\nstats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: "
},
{
"path": "demo/index.html",
"chars": 3058,
"preview": "<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset=\"UTF-8\">\n <title>DPlayer Demo</title>\n <meta name=\"viewport\" cont"
},
{
"path": "demo/modernizr.js",
"chars": 40102,
"preview": "/*!\n * modernizr v3.5.0\n * Build https://modernizr.com/download?-adownload-canvas-cssanimations-csstransforms-documentfr"
},
{
"path": "docs/.vuepress/components/DPlayer.vue",
"chars": 2934,
"preview": "<template>\n<div class=\"dplayer-wrap\">\n <div class=\"dplayer\" ref=\"dplayer\"><button class=\"load\" v-on:click=\"load\">Load"
},
{
"path": "docs/.vuepress/config.js",
"chars": 2584,
"preview": "module.exports = {\n plugins: {\n '@vuepress/back-to-top': true,\n umami: {\n trackerUrl: 'https"
},
{
"path": "docs/.vuepress/styles/index.styl",
"chars": 612,
"preview": ".navbar .home-link .site-name {\n color: #F5712C;\n}\n\n.page .custom-block.tip {\n border-color: #F5712C;\n}\n\n.icon.out"
},
{
"path": "docs/.vuepress/styles/palette.styl",
"chars": 23,
"preview": "$accentColor = #F5712C\n"
},
{
"path": "docs/.vuepress/theme/components/CarbonAds.vue",
"chars": 1274,
"preview": "<script>\nexport default {\n name: 'CarbonAds',\n\n watch: {\n '$route' (to, from) {\n if (\n to.path !== from"
},
{
"path": "docs/.vuepress/theme/index.js",
"chars": 61,
"preview": "module.exports = {\n extend: '@vuepress/theme-default',\n};\n"
},
{
"path": "docs/.vuepress/theme/layouts/Layout.vue",
"chars": 350,
"preview": "<template>\n <ParentLayout>\n <template #sidebar-top>\n <CarbonAds />\n </template>\n </ParentLayout>\n</template"
},
{
"path": "docs/.vuepress/theme/package.json",
"chars": 65,
"preview": "{\n \"name\": \"vuepress-theme-dplayer\",\n \"main\": \"index.js\"\n}\n"
},
{
"path": "docs/README.md",
"chars": 306,
"preview": "---\nhome: true\nactionText: Get Started →\nactionLink: /guide/\nfooter: MIT Licensed | Made with love by DIYgod\n---\n\n<div>\n"
},
{
"path": "docs/ecosystem.md",
"chars": 3187,
"preview": "---\nsidebar: auto\n---\n\n# Ecosystem\n\nLet's make DPlayer better, feel free to submit yours in [`Let me know!`](https://git"
},
{
"path": "docs/guide.md",
"chars": 27929,
"preview": "---\nsidebar: auto\n---\n\n# Guide\n\n# DPlayer\n\n🍭 Wow, such a lovely HTML5 danmaku video player\n\n<DPlayer :immediate=\"true\"><"
},
{
"path": "docs/package.json",
"chars": 374,
"preview": "{\n \"name\": \"docs\",\n \"scripts\": {\n \"docs:dev\": \"vuepress dev\",\n \"docs:build\": \"vuepress build\"\n },"
},
{
"path": "docs/support.md",
"chars": 1705,
"preview": "---\nsidebar: auto\n---\n\n# Sponsor DPlayer Development\n\nDPlayer is an MIT licensed open source project and completely free"
},
{
"path": "docs/zh/README.md",
"chars": 305,
"preview": "---\nhome: true\nactionText: Get Started →\nactionLink: /zh/guide/\nfooter: MIT Licensed | Made with love by DIYgod\n---\n\n<di"
},
{
"path": "docs/zh/ecosystem.md",
"chars": 2883,
"preview": "---\nsidebar: auto\n---\n\n# 生态\n\n让 DPlayer 变得更好,请随意在 [`Let me know!`](https://github.com/MoePlayer/DPlayer/issues/31) 提交你的项目"
},
{
"path": "docs/zh/guide.md",
"chars": 23391,
"preview": "---\nsidebar: auto\n---\n\n# 指南\n\n# DPlayer\n\n🍭 Wow, such a lovely HTML5 danmaku video player\n\n<DPlayer :immediate=\"true\"></DP"
},
{
"path": "docs/zh/support.md",
"chars": 982,
"preview": "---\nsidebar: auto\n---\n\n# 赞助 DPlayer 的研发\n\nDPlayer 是采用 MIT 许可的开源项目,使用完全免费。 但是随着项目规模的增长,也需要有相应的资金支持才能持续项目的维护的开发。\n\n如果你是企业经营者"
},
{
"path": "package.json",
"chars": 2431,
"preview": "{\n \"name\": \"dplayer\",\n \"version\": \"1.27.1\",\n \"description\": \"Wow, such a lovely HTML5 danmaku video player\",\n "
},
{
"path": "src/css/balloon.less",
"chars": 261,
"preview": "@import '../../node_modules/balloon-css/balloon.css';\n\n[data-balloon]:before {\n display: none;\n}\n\n[data-balloon]:afte"
},
{
"path": "src/css/bezel.less",
"chars": 2097,
"preview": ".dplayer-bezel {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n font-size: 22px;\n "
},
{
"path": "src/css/controller.less",
"chars": 22486,
"preview": ".dplayer-controller-mask {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdkl"
},
{
"path": "src/css/danmaku.less",
"chars": 1416,
"preview": ".dplayer-danmaku {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n font-size: 22px;\n "
},
{
"path": "src/css/global.less",
"chars": 3610,
"preview": "@keyframes my-face {\n 2% {\n transform: translate(0, 1.5px) rotate(1.5deg);\n }\n 4% {\n transform: t"
},
{
"path": "src/css/index.less",
"chars": 245,
"preview": "@import './global';\n@import './player';\n@import './balloon';\n@import './bezel';\n@import './controller';\n@import './danma"
},
{
"path": "src/css/info-panel.less",
"chars": 850,
"preview": ".dplayer-info-panel {\n position: absolute;\n top: 10px;\n left: 10px;\n width: 400px;\n background: rgba(28, "
},
{
"path": "src/css/logo.less",
"chars": 234,
"preview": ".dplayer-logo {\n pointer-events: none;\n position: absolute;\n left: 20px;\n top: 20px;\n max-width: 50px;\n "
},
{
"path": "src/css/menu.less",
"chars": 927,
"preview": ".dplayer-menu {\n position: absolute;\n width: 170px;\n border-radius: 2px;\n background: rgba(28, 28, 28, 0.85)"
},
{
"path": "src/css/notice.less",
"chars": 961,
"preview": ".dplayer-notice-list{\n position: absolute;\n bottom: 60px;\n left: 20px;\n\n .dplayer-notice {\n border-ra"
},
{
"path": "src/css/player.less",
"chars": 3888,
"preview": ".dplayer {\n position: relative;\n overflow: hidden;\n user-select: none;\n line-height: 1;\n\n * {\n box"
},
{
"path": "src/css/subtitle.less",
"chars": 269,
"preview": ".dplayer-subtitle {\n position: absolute;\n bottom: 40px;\n width: 90%;\n left: 5%;\n text-align: center;\n "
},
{
"path": "src/css/video.less",
"chars": 520,
"preview": ".dplayer-mask {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n z-index: 1;\n displa"
},
{
"path": "src/js/api.js",
"chars": 1436,
"preview": "import axios from 'axios';\n\nexport default {\n send: (options) => {\n axios\n .post(options.url, optio"
},
{
"path": "src/js/bar.js",
"chars": 842,
"preview": "class Bar {\n constructor(template) {\n this.elements = {};\n this.elements.volume = template.volumeBar;\n "
},
{
"path": "src/js/bezel.js",
"chars": 393,
"preview": "class Bezel {\n constructor(container) {\n this.container = container;\n\n this.container.addEventListener("
},
{
"path": "src/js/comment.js",
"chars": 3489,
"preview": "import utils from './utils';\n\nclass Comment {\n constructor(player) {\n this.player = player;\n\n this.play"
},
{
"path": "src/js/contextmenu.js",
"chars": 2553,
"preview": "class ContextMenu {\n constructor(player) {\n this.player = player;\n this.shown = false;\n\n Array.p"
},
{
"path": "src/js/controller.js",
"chars": 17190,
"preview": "import utils from './utils';\nimport Thumbnails from './thumbnails';\nimport Icons from './icons';\n\nlet cast;\nlet runOnce "
},
{
"path": "src/js/danmaku.js",
"chars": 12011,
"preview": "import utils from './utils';\n\nclass Danmaku {\n constructor(options) {\n this.options = options;\n this.pl"
},
{
"path": "src/js/events.js",
"chars": 2187,
"preview": "class Events {\n constructor() {\n this.events = {};\n\n this.videoEvents = [\n 'abort',\n "
},
{
"path": "src/js/fullscreen.js",
"chars": 5828,
"preview": "import utils from './utils';\n\nclass FullScreen {\n constructor(player) {\n this.player = player;\n this.la"
},
{
"path": "src/js/hotkey.js",
"chars": 2782,
"preview": "class HotKey {\n constructor(player) {\n this.player = player;\n this.doHotKeyHandler = this.doHotKey.bind"
},
{
"path": "src/js/i18n.js",
"chars": 11912,
"preview": "/*\nW3C def language codes is :\n language-code = primary-code ( \"-\" subcode )\n primary-code ISO 639-1 ( th"
},
{
"path": "src/js/icons.js",
"chars": 1254,
"preview": "import play from '../assets/play.svg';\nimport pause from '../assets/pause.svg';\nimport volumeUp from '../assets/volume-u"
},
{
"path": "src/js/index.js",
"chars": 330,
"preview": "import '../css/index.less';\nimport DPlayer from './player';\n\n/* global DPLAYER_VERSION GIT_HASH */\nconsole.log(`${'\\n'} "
},
{
"path": "src/js/info-panel.js",
"chars": 1793,
"preview": "/* global DPLAYER_VERSION GIT_HASH */\n\nclass InfoPanel {\n constructor(player) {\n this.container = player.templ"
},
{
"path": "src/js/options.js",
"chars": 2262,
"preview": "/* global DPLAYER_VERSION */\nimport defaultApiBackend from './api.js';\n\nexport default (options) => {\n // default opt"
},
{
"path": "src/js/player.js",
"chars": 27881,
"preview": "import Promise from 'promise-polyfill';\n\nimport utils from './utils';\nimport handleOption from './options';\nimport { i18"
},
{
"path": "src/js/setting.js",
"chars": 5754,
"preview": "import utils from './utils';\n\nclass Setting {\n constructor(player) {\n this.player = player;\n\n this.play"
},
{
"path": "src/js/subtitle.js",
"chars": 1669,
"preview": "class Subtitle {\n constructor(container, video, options, events) {\n this.container = container;\n this.v"
},
{
"path": "src/js/subtitles.js",
"chars": 3489,
"preview": "class Subtitles {\n constructor(player) {\n this.player = player;\n\n this.player.template.mask.addEventLis"
},
{
"path": "src/js/template.js",
"chars": 7993,
"preview": "import Icons from './icons';\nimport tplPlayer from '../template/player.art';\nimport utils from './utils';\n\nclass Templat"
},
{
"path": "src/js/thumbnails.js",
"chars": 1063,
"preview": "class Thumbnails {\n constructor(options) {\n this.container = options.container;\n this.barWidth = option"
},
{
"path": "src/js/timer.js",
"chars": 3111,
"preview": "class Timer {\n constructor(player) {\n this.player = player;\n\n window.requestAnimationFrame = (() =>\n "
},
{
"path": "src/js/user.js",
"chars": 1101,
"preview": "import utils from './utils';\n\nclass User {\n constructor(player) {\n this.storageName = {\n opacity: '"
},
{
"path": "src/js/utils.js",
"chars": 4709,
"preview": "const isMobile = /mobile|android|iphone|ipod|phone|ipad/i.test(window.navigator.userAgent);\n\nconst utils = {\n /**\n "
},
{
"path": "src/template/player.art",
"chars": 14576,
"preview": "<div class=\"dplayer-mask\"></div>\n<div class=\"dplayer-video-wrap\">\n {{ include './video.art' video }}\n {{ if option"
},
{
"path": "src/template/video.art",
"chars": 782,
"preview": "{{ set enableSubtitle = subtitle && subtitle.type === 'webvtt' }}\n<video\n class=\"dplayer-video {{ if current }}dplaye"
},
{
"path": "tea.yaml",
"chars": 128,
"preview": "# https://tea.xyz/what-is-this-file\n---\nversion: 1.0.0\ncodeOwners:\n - '0x185bfcef7b37010e2511309048a130f477f54fBf'\nqu"
},
{
"path": "webpack/dev.config.js",
"chars": 2751,
"preview": "const path = require('path');\nconst webpack = require('webpack');\nconst { GitRevisionPlugin } = require('git-revision-we"
},
{
"path": "webpack/prod.config.js",
"chars": 2607,
"preview": "const path = require('path');\nconst webpack = require('webpack');\nconst { GitRevisionPlugin } = require('git-revision-we"
}
]
About this extraction
This page contains the full source code of the DIYgod/DPlayer GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 73 files (311.8 KB), approximately 77.2k tokens, and a symbol index with 169 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.