@@ -10,91 +10,89 @@ redirectFrom:
10
10
11
11
适合 ArtPlayer 使用的弹幕
12
12
13
- ## API V1
14
-
15
- ### ArtPlayer 弹幕
16
-
17
- #### API
18
-
19
- - ` /api/artplayer/v1/{id}.{format?} `
20
- - ` /api/artplayer/v1/?id={id} `
21
-
22
- #### 示例
23
-
24
- - ` https://danmu.u2sb.com/api/artplayer/v1/cENuyhsT2rMOCohK `
25
- - ` https://danmu.u2sb.com/api/artplayer/v1/cENuyhsT2rMOCohK.json `
26
- - ` https://danmu.u2sb.com/api/artplayer/v1/?id=cENuyhsT2rMOCohK `
13
+ ## API V2
27
14
28
15
### 解析 BiliBili 弹幕
29
16
30
17
#### 解释
31
18
32
- - ` id ` aid 或 bvid,例如 ` av810872 ` 或 ` BV18b411j72u `
19
+ - ` bvid ` 视频 bvid
33
20
- ` p ` 分 P,例如 ` 1 ` ` 2 ` ,省略时默认为 ` 1 `
34
- - ` format ` 数据格式,` json ` 或 ` xml `
21
+ - ` format ` 数据格式,` json `
35
22
36
23
#### API
37
24
38
- - ` /api/artplayer/v1/ bilibili/{id}/{p:int? }.{format? } `
39
- - ` /api/artplayer/v1/ bilibili.{format}? bvid={id}&p={p } `
25
+ - ` /api/art/ bilibili/v2/{bvid }.{format} `
26
+ - ` /api/art/ bilibili/v2/{ bvid}/{p:int}.{format } `
40
27
41
28
#### 示例
42
29
43
- - ` https://danmu.u2sb.com/api/artplayer/v1/bilibili/BV18b411j72u `
44
- - ` https://danmu.u2sb.com/api/artplayer/v1/bilibili/BV18b411j72u.json `
45
- - ` https://danmu.u2sb.com/api/artplayer/v1/bilibili/BV18b411j72u/2.json `
46
- - ` https://danmu.u2sb.com/api/artplayer/v1/bilibili/?bvid=BV18b411j72u `
47
-
48
- #### 返回
49
-
50
- ``` xml
51
- <i xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns : xsd =" http://www.w3.org/2001/XMLSchema" >
52
- <d p =" 12.544,1,25,16777215,1555668046,0,3600fffd,14955772062990336, 6" >来了</d >
53
- <d p =" 7.739,1,25,16777215,1555668050,0,5689bb4c,14955774128160768, 8" >第一,截图见证</d >
54
- <d p =" 30.225,1,25,16777215,1555668063,0,b21ea9d5,14955781264769024, 8" >国风真美!!!</d >
55
- <d p =" 25.077,1,25,16777215,1555668091,0,260d013c,14955795885588482, 7" >好像真的是第一</d >
56
- <d p =" 6.46,1,25,16777215,1555668096,0,8e084014,14955798307799044, 7" >我好早</d >
57
- <d p =" 11.538,1,25,16777215,1555668098,0,e3027d1f,14955799643160580, 10" >来了来了!</d >
58
- <d p =" 39.019,1,25,16777215,1555668105,0,3600fffd,14955802998079490, 9" >那个说第一的,你错了,00:12那个是我,我才是第一</d >
59
- <d p =" 40.484,1,25,16777215,1555668200,0,d1f6347d,14955852705824768, 1" >真的美爆了!⁽⁽ଘ( ˊᵕˋ )ଓ⁾⁾</d >
60
- </i >
61
- ```
30
+ - ` https://danmu.u2sb.com/api/art/bilibili/v2/BV1JP41167xK.json `
62
31
63
- ``` json
64
- {
65
- "code" : 0 ,
66
- "data" : [
67
- {
68
- "text" : " 来了" ,
69
- "time" : 12.544 ,
70
- "color" : " #FFFFFF" ,
71
- "size" : 25 ,
72
- "border" : false ,
73
- "mode" : 0
74
- },
75
- {
76
- "text" : " 第一,截图见证" ,
77
- "time" : 7.739 ,
78
- "color" : " #FFFFFF" ,
79
- "size" : 25 ,
80
- "border" : false ,
81
- "mode" : 0
82
- },
83
- {
84
- "text" : " 国风真美!!!" ,
85
- "time" : 30.225 ,
86
- "color" : " #FFFFFF" ,
87
- "size" : 25 ,
88
- "border" : false ,
89
- "mode" : 0
32
+ ``` html
33
+ <!DOCTYPE html>
34
+
35
+ <head >
36
+ <meta charset =" UTF-8" />
37
+ <meta http-equiv =" X-UA-Compatible" content =" IE=edge" />
38
+ <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
39
+ <title >demo</title >
40
+ <style >
41
+ .art-container {
42
+ width : 800px ;
43
+ height : 450px ;
90
44
}
91
- ]
92
- }
45
+ </style >
46
+ </head >
47
+
48
+ <body >
49
+ <h2 >MessagePack 推荐</h2 >
50
+ <div id =" art1" class =" art-container" ></div >
51
+
52
+ <h2 >JSON 不推荐</h2 >
53
+ <div id =" art2" class =" art-container" ></div >
54
+
55
+ <script type =" module" >
56
+ import artplayer from " https://cdn.jsdelivr.net/npm/artplayer/+esm" ;
57
+ import artdm from " https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/+esm" ;
58
+ import { getDanMuAsync } from " /assets/js/artMsgpackDm.js" ;
59
+
60
+ const Artplayer = artplayer .default ;
61
+ const artplayerPluginDanmuku = artdm .default ;
62
+
63
+ const art1 = new Artplayer ({
64
+ container: " #art1" ,
65
+ url: " /assets/video/1214946209-1-192.mp4" ,
66
+ fullscreen: true ,
67
+ fullscreenWeb: true ,
68
+ plugins: [
69
+ artplayerPluginDanmuku ({
70
+ danmuku : () => getDanMuAsync (" /api/art/bilibili/v2/BV1JP41167xK" ),
71
+ }),
72
+ ],
73
+ });
74
+
75
+ // 不推荐
76
+ const art2 = new Artplayer ({
77
+ container: " #art2" ,
78
+ url: " /assets/video/1214946209-1-192.mp4" ,
79
+ fullscreen: true ,
80
+ fullscreenWeb: true ,
81
+ plugins: [
82
+ artplayerPluginDanmuku ({
83
+ danmuku : () =>
84
+ fetch (" /api/art/bilibili/v2/BV1JP41167xK.json" ).then ((res ) =>
85
+ res .json ()
86
+ ),
87
+ }),
88
+ ],
89
+ });
90
+ </script >
91
+ </body >
93
92
```
94
93
95
94
## 示例
96
95
97
-
98
96
<div ref =" art0 " />
99
97
100
98
``` html
0 commit comments