enhance(frontend): make default volume of video 30%

This commit is contained in:
syuilo 2023-10-08 14:01:40 +09:00
parent f37a3eff79
commit 774bf6a55e
4 changed files with 17 additions and 14 deletions

View file

@ -37,6 +37,7 @@
### Client
- Enhance: 二要素認証のバックアップコード一覧をテキストファイルでダウンロード可能に
- Enhance: 動画再生時のデフォルトボリュームを30%に
- Fix: リアクションしたユーザ一覧のUIが稀に左上に残ってしまう不具合を修正
### Server

View file

@ -17,7 +17,6 @@ SPDX-License-Identifier: AGPL-3.0-only
:title="media.name"
controls
preload="metadata"
@volumechange="volumechange"
/>
</div>
<a
@ -33,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import { onMounted, shallowRef, watch } from 'vue';
import * as Misskey from 'misskey-js';
import { soundConfigStore } from '@/scripts/sound.js';
import { i18n } from '@/i18n.js';
@ -43,15 +42,13 @@ const props = withDefaults(defineProps<{
}>(), {
});
const audioEl = $shallowRef<HTMLAudioElement | null>();
const audioEl = shallowRef<HTMLAudioElement>();
let hide = $ref(true);
function volumechange() {
if (audioEl) soundConfigStore.set('mediaVolume', audioEl.volume);
}
onMounted(() => {
if (audioEl) audioEl.volume = soundConfigStore.state.mediaVolume;
watch(audioEl, () => {
if (audioEl.value) {
audioEl.value.volume = 0.3;
}
});
</script>

View file

@ -14,6 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div v-else :class="[$style.visible, (video.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitiveContainer]">
<video
ref="videoEl"
:class="$style.video"
:poster="video.thumbnailUrl"
:title="video.comment"
@ -31,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { ref, shallowRef, watch } from 'vue';
import * as Misskey from 'misskey-js';
import bytes from '@/filters/bytes.js';
import { defaultStore } from '@/store.js';
@ -42,6 +43,14 @@ const props = defineProps<{
}>();
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.enableDataSaverMode) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore'));
const videoEl = shallowRef<HTMLVideoElement>();
watch(videoEl, () => {
if (videoEl.value) {
videoEl.value.volume = 0.3;
}
});
</script>
<style lang="scss" module>

View file

@ -7,10 +7,6 @@ import { markRaw } from 'vue';
import { Storage } from '@/pizzax.js';
export const soundConfigStore = markRaw(new Storage('sound', {
mediaVolume: {
where: 'device',
default: 0.5,
},
sound_masterVolume: {
where: 'device',
default: 0.3,