mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 00:56:16 -08:00
31 lines
780 B
JavaScript
31 lines
780 B
JavaScript
import { clamp, def } from '../utils';
|
|
|
|
export default function volumeMix(art) {
|
|
const {
|
|
template: { $video },
|
|
i18n,
|
|
notice,
|
|
storage,
|
|
} = art;
|
|
|
|
def(art, 'volume', {
|
|
get: () => $video.volume || 0,
|
|
set: (percentage) => {
|
|
$video.volume = clamp(percentage, 0, 1);
|
|
notice.show = `${i18n.get('Volume')}: ${parseInt($video.volume * 100, 10)}`;
|
|
if ($video.volume !== 0) {
|
|
storage.set('volume', $video.volume);
|
|
}
|
|
art.emit('volume', $video.volume);
|
|
},
|
|
});
|
|
|
|
def(art, 'muted', {
|
|
get: () => $video.muted,
|
|
set: (muted) => {
|
|
$video.muted = muted;
|
|
art.emit('volume', $video.volume);
|
|
},
|
|
});
|
|
}
|