DPlayer 弹幕
# 介绍
适合 DPlayer 使用的弹幕
# API V3
# DPlayer 弹幕
# API
/api/dplayer/
# 示例
https://danmu.u2sb.com/api/dplayer/
# 解析 BiliBili 弹幕
# 解释
id
aid 或 bvid,例如av810872
或BV18b411j72u
p
分 P,例如1
2
,省略时默认为1
# API
/api/dplayer/v3/bilibili/{id}/{p:int?}
/api/dplayer/v3/bilibili/danmu/?bvid={id}&p={p}
# 示例
https://danmu.u2sb.com/api/dplayer/v3/bilibili/BV18b411j72u
https://danmu.u2sb.com/api/dplayer/v3/bilibili/danmu/?bvid=BV18b411j72u
# 返回
{
"code": 0,
"data": [
[12.544, 0, 16777215, "3600fffd", "来了"],
[7.739, 0, 16777215, "5689bb4c", "第一,截图见证"],
[30.225, 0, 16777215, "b21ea9d5", "国风真美!!!"],
[25.077, 0, 16777215, "260d013c", "好像真的是第一"]
]
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 示例
点击查看
<div ref="dp"></div>
1
export default {
mounted() {
this.$nextTick(() => {
import("dplayer").then(({ default: DPlayer }) => {
this.dp = new DPlayer({
container: this.$refs.dp,
video: {
url: "/assets/video/s_720.mp4",
thumbnails: "/assets/video/thumbnails.jpg",
},
danmaku: {
api: "https://danmu.u2sb.com/api/dplayer/",
id: "cENuyhsT2rMOCohK",
addition: ["https://danmu.u2sb.com/api/dplayer/v3/bilibili/BV1zt411t79A"],
},
})
});
})
},
beforeDestroy() {
this.dp.destroy();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
提示
一定要把 id
改掉,别 TM 傻逼呵呵的直接用我测试视频的 id 直接就写上去了,自己想办法随便生成一个随机字符串。
上次更新: 10/4/2022, 11:21:17 PM