修正模糊插件的时间差问题

This commit is contained in:
Harvey Zack committed 2019-05-08 12:12:43 +08:00
1 parent dac68903c5
commit 22f2b4714f
3 files changed
+44 -34

No files matched your search

+20 -15
View File
@@ -10,21 +10,6 @@ function artplayerPluginBlur(art) {
$ref.style.backgroundRepeat = 'no-repeat';
$ref.style.transition = 'all .2s ease';
function show() {
const { left, top } = $ref.getBoundingClientRect();
$ref.style.backgroundImage = 'none';
$ref.style.backgroundSize = `${player.width}px ${player.height}px`;
$ref.style.backgroundPosition = `${player.left - left}px ${player.top - top}px`;
player.getScreenshotBlobUrl().then(url => {
blurImageUrl(url, clamp(radius, 0, 50)).then(img => {
$ref.style.backgroundImage = `url(${img})`;
$ref.style.visibility = 'visible';
$ref.style.opacity = '1';
$ref.style.pointerEvents = 'auto';
});
});
}
function hide() {
$ref.style.visibility = 'hidden';
$ref.style.opacity = '0';
@@ -32,6 +17,26 @@ function artplayerPluginBlur(art) {
$ref.style.backgroundImage = 'none';
}
function show() {
const { left, top } = $ref.getBoundingClientRect();
const time = player.currentTime;
$ref.style.backgroundImage = 'none';
$ref.style.backgroundSize = `${player.width}px ${player.height}px`;
$ref.style.backgroundPosition = `${player.left - left}px ${player.top - top}px`;
player.getScreenshotBlobUrl().then(url => {
blurImageUrl(url, clamp(radius, 0, 50)).then(img => {
if (time === player.currentTime) {
$ref.style.backgroundImage = `url(${img})`;
$ref.style.visibility = 'visible';
$ref.style.opacity = '1';
$ref.style.pointerEvents = 'auto';
} else {
hide();
}
});
});
}
hide();
art.on('video:pause', show);
art.on('video:ended', show);