mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
优化弹幕库
This commit is contained in:
1 parent
cd67baae94
commit
b73611b126
4 files changed
+14
-3024
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// 使用 Github Issues Api 做弹幕接口
|
||||
// 接口每小时限制 5000 次请求,勿滥用
|
||||
var github = new ArtplayerToolGithub({
|
||||
var danmuku = new ArtplayerToolGithub({
|
||||
api: 'zhw2590582/github-issues-api-as-danmuku/issues/1',
|
||||
clientID: '749a95aad589f8849abe',
|
||||
clientSecret: '7bb6fa67ef6e525e5bd5fda46cd3925ecc4a3760',
|
||||
@@ -19,8 +19,8 @@ var art = new Artplayer({
|
||||
click: () => {
|
||||
if (window.location.href.includes('code=')) {
|
||||
art.notice.show('正在登陆中,请稍等!!!');
|
||||
} else if (!github.isLogin) {
|
||||
github.login();
|
||||
} else if (!danmuku.isLogin) {
|
||||
danmuku.login();
|
||||
} else {
|
||||
var text = prompt('请输入:', '弹幕内容');
|
||||
if (!text || !text.trim()) return;
|
||||
@@ -28,26 +28,26 @@ var art = new Artplayer({
|
||||
art.notice.show('弹幕字数不能大于20字!!!');
|
||||
return;
|
||||
}
|
||||
if (github.remaining <= 10) {
|
||||
if (danmuku.remaining <= 10) {
|
||||
art.notice.show('接口请求到达上限,请稍后再试!!!');
|
||||
return;
|
||||
}
|
||||
art.notice.show('弹幕发送中...');
|
||||
github
|
||||
danmuku
|
||||
.send({
|
||||
text: text,
|
||||
time: art.player.currentTime,
|
||||
color: '#' + Math.floor(Math.random() * 0xffffff).toString(16),
|
||||
})
|
||||
.then(data => {
|
||||
art.notice.show(`发送弹幕成功: ${github.remaining} / ${github.limit}`);
|
||||
art.notice.show(`发送弹幕成功: ${danmuku.remaining} / ${danmuku.limit}`);
|
||||
art.plugins.artplayerPluginDanmu.emit({
|
||||
...data,
|
||||
time: art.player.currentTime,
|
||||
border: data.color,
|
||||
});
|
||||
}).catch(() => {
|
||||
art.notice.show(`发送弹幕失败: ${github.remaining} / ${github.limit}`);
|
||||
art.notice.show(`发送弹幕失败: ${danmuku.remaining} / ${danmuku.limit}`);
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -55,7 +55,7 @@ var art = new Artplayer({
|
||||
],
|
||||
plugins: [
|
||||
artplayerPluginDanmu({
|
||||
danmus: () => github.cache(),
|
||||
danmus: () => danmuku.load(),
|
||||
speed: 5,
|
||||
opacity: 1,
|
||||
color: '#fff',
|
||||
|
||||
Reference in new issue
Block a user