| .. | .. |
|---|
| 167 | 167 | if (path == null) return; |
|---|
| 168 | 168 | |
|---|
| 169 | 169 | if (_isPlaying) { |
|---|
| 170 | | - // Already playing — just add to queue, it will play when current finishes |
|---|
| 170 | + // Already playing — add to queue, plays when current finishes |
|---|
| 171 | 171 | _queue.add(path); |
|---|
| 172 | + debugPrint('AudioService: queued (queue size: ${_queue.length})'); |
|---|
| 172 | 173 | } else { |
|---|
| 173 | 174 | // Nothing playing — start immediately |
|---|
| 174 | | - await _player.play(DeviceFileSource(path)); |
|---|
| 175 | | - _isPlaying = true; |
|---|
| 176 | | - onPlaybackStateChanged?.call(); |
|---|
| 175 | + try { |
|---|
| 176 | + await _player.play(DeviceFileSource(path)); |
|---|
| 177 | + _isPlaying = true; |
|---|
| 178 | + onPlaybackStateChanged?.call(); |
|---|
| 179 | + debugPrint('AudioService: playing immediately'); |
|---|
| 180 | + } catch (e) { |
|---|
| 181 | + debugPrint('AudioService: play failed: $e'); |
|---|
| 182 | + _onTrackComplete(); |
|---|
| 183 | + } |
|---|
| 177 | 184 | } |
|---|
| 178 | 185 | } |
|---|
| 179 | 186 | |
|---|