@xpadev-net/niconicomments 0.2.78 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -7
- package/dist/bundle.d.ts +438 -306
- package/dist/bundle.js +2918 -1150
- package/package.json +20 -23
package/README.md
CHANGED
|
@@ -15,16 +15,24 @@ npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
+
CDN から読み込む場合は、可変エイリアスではなく固定バージョンを指定してください。
|
|
19
|
+
|
|
18
20
|
```html
|
|
19
|
-
<script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@0.2.78/dist/bundle.min.js"></script>
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
or
|
|
23
25
|
|
|
24
|
-
```
|
|
26
|
+
```shell
|
|
25
27
|
npm i @xpadev-net/niconicomments
|
|
26
28
|
```
|
|
27
29
|
|
|
30
|
+
npm で読み込む場合:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import NiconiComments from "@xpadev-net/niconicomments";
|
|
34
|
+
```
|
|
35
|
+
|
|
28
36
|
## Examples
|
|
29
37
|
|
|
30
38
|
```javascript
|
|
@@ -34,10 +42,40 @@ const req = await fetch("sample.json");
|
|
|
34
42
|
const res = await req.json();
|
|
35
43
|
const niconiComments = new NiconiComments(canvas, res);
|
|
36
44
|
//video.ontimeupdateを使用すると、呼び出し回数の関係でコメントカクつく
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
45
|
+
let animationFrameId = null;
|
|
46
|
+
|
|
47
|
+
const stopDrawing = () => {
|
|
48
|
+
if (animationFrameId === null) return;
|
|
49
|
+
cancelAnimationFrame(animationFrameId);
|
|
50
|
+
animationFrameId = null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const draw = () => {
|
|
54
|
+
animationFrameId = null;
|
|
55
|
+
niconiComments.drawCanvas(video.currentTime * 100);
|
|
56
|
+
if (!video.paused && document.visibilityState !== "hidden") {
|
|
57
|
+
animationFrameId = requestAnimationFrame(draw);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const startDrawing = () => {
|
|
62
|
+
if (animationFrameId === null && document.visibilityState !== "hidden") {
|
|
63
|
+
animationFrameId = requestAnimationFrame(draw);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
video.addEventListener("play", startDrawing);
|
|
68
|
+
video.addEventListener("pause", () => {
|
|
69
|
+
stopDrawing();
|
|
70
|
+
niconiComments.drawCanvas(video.currentTime * 100);
|
|
71
|
+
});
|
|
72
|
+
document.addEventListener("visibilitychange", () => {
|
|
73
|
+
if (document.visibilityState === "hidden" || video.paused) {
|
|
74
|
+
stopDrawing();
|
|
75
|
+
} else {
|
|
76
|
+
startDrawing();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
41
79
|
```
|
|
42
80
|
|
|
43
81
|
## Sample
|
|
@@ -48,4 +86,4 @@ setInterval(
|
|
|
48
86
|
### このライブラリを使用される方へ
|
|
49
87
|
|
|
50
88
|
このライブラリを使用するかどうかに関わらず、リアルタイムでコメントを取得、画面を描画、コメントの投稿という一連の流れを実装した場合、ニコニコの特許を侵害する可能性があります
|
|
51
|
-
詳しくはこちら[ニコニコが保有する特許について](https://github.com/xpadev-net/niconicomments/blob/develop/ABOUT_PATENT.md)を参照してください
|
|
89
|
+
詳しくはこちら[ニコニコが保有する特許について](https://github.com/xpadev-net/niconicomments/blob/develop/ABOUT_PATENT.md)を参照してください
|