From d17b6376e8137447c244693853fd05b57aaf368f Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Tue, 24 Mar 2026 13:55:54 +0100
Subject: [PATCH] fix: audio queue debug logging, 200ms playback state delay

---
 lib/services/audio_service.dart |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/services/audio_service.dart b/lib/services/audio_service.dart
index 680a0fd..0da9b0f 100644
--- a/lib/services/audio_service.dart
+++ b/lib/services/audio_service.dart
@@ -167,13 +167,20 @@
     if (path == null) return;
 
     if (_isPlaying) {
-      // Already playing — just add to queue, it will play when current finishes
+      // Already playing — add to queue, plays when current finishes
       _queue.add(path);
+      debugPrint('AudioService: queued (queue size: ${_queue.length})');
     } else {
       // Nothing playing — start immediately
-      await _player.play(DeviceFileSource(path));
-      _isPlaying = true;
-      onPlaybackStateChanged?.call();
+      try {
+        await _player.play(DeviceFileSource(path));
+        _isPlaying = true;
+        onPlaybackStateChanged?.call();
+        debugPrint('AudioService: playing immediately');
+      } catch (e) {
+        debugPrint('AudioService: play failed: $e');
+        _onTrackComplete();
+      }
     }
   }
 

--
Gitblit v1.3.1