import 'package:flutter/services.dart'; import 'package:em2rp/utils/debug_log.dart'; /// Service pour émettre des feedbacks sonores lors des interactions class AudioFeedbackService { /// Jouer un son de succès (clic système) static Future playSuccessBeep() async { try { await SystemSound.play(SystemSoundType.click); } catch (e) { DebugLog.error('[AudioFeedbackService] Error playing success beep', e); } } /// Jouer un son d'erreur (alerte système) static Future playErrorBeep() async { try { // Note: SystemSoundType.alert n'existe pas sur toutes les plateformes // On utilise click pour l'instant, peut être amélioré avec audioplayers await SystemSound.play(SystemSoundType.click); await Future.delayed(const Duration(milliseconds: 100)); await SystemSound.play(SystemSoundType.click); } catch (e) { DebugLog.error('[AudioFeedbackService] Error playing error beep', e); } } /// Jouer une vibration haptique (si disponible) static Future playHapticFeedback() async { try { await HapticFeedback.mediumImpact(); } catch (e) { DebugLog.error('[AudioFeedbackService] Error playing haptic feedback', e); } } /// Jouer un feedback complet (son + vibration) static Future playFullFeedback({bool isSuccess = true}) async { await playHapticFeedback(); if (isSuccess) { await playSuccessBeep(); } else { await playErrorBeep(); } } }