repod/src/components/Player/Volume.vue

91 lines
1.7 KiB
Vue
Raw Normal View History

2023-08-27 22:20:34 +02:00
<template>
<div>
<VolumeHighIcon
v-if="volume > 0.7"
class="pointer"
:size="30"
:title="t('repod', 'Mute')"
@click="mute" />
<VolumeLowIcon
v-if="volume > 0 && volume <= 0.3"
2023-08-27 22:20:34 +02:00
class="pointer"
:size="30"
:title="t('repod', 'Mute')"
2023-08-27 22:20:34 +02:00
@click="mute" />
<VolumeMediumIcon
v-if="volume > 0.3 && volume <= 0.7"
2023-08-27 22:20:34 +02:00
class="pointer"
:size="30"
:title="t('repod', 'Mute')"
2023-08-27 22:20:34 +02:00
@click="mute" />
<VolumeMuteIcon
v-if="volume === 0"
2023-08-27 22:20:34 +02:00
class="pointer"
:size="30"
:title="t('repod', 'Unmute')"
@click="setVolume(volumeMuted)" />
<input
max="1"
2023-08-28 00:02:07 +02:00
min="0"
step="0.1"
type="range"
:value="volume"
@change="
(event) =>
2024-10-18 17:15:54 +02:00
setVolume(parseFloat((event.target as HTMLInputElement).value))
" />
2023-08-27 22:20:34 +02:00
</div>
</template>
<script lang="ts">
import { mapActions, mapState } from 'pinia'
2024-03-16 18:35:31 +01:00
import VolumeHighIcon from 'vue-material-design-icons/VolumeHigh.vue'
import VolumeLowIcon from 'vue-material-design-icons/VolumeLow.vue'
import VolumeMediumIcon from 'vue-material-design-icons/VolumeMedium.vue'
import VolumeMuteIcon from 'vue-material-design-icons/VolumeMute.vue'
import { t } from '@nextcloud/l10n'
import { usePlayer } from '../../store/player.ts'
2023-08-27 22:20:34 +02:00
export default {
name: 'Volume',
components: {
2024-03-16 18:35:31 +01:00
VolumeHighIcon,
VolumeLowIcon,
VolumeMediumIcon,
VolumeMuteIcon,
2023-08-27 22:20:34 +02:00
},
data: () => ({
volumeMuted: 0,
}),
2023-08-27 22:20:34 +02:00
computed: {
...mapState(usePlayer, ['volume']),
2023-08-27 22:20:34 +02:00
},
methods: {
...mapActions(usePlayer, ['setVolume']),
2023-08-27 22:20:34 +02:00
mute() {
this.volumeMuted = this.volume
this.setVolume(0)
2023-08-27 22:20:34 +02:00
},
t,
2023-08-27 22:20:34 +02:00
},
}
</script>
<style scoped>
div {
align-items: center;
display: flex;
gap: 5px;
justify-content: flex-end;
}
2023-08-27 22:20:34 +02:00
input {
transform: rotate(270deg);
width: 4rem;
}
.pointer {
cursor: pointer;
}
2023-08-27 22:20:34 +02:00
</style>