summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorおさむのひと <46447427+samunohito@users.noreply.github.com>2023-11-26 16:12:02 +0900
committerGitHub <noreply@github.com>2023-11-26 16:12:02 +0900
commitc9503da8f8e4a67cbe7ba88722b3c3893f9ab4e4 (patch)
tree2298d7c984b6097d758a81b431547b19461d3b79
parentchore: create AudioContext when it is needed (#12460) (diff)
downloadsharkey-c9503da8f8e4a67cbe7ba88722b3c3893f9ab4e4.tar.gz
sharkey-c9503da8f8e4a67cbe7ba88722b3c3893f9ab4e4.tar.bz2
sharkey-c9503da8f8e4a67cbe7ba88722b3c3893f9ab4e4.zip
サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加 (#12342)
Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
-rw-r--r--CHANGELOG.md1
-rw-r--r--locales/index.d.ts2
-rw-r--r--locales/ja-JP.yml2
-rw-r--r--packages/frontend/src/pages/settings/sounds.vue9
-rw-r--r--packages/frontend/src/scripts/sound.ts17
-rw-r--r--packages/frontend/src/store.ts8
6 files changed, 38 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a1bdd233d..bf3fecb5b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,6 +54,7 @@
- 例: `$[unixtime 1701356400]`
- Enhance: プラグインでエラーが発生した場合のハンドリングを強化
- Enhance: 細かなUIのブラッシュアップ
+- Enhance: サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加
- Fix: 効果音が再生されるとデバイスで再生している動画や音声が停止する問題を修正 #12339
- Fix: デッキに表示されたチャンネルの表示先チャンネルを切り替えた際、即座に反映されない問題を修正 #12236
- Fix: プラグインでノートの表示を書き換えられない問題を修正
diff --git a/locales/index.d.ts b/locales/index.d.ts
index 6e9fe311f1..6097ae130e 100644
--- a/locales/index.d.ts
+++ b/locales/index.d.ts
@@ -547,6 +547,8 @@ export interface Locale {
"popout": string;
"volume": string;
"masterVolume": string;
+ "notUseSound": string;
+ "useSoundOnlyWhenActive": string;
"details": string;
"chooseEmoji": string;
"unableToProcess": string;
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 0b051b6190..1f6695b3e3 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -544,6 +544,8 @@ showInPage: "ページで表示"
popout: "ポップアウト"
volume: "音量"
masterVolume: "マスター音量"
+notUseSound: "サウンドを出力しない"
+useSoundOnlyWhenActive: "Misskeyがアクティブな時のみサウンドを出力する"
details: "詳細"
chooseEmoji: "絵文字を選択"
unableToProcess: "操作を完了できません"
diff --git a/packages/frontend/src/pages/settings/sounds.vue b/packages/frontend/src/pages/settings/sounds.vue
index 244bb1e0e2..05e4b0d14c 100644
--- a/packages/frontend/src/pages/settings/sounds.vue
+++ b/packages/frontend/src/pages/settings/sounds.vue
@@ -5,6 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div class="_gaps_m">
+ <MkSwitch v-model="notUseSound">
+ <template #label>{{ i18n.ts.notUseSound }}</template>
+ </MkSwitch>
+ <MkSwitch v-model="useSoundOnlyWhenActive">
+ <template #label>{{ i18n.ts.useSoundOnlyWhenActive }}</template>
+ </MkSwitch>
<MkRange v-model="masterVolume" :min="0" :max="1" :step="0.05" :textConverter="(v) => `${Math.floor(v * 100)}%`">
<template #label>{{ i18n.ts.masterVolume }}</template>
</MkRange>
@@ -35,7 +41,10 @@ import MkFolder from '@/components/MkFolder.vue';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { defaultStore } from '@/store.js';
+import MkSwitch from '@/components/MkSwitch.vue';
+const notUseSound = computed(defaultStore.makeGetterSetter('sound_notUseSound'));
+const useSoundOnlyWhenActive = computed(defaultStore.makeGetterSetter('sound_useSoundOnlyWhenActive'));
const masterVolume = computed(defaultStore.makeGetterSetter('sound_masterVolume'));
const soundsKeys = ['note', 'noteMy', 'notification', 'antenna', 'channel', 'reaction'] as const;
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index d28d629227..a3cddba1f4 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -104,7 +104,7 @@ export async function playFile(file: string, volume: number) {
export function createSourceNode(buffer: AudioBuffer, volume: number) : AudioBufferSourceNode | null {
const masterVolume = defaultStore.state.sound_masterVolume;
- if (masterVolume === 0 || volume === 0) {
+ if (isMute() || masterVolume === 0 || volume === 0) {
return null;
}
@@ -117,3 +117,18 @@ export function createSourceNode(buffer: AudioBuffer, volume: number) : AudioBuf
return soundSource;
}
+
+export function isMute(): boolean {
+ if (defaultStore.state.sound_notUseSound) {
+ // サウンドを出力しない
+ return true;
+ }
+
+ // noinspection RedundantIfStatementJS
+ if (defaultStore.state.sound_useSoundOnlyWhenActive && document.visibilityState === 'hidden') {
+ // ブラウザがアクティブな時のみサウンドを出力する
+ return true;
+ }
+
+ return false;
+}
diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts
index f2ed4e7c0b..40fb1dde76 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -391,6 +391,14 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: 0.3,
},
+ sound_notUseSound: {
+ where: 'device',
+ default: false,
+ },
+ sound_useSoundOnlyWhenActive: {
+ where: 'device',
+ default: false,
+ },
sound_note: {
where: 'device',
default: { type: 'syuilo/n-aec', volume: 1 },