diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-21 18:35:26 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-21 18:35:26 +0300 |
| commit | e58a12ee773da39d639ebb0e26fdb1b782941c56 (patch) | |
| tree | 60dbf99bc2daf8f9c0b0b0709a7fa0fa106eb8f1 /player-android/lib/api/player_api_client.dart | |
| parent | 627f44e105926e5ad4963336cdbfd9f9522bcdb1 (diff) | |
Wrap AudioPlayerScreen in audio_service for background playback (1b)
Creates PlayerAudioHandler (BaseAudioHandler + SeekHandler) that wraps
just_audio's AudioPlayer and bridges it to the Android media session:
background foreground-service playback, lock-screen / notification
controls (play/pause/seek/skip ±15 s), audio focus, and Bluetooth
headset events all handled by audio_service.
Key design decisions:
- Handler registered once via AudioService.init in main() and injected
into ProviderScope via overrideWithValue (DIP: no global mutable var).
- Progress-sync timer stays in the screen so PlayerApiClient is never
imported by the handler (SRP boundary preserved).
- Seek bar onChanged routes through handler.seek() so the notification
position updates on slider drags (Law of Demeter fix).
- _initPlayer refactored into _buildAuthHeaders / _loadSource /
_resumeFromSavedPosition helpers (each ≤30 lines, SoC).
- Tests override audioHandlerProvider with _FakePlayerAudioHandler to
avoid platform-channel calls; all 221 tests pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'player-android/lib/api/player_api_client.dart')
0 files changed, 0 insertions, 0 deletions
