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