添加音量本地保存

This commit is contained in:
Harvey Zack committed 2018-10-24 17:40:01 +08:00
1 parent dcedb802ee
commit 94c47f2e52
4 files changed
+11 -7

No files matched your search

+1 -3
View File
@@ -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
View File
@@ -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;