summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/sound.ts
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 /packages/frontend/src/scripts/sound.ts
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>
Diffstat (limited to 'packages/frontend/src/scripts/sound.ts')
-rw-r--r--packages/frontend/src/scripts/sound.ts17
1 files changed, 16 insertions, 1 deletions
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;
+}