refactor(audio): 볼륨 0일 때 재생 스킵 및 풀 크기 조정
This commit is contained in:
@@ -216,6 +216,7 @@ class AudioService {
|
||||
Future<void> playBgm(String name) async {
|
||||
if (_isPaused) return;
|
||||
if (!_staticInitialized) await init();
|
||||
if (_bgmVolume == 0) return; // 볼륨 0이면 재생 안함
|
||||
if (_currentBgm == name) return;
|
||||
if (_staticBgmPlayer == null) return;
|
||||
|
||||
@@ -376,6 +377,7 @@ class AudioService {
|
||||
/// 플레이어 이펙트 SFX 재생
|
||||
Future<void> playPlayerSfx(String name) async {
|
||||
if (_isPaused) return;
|
||||
if (_sfxVolume == 0) return; // 볼륨 0이면 재생 안함
|
||||
if (!_staticInitialized) await init();
|
||||
_tryPlayPendingBgm();
|
||||
await _playerSfxPool?.play('assets/audio/sfx/$name.mp3');
|
||||
@@ -384,6 +386,7 @@ class AudioService {
|
||||
/// 몬스터 이펙트 SFX 재생
|
||||
Future<void> playMonsterSfx(String name) async {
|
||||
if (_isPaused) return;
|
||||
if (_sfxVolume == 0) return; // 볼륨 0이면 재생 안함
|
||||
if (!_staticInitialized) await init();
|
||||
_tryPlayPendingBgm();
|
||||
await _monsterSfxPool?.play('assets/audio/sfx/$name.mp3');
|
||||
@@ -412,7 +415,13 @@ class AudioService {
|
||||
_bgmVolume = volume.clamp(0.0, 1.0);
|
||||
if (_staticBgmPlayer != null) {
|
||||
try {
|
||||
await _staticBgmPlayer!.setVolume(_bgmVolume);
|
||||
// 볼륨 0이면 BGM 정지
|
||||
if (_bgmVolume == 0) {
|
||||
await _staticBgmPlayer!.stop();
|
||||
_currentBgm = null;
|
||||
} else {
|
||||
await _staticBgmPlayer!.setVolume(_bgmVolume);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
await _settingsRepository.saveBgmVolume(_bgmVolume);
|
||||
|
||||
Reference in New Issue
Block a user