サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加 (#12342)
Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									ccb951f11e
								
							
						
					
					
						commit
						c9503da8f8
					
				|  | @ -54,6 +54,7 @@ | |||
| 	- 例: `$[unixtime 1701356400]` | ||||
| - Enhance: プラグインでエラーが発生した場合のハンドリングを強化 | ||||
| - Enhance: 細かなUIのブラッシュアップ | ||||
| - Enhance: サウンド設定に「サウンドを出力しない」と「Misskeyがアクティブな時のみサウンドを出力する」を追加 | ||||
| - Fix: 効果音が再生されるとデバイスで再生している動画や音声が停止する問題を修正 #12339 | ||||
| - Fix: デッキに表示されたチャンネルの表示先チャンネルを切り替えた際、即座に反映されない問題を修正 #12236 | ||||
| - Fix: プラグインでノートの表示を書き換えられない問題を修正 | ||||
|  |  | |||
|  | @ -547,6 +547,8 @@ export interface Locale { | |||
|     "popout": string; | ||||
|     "volume": string; | ||||
|     "masterVolume": string; | ||||
|     "notUseSound": string; | ||||
|     "useSoundOnlyWhenActive": string; | ||||
|     "details": string; | ||||
|     "chooseEmoji": string; | ||||
|     "unableToProcess": string; | ||||
|  |  | |||
|  | @ -544,6 +544,8 @@ showInPage: "ページで表示" | |||
| popout: "ポップアウト" | ||||
| volume: "音量" | ||||
| masterVolume: "マスター音量" | ||||
| notUseSound: "サウンドを出力しない" | ||||
| useSoundOnlyWhenActive: "Misskeyがアクティブな時のみサウンドを出力する" | ||||
| details: "詳細" | ||||
| chooseEmoji: "絵文字を選択" | ||||
| unableToProcess: "操作を完了できません" | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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; | ||||
| } | ||||
|  |  | |||
|  | @ -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 }, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue