mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
添加音量本地保存
This commit is contained in:
1 parent
dcedb802ee
commit
94c47f2e52
4 files changed
+11
-7
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { append, setStorage, getStorage, clamp, tooltip } from '../utils';
|
||||
import { append, getStorage, clamp, tooltip } from '../utils';
|
||||
import icons from '../icons';
|
||||
|
||||
export default class Volume {
|
||||
@@ -28,7 +28,6 @@ export default class Volume {
|
||||
proxy(this.$volume, 'click', () => {
|
||||
this.$volume.style.display = 'none';
|
||||
this.$volumeClose.style.display = 'block';
|
||||
setStorage('volume', player.volume());
|
||||
player.volume(0);
|
||||
});
|
||||
|
||||
@@ -89,7 +88,6 @@ export default class Volume {
|
||||
const { left: panelLeft, width: panelWidth } = this.$volumePanel.getBoundingClientRect();
|
||||
const { width: handleWidth } = this.$volumeHandle.getBoundingClientRect();
|
||||
const percentage = clamp(event.x - panelLeft - handleWidth / 2, 0, panelWidth - handleWidth / 2) / (panelWidth - handleWidth);
|
||||
setStorage('volume', percentage);
|
||||
player.volume(percentage);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
import { clamp, secondToTime } from './utils';
|
||||
import { clamp, secondToTime, setStorage } from './utils';
|
||||
import config from './config';
|
||||
|
||||
export default class Player {
|
||||
@@ -137,6 +137,9 @@ export default class Player {
|
||||
if (percentage !== undefined) {
|
||||
$video.volume = clamp(percentage, 0, 1);
|
||||
notice.show(`${i18n.get('Volume')}: ${parseInt($video.volume * 100)}`);
|
||||
if ($video.volume !== 0) {
|
||||
setStorage('volume', $video.volume);
|
||||
}
|
||||
this.art.emit('volume', $video.volume);
|
||||
}
|
||||
return $video.volume || 0;
|
||||
|
||||
Reference in new issue
Block a user