update danmuku.js

This commit is contained in:
Harvey Zack committed 2022-05-14 22:00:28 +08:00
1 parent 1ba6898705
commit c568076b6b
15 files changed
+197 -192

No files matched your search

@@ -1,6 +1,6 @@
{
"license": "MIT",
"version": "4.3.23",
"version": "4.4.0",
"name": "artplayer-plugin-danmuku",
"description": "Danmuku plugin for ArtPlayer",
"main": "dist/artplayer-plugin-danmuku.js",
@@ -461,9 +461,15 @@ export default class Danmuku {
danmu.time = this.art.currentTime + 0.5;
}
if (danmu.mode === undefined) {
danmu.mode = this.option.mode;
}
if (danmu.color === undefined) {
danmu.color = this.option.color;
}
this.queue.push({
mode: this.option.mode,
color: this.option.color,
...danmu,
$state: 'wait',
$ref: null,
@@ -6,11 +6,10 @@ function checkVersion(art) {
version,
utils: { errorHandle },
} = art.constructor;
const arr = version.split('.').map(Number);
const major = arr[0];
const minor = arr[1] / 100;
errorHandle(major + minor >= 4.04, `弹幕库:Artplayer.js@${version} 版本不兼容,请更新到 4.4.x 版本以上`);
errorHandle(major + minor >= 4.04, `Artplayer.js@${version}不兼容该弹幕库,请更新到 4.4.x 版本以上`);
}
export default function artplayerPluginDanmuku(option) {
@@ -34,4 +33,6 @@ export default function artplayerPluginDanmuku(option) {
};
}
window['artplayerPluginDanmuku'] = artplayerPluginDanmuku;
if (typeof window !== 'undefined') {
window['artplayerPluginDanmuku'] = artplayerPluginDanmuku;
}
@@ -109,10 +109,10 @@ export default function setting(art, danmuku) {
border: true,
};
countdown(5);
$input.value = '';
danmuku.emit(danmu);
addClass($send, 'art-disabled');
countdown(danmuku.option.timeout || 5);
art.emit('artplayerPluginDanmuku:emit', danmu);
}
@@ -29,6 +29,7 @@
background-color: rgba(0, 0, 0, 0.9);
.art-danmuku-style-panel-title {
font-size: 13px;
margin-bottom: 10px;
}
@@ -29,9 +29,9 @@ export default function aspectRatio(art) {
art.aspectRatio = item.value;
},
mounted: ($panel, item) => {
update($panel, item._$tooltip, art.aspectRatio);
update($panel, item.$tooltip, art.aspectRatio);
art.on('aspectRatio', () => {
update($panel, item._$tooltip, art.aspectRatio);
update($panel, item.$tooltip, art.aspectRatio);
});
},
};
+2 -2
View File
@@ -31,9 +31,9 @@ export default function flip(art) {
art.flip = item.value;
},
mounted: ($panel, item) => {
update($panel, item._$tooltip, art.flip);
update($panel, item.$tooltip, art.flip);
art.on('flip', () => {
update($panel, item._$tooltip, art.flip);
update($panel, item.$tooltip, art.flip);
});
},
};
+8 -8
View File
@@ -168,7 +168,7 @@ export default class Setting extends Component {
}
append($left, $icon);
item._$icon = $icon;
item.$icon = $icon;
def(item, 'icon', {
get() {
@@ -185,7 +185,7 @@ export default class Setting extends Component {
addClass($html, 'art-setting-item-left-text');
append($html, item.html || '');
append($left, $html);
item._$html = $html;
item.$html = $html;
def(item, 'html', {
get() {
@@ -202,7 +202,7 @@ export default class Setting extends Component {
addClass($tooltip, 'art-setting-item-right-tooltip');
append($tooltip, item.tooltip || '');
append($right, $tooltip);
item._$tooltip = $tooltip;
item.$tooltip = $tooltip;
def(item, 'tooltip', {
get() {
@@ -223,14 +223,14 @@ export default class Setting extends Component {
const $switchOff = append($state, icons.switchOff);
setStyle(item.switch ? $switchOff : $switchOn, 'display', 'none');
append($right, $state);
item._$switch = item.switch;
item.$switch = item.switch;
def(item, 'switch', {
get() {
return item._$switch;
return item.$switch;
},
set(value) {
item._$switch = value;
item.$switch = value;
if (value) {
setStyle($switchOff, 'display', 'none');
setStyle($switchOn, 'display', null);
@@ -273,8 +273,8 @@ export default class Setting extends Component {
if (item._parentItem && item._parentItem.onSelect) {
const result = await item._parentItem.onSelect.call(this.art, item, $item, event);
if (item._parentItem._$tooltip && isStringOrNumber(result)) {
item._parentItem._$tooltip.innerHTML = result;
if (item._parentItem.$tooltip && isStringOrNumber(result)) {
item._parentItem.$tooltip.innerHTML = result;
}
}
}
@@ -29,9 +29,9 @@ export default function playbackRate(art) {
art.playbackRate = item.value;
},
mounted: ($panel, item) => {
update($panel, item._$tooltip, art.playbackRate);
update($panel, item.$tooltip, art.playbackRate);
art.on('playbackRate', () => {
update($panel, item._$tooltip, art.playbackRate);
update($panel, item.$tooltip, art.playbackRate);
});
},
};
@@ -29,9 +29,9 @@ export default function subtitleOffset(art) {
art.subtitleOffset = item.value;
},
mounted: ($panel, item) => {
update($panel, item._$tooltip, art.subtitleOffset);
update($panel, item.$tooltip, art.subtitleOffset);
art.on('subtitleOffset', () => {
update($panel, item._$tooltip, art.subtitleOffset);
update($panel, item.$tooltip, art.subtitleOffset);
});
},
};