From e13d1c589be30089a284c9cb5a8d98d7040124db Mon Sep 17 00:00:00 2001 From: gemstone Date: Fri, 17 May 2024 14:52:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20(xgplayer)=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=9F=B3=E9=87=8F=E5=B1=95=E7=A4=BA=E5=92=8C=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E6=95=B0=E5=80=BC=E6=9C=89=E5=B7=AE=E5=BC=82=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/xgplayer/src/plugins/volume/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/xgplayer/src/plugins/volume/index.js b/packages/xgplayer/src/plugins/volume/index.js index 9aece3e4..9fa40f0f 100644 --- a/packages/xgplayer/src/plugins/volume/index.js +++ b/packages/xgplayer/src/plugins/volume/index.js @@ -181,8 +181,10 @@ class Volume extends Plugin { const $labelValue = this.find('.xgplayer-value-label') const vol = Math.max(Math.min(volume, 1), 0) - // Math.ceil有精度问题,比如Math.ceil(0.55 * 100) == 56,因此这里使用parseInt - $labelValue.innerText = muted ? 0 : parseInt(vol * 100, 10) + // Math.ceil有精度问题,比如Math.ceil(0.55 * 100) == 56,因此这里使用Math.round + // 0.58 * 100 === 57.99999999999999 + // 0.55 * 100 === 55.00000000000001 + $labelValue.innerText = muted ? 0 : Math.round(vol * 100) } /**