Skip to content

Commit

Permalink
Feat: sound - enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
fs5m8 committed Dec 19, 2022
1 parent c6e821c commit 56fba4c
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 8 deletions.
6 changes: 5 additions & 1 deletion locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ common:
remain-deleted-note: "Continue to show deleted notes"
sound: "Sound"
enable-sounds: "Enable sounds"
enable-sounds-desc: "Play a sound when you receive a post/message. This setting is stored in the browser."
enable-sounds-desc: "This setting is stored in the browser."
enable-sounds-intimeline: "In a new post receive on your timelines (Only Desktop/Home)"
enable-sounds-innotifications: "In receive a notify (Only Desktop)"
enable-sounds-inmessage: "In receive a message"
enable-sounds-inreversi: "In put a stone in reversi games"
volume: "Volume"
test: "Test"
update: "Areionskey Update"
Expand Down
6 changes: 5 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ common:
remain-deleted-note: "削除された投稿を表示し続ける"
sound: "サウンド"
enable-sounds: "サウンドを有効にする"
enable-sounds-desc: "投稿やメッセージを送受信したときなどにサウンドを再生します。この設定はブラウザに記憶されます。"
enable-sounds-desc: "この設定はブラウザに記憶されます。"
enable-sounds-intimeline: "タイムラインに新しい投稿が流れたとき (デスクトップ/ホームのみ)"
enable-sounds-innotifications: "通知を受信したとき (デスクトップのみ)"
enable-sounds-inmessage: "メッセージを受信したとき"
enable-sounds-inreversi: "リバーシで石を置いたとき"
volume: "ボリューム"
test: "テスト"
update: "Areionskey Update"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default Vue.extend({
this.o.put(this.myColor, pos);
// サウンドを再生する
if (this.$store.state.device.enableSounds) {
if (this.$store.state.device.enableSounds && this.$store.state.device.enableSoundsInReversi) {
const sound = new Audio(`${url}/assets/reversi-put-me.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
Expand All @@ -256,7 +256,7 @@ export default Vue.extend({
this.$forceUpdate();
// サウンドを再生する
if (this.$store.state.device.enableSounds && x.color != this.myColor) {
if (this.$store.state.device.enableSounds && this.$store.state.device.enableSoundsInReversi && x.color != this.myColor) {
const sound = new Audio(`${url}/assets/reversi-put-you.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/common/views/components/messaging-room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export default Vue.extend({
onMessage(message) {
// サウンドを再生する
if (this.$store.state.device.enableSounds) {
const sound = new Audio(`${url}/assets/message.mp3`);
if (this.$store.state.device.enableSounds && this.$store.state.device.enableSoundsInMessage) {
const sound = new Audio(`${url}/assets/notify.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
}
Expand Down
30 changes: 29 additions & 1 deletion src/client/app/common/views/components/settings/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@
<ui-switch v-model="enableSounds">{{ $t('@._settings.enable-sounds') }}
<template #desc>{{ $t('@._settings.enable-sounds-desc') }}</template>
</ui-switch>
<ui-switch :disabled="!enableSounds" v-model="enableSoundsInTimeline">{{ $t('@._settings.enable-sounds-intimeline')}}
</ui-switch>
<ui-switch :disabled="!enableSounds" v-model="enableSoundsInNotifications">{{ $t('@._settings.enable-sounds-innotifications')}}
</ui-switch>
<ui-switch :disabled="!enableSounds" v-model="enableSoundsInMessage">{{ $t('@._settings.enable-sounds-inmessage')}}
</ui-switch>
<ui-switch :disabled="!enableSounds" v-model="enableSoundsInReversi">{{ $t('@._settings.enable-sounds-inreversi')}}
</ui-switch>
<label>{{ $t('@._settings.volume') }}</label>
<input type="range"
v-model="soundVolume"
Expand Down Expand Up @@ -421,6 +429,26 @@ export default Vue.extend({
set(value) { this.$store.commit('device/set', { key: 'enableSounds', value }); }
},
enableSoundsInTimeline: {
get() { return this.$store.state.device.enableSoundsInTimeline; },
set(value) { this.$store.commit('device/set', { key: 'enableSoundsInTimeline', value }); }
},
enableSoundsInNotifications: {
get() { return this.$store.state.device.enableSoundsInNotifications; },
set(value) { this.$store.commit('device/set', { key: 'enableSoundsInNotifications', value }); }
},
enableSoundsInMessage: {
get() { return this.$store.state.device.enableSoundsInMessage; },
set(value) { this.$store.commit('device/set', { key: 'enableSoundsInMessage', value }); }
},
enableSoundsInReversi: {
get() { return this.$store.state.device.enableSoundsInReversi; },
set(value) { this.$store.commit('device/set', { key: 'enableSoundsInReversi', value }); }
},
soundVolume: {
get() { return this.$store.state.device.soundVolume; },
set(value) { this.$store.commit('device/set', { key: 'soundVolume', value }); }
Expand Down Expand Up @@ -675,7 +703,7 @@ export default Vue.extend({
});
},
soundTest() {
const sound = new Audio(`${url}/assets/message.mp3`);
const sound = new Audio(`${url}/assets/notify.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
},
Expand Down
7 changes: 7 additions & 0 deletions src/client/app/common/views/deck/deck.notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import * as config from '../../../config';
import XNotification from './deck.notification.vue';
import paging from '../../../common/scripts/paging';
Expand Down Expand Up @@ -108,6 +109,12 @@ export default Vue.extend({
});
this.prepend(notification);
if (this.$store.state.device.enableSounds && this.$store.state.device.enableSoundsInNotifications) {
const sound = new Audio(`${config.url}/assets/notify.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
}
},
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/desktop/views/components/notes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default Vue.extend({
if (self.isScrollTop()) {
// サウンドを再生する
if (self.$store.state.device.enableSounds && !silent) {
if (self.$store.state.device.enableSounds && self.$store.state.device.enableSoundsInTimeline && !silent) {
const sound = new Audio(`${config.url}/assets/post.mp3`);
sound.volume = self.$store.state.device.soundVolume;
sound.play();
Expand Down
7 changes: 7 additions & 0 deletions src/client/app/desktop/views/components/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import * as config from '../../../config';
import getNoteSummary from '../../../../../misc/get-note-summary';
import paging from '../../../common/scripts/paging';
Expand Down Expand Up @@ -228,6 +229,12 @@ export default Vue.extend({
});
this.prepend(notification);
if (this.$store.state.device.enableSounds && this.$store.state.device.enableSoundsInNotifications) {
const sound = new Audio(`${config.url}/assets/notify.mp3`);
sound.volume = this.$store.state.device.soundVolume;
sound.play();
}
}
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/client/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const defaultDeviceSettings = {
fontSize: 0,
themes: [],
enableSounds: true,
enableSoundsInTimeline: false,
enableSoundsInNotifications: true,
enableSoundsInMessage: true,
enableSoundsInReversi: true,
soundVolume: 0.5,
mediaVolume: 0.5,
lang: null,
Expand Down
File renamed without changes.

0 comments on commit 56fba4c

Please sign in to comment.