diff --git a/lib/services/sound_service.dart b/lib/services/sound_service.dart index ea1ee2b..7180e66 100644 --- a/lib/services/sound_service.dart +++ b/lib/services/sound_service.dart @@ -31,20 +31,20 @@ } /// シャッター音を再生する(サウンドが OFF の場合は何もしない). - Future playShutterSound() async { - if (!_soundEnabled) return; - try { - await _rawCaptureService.playShutterSound(); - } catch (e) { - // サウンドエラーで撮影フローを止めない - } - } + Future playShutterSound() => + _playIfEnabled(_rawCaptureService.playShutterSound); /// 保存完了音を再生する(サウンドが OFF の場合は何もしない). - Future playSaveCompleteSound() async { + Future playSaveCompleteSound() => + _playIfEnabled(_rawCaptureService.playSaveCompleteSound); + + /// サウンドが有効なときだけ [play] を実行する. + /// + /// サウンドエラーで撮影フローを止めないため,例外は握りつぶす. + Future _playIfEnabled(Future Function() play) async { if (!_soundEnabled) return; try { - await _rawCaptureService.playSaveCompleteSound(); + await play(); } catch (e) { // サウンドエラーで撮影フローを止めない }