サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加 (#12342)

Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
おさむのひと 2023-11-26 16:12:02 +09:00 committed by GitHub
parent ccb951f11e
commit c9503da8f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 1 deletions

View file

@ -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;
}