Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Cristiang1021/ErgoKawsay/llms.txt

Use this file to discover all available pages before exploring further.

Research consistently shows that ambient sound — particularly nature sounds and instrumental music — lowers cortisol levels, reduces perceived stress, and improves focus. ErgoKawsay’s Music module brings this benefit directly to teachers without requiring headphones, playlists, subscriptions, or even an internet connection. Three carefully selected ambient tracks are bundled as app assets and ready to play the moment the module is opened. The music player is designed to be non-intrusive: a mini player persists at the bottom of the screen across other modules so teachers can keep ambient audio running while reading tips, reviewing exercises, or logging their emotions.

Available Tracks

Forest Sounds

Sonido del bosqueThe natural soundscape of a forest — birdsong, wind through leaves, rustling branches. Ideal for restoring attention and reducing cognitive fatigue between classes.Asset: assets/audio/Sonido-del-bosque.mp3Track ID: forest

Gentle Rain

Lluvia SuaveSoft, consistent rainfall — one of the most universally recognized sounds for relaxation. Effective for winding down after a demanding teaching session or preparing for sleep.Asset: assets/audio/Lluvia-Suave.mp3Track ID: rain

Energizing Music

Música energizanteUpbeat instrumental music to restore energy and motivation. Suitable for preparation periods, active breaks, or the start of the school day.Asset: assets/audio/Musica-energizante.mp3Track ID: energizing
All three audio tracks are bundled directly inside the app as Flutter asset files. No streaming, no network request, and no internet connection is required to play them. Audio is available even in areas with no connectivity.

Audio Features

  • Play / Pause — tap the track card or the featured card’s CTA button to start playback; tap again to pause.
  • Track switching — tapping any track in the ambient list immediately loads and plays that track, even while another is playing.
  • Progress bar — an inline LinearProgressIndicator shows current playback position on both the featured card and the active list card. Elapsed and total duration are displayed.
  • Audio visualizer animation — when a track is active and playing, a green animated indicator dot pulses on its list card.
  • Mini player (persistent) — a compact now-playing bar appears at the bottom of the main app scaffold while audio is active, allowing playback control without staying on the Music screen. The Music screen sets hideMiniPlayer: true to avoid duplication.
  • Auto-advance — when a track finishes, playback automatically advances to the next track in the playlist order.
  • Previous / NextAudioController exposes previous() and next() methods for sequential navigation through the playlist.

Visual Theme

Each track has a distinct color scheme derived from the app palette:
TrackBackgroundForeground text
ForestblockLimeblockLimeText
RainblockLilacblockLilacText
EnergizingblockMintblockMintText
The featured card (always showing the first track, forest) uses the blockMint color scheme with a large circular icon and an active progress bar.

Implementation

Package: just_audio ^0.9.40 Audio is managed by a global singleton AudioController that persists for the entire app lifetime. It extends ChangeNotifier so that any ListenableBuilder subscribed to it rebuilds in response to playback state changes.
/// Global singleton — call AudioController.instance from anywhere.
class AudioController extends ChangeNotifier {
  static final AudioController instance = AudioController._();

  // Playback state (read-only from the outside)
  MusicTrack? get currentTrack => _currentTrack;
  bool get isPlaying => _isPlaying;
  Duration get position => _position;
  Duration get duration => _duration;
  String? get error => _error;

  // Playlist navigation helpers
  bool get hasPrevious => _currentIndex > 0;
  bool get hasNext =>
      _playlist.isNotEmpty && _currentIndex < _playlist.length - 1;

  // Progress as a 0.0–1.0 fraction (safe for LinearProgressIndicator)
  double get progress { ... }

  // Core actions
  Future<void> playTrack(MusicTrack track, {List<MusicTrack>? playlist});
  Future<void> togglePlayPause();
  Future<void> previous();
  Future<void> next();
  Future<void> stop();
  void seek(Duration position);

  // Formats a Duration as "MM:SS"
  String formatDuration(Duration d);
}
Asset declaration — all three MP3 files must be listed in pubspec.yaml:
flutter:
  assets:
    - assets/audio/Sonido-del-bosque.mp3
    - assets/audio/Lluvia-Suave.mp3
    - assets/audio/Musica-energizante.mp3
When isAsset is true on a MusicTrack, AudioController loads via _player.setAsset(track.assetPath). When isAsset is false and a url is provided, it loads via _player.setUrl(track.url!). Only asset-based playback is used in the current release.

MusicTrack Model

Tracks are immutable value objects defined in lib/data/models/music_track.dart.
class MusicTrack {
  const MusicTrack({
    required this.id,           // Unique identifier: 'forest' | 'rain' | 'energizing'
    required this.titleEs,      // Display title in Spanish
    required this.titleQu,      // Display title in Kichwa
    required this.descriptionEs, // Short description in Spanish
    required this.descriptionQu, // Short description in Kichwa
    required this.assetPath,    // Flutter asset path, e.g. 'assets/audio/...'
    required this.isAsset,      // true = load as asset; false = load from url
    this.url,                   // Optional remote URL (not used in current release)
  });

  final String id;
  final String titleEs;
  final String titleQu;
  final String descriptionEs;
  final String descriptionQu;
  final String assetPath;
  final bool isAsset;
  final String? url;

  // Language-aware accessors
  String title(bool isKichwa) => isKichwa ? titleQu : titleEs;
  String description(bool isKichwa) => isKichwa ? descriptionQu : descriptionEs;
}

Technical Reference

PropertyValue
Route/music
Category eyebrowRelajación / (Kichwa equivalent)
State managementListenableBuilder on AudioController.instance
Audio packagejust_audio ^0.9.40
Data sourceLocalDataRepository.instance.musicTracks
Total tracks3
Streaming❌ None — all assets bundled in APK
Network required❌ Fully offline

Build docs developers (and LLMs) love