This document explains how to add audio files to the ZenTap game and integrate them with the existing audio system.
All audio files should be placed in the assets/audio/ directory:
assets/
└── audio/
├── bubble_pop.wav # Primary bubble pop sound
├── bubble_pop_alt.wav # Alternative bubble pop sound
├── ambient_background.mp3 # Main background music
├── zen_mode_background.mp3 # Zen mode ambient music
└── ui_click.wav # UI button click sound (optional)
| File Name | Purpose | Duration | Description |
|---|---|---|---|
bubble_pop.wav |
Primary bubble pop sound | 0.1-0.3s | Satisfying pop sound when bubbles are tapped |
bubble_pop_alt.wav |
Alternative pop sound | 0.1-0.3s | Variation for audio diversity (optional) |
ui_click.wav |
UI interaction | 0.05-0.1s | Button press feedback (optional) |
| File Name | Purpose | Duration | Description |
|---|---|---|---|
ambient_background.mp3 |
Play mode background | 2-5 minutes | Calm, looping ambient music for gameplay |
zen_mode_background.mp3 |
Zen mode background | 2-5 minutes | Even more relaxing track for zen mode |
Place your audio files in the assets/audio/ directory with the exact filenames listed above.
The pubspec.yaml file already includes the audio assets:
flutter:
assets:
- assets/audio/
Modify lib/game/audio/audio_manager.dart to load the actual files:
// Replace the placeholder methods with actual file loading:
Future<void> initialize() async {
try {
// Load background music
await _backgroundPlayer.setAsset('assets/audio/ambient_background.mp3');
await _backgroundPlayer.setLoopMode(LoopMode.one);
} catch (e) {
print('Audio initialization failed: $e');
}
}
Future<void> playBubblePop() async {
if (!_soundEnabled) return;
try {
// Load and play bubble pop sound
await _effectPlayer.setAsset('assets/audio/bubble_pop.wav');
await _effectPlayer.play();
// Add haptic feedback
if (_hapticEnabled) {
await _playHapticFeedback();
}
} catch (e) {
print('Failed to play bubble pop sound: $e');
}
}
Future<void> playBackgroundMusic() async {
if (!_musicEnabled) return;
try {
// Switch music based on zen mode
String musicFile = isZenMode
? 'assets/audio/zen_mode_background.mp3'
: 'assets/audio/ambient_background.mp3';
await _backgroundPlayer.setAsset(musicFile);
await _backgroundPlayer.play();
} catch (e) {
print('Failed to play background music: $e');
}
}
After adding files and updating the code:
flutter pub get
flutter run
File Not Found Errors
assets/audio/ exactly as namedflutter pub get after adding filespubspec.yaml includes the assets sectionAudio Not Playing
Performance Issues
# Clean and rebuild
flutter clean
flutter pub get
flutter run
# Check for audio file issues
flutter analyze
Note: Current implementation uses system sounds as placeholders. Follow this guide to replace them with custom audio files for the complete ZenTap experience.