サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加 (#12342)
Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
parent
ccb951f11e
commit
c9503da8f8
6 changed files with 38 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue