From f2e633df99cefd7082f6d5076a8418c4b2863c2f Mon Sep 17 00:00:00 2001 From: Sergei Date: Sun, 25 Jan 2026 18:03:56 -0800 Subject: [PATCH] Fix audio playback: add room.startAudio() call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: Audio from remote participant (Julia AI) was not playing because room.startAudio() was never called after connecting. This is REQUIRED by LiveKit WebRTC to enable audio playback. The fix matches the working implementation in debug.tsx (Robert version). Changes: - Add room.startAudio() call after room.connect() - Add canPlayAudio state tracking - Add proper error handling for startAudio 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- hooks/useLiveKitRoom.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hooks/useLiveKitRoom.ts b/hooks/useLiveKitRoom.ts index 8841213..85282ee 100644 --- a/hooks/useLiveKitRoom.ts +++ b/hooks/useLiveKitRoom.ts @@ -435,6 +435,19 @@ export function useLiveKitRoom(options: UseLiveKitRoomOptions): UseLiveKitRoomRe logSuccess('Connected to room!'); + // ========== CRITICAL: Start Audio Playback ========== + // This is REQUIRED for audio to play on iOS and Android! + // Without this call, remote audio tracks will NOT be heard. + logInfo('Starting audio playback (room.startAudio)...'); + try { + await lkRoom.startAudio(); + logSuccess(`Audio playback started! canPlaybackAudio: ${lkRoom.canPlaybackAudio}`); + setCanPlayAudio(lkRoom.canPlaybackAudio); + } catch (audioPlaybackErr: any) { + logError(`startAudio failed: ${audioPlaybackErr.message}`); + // Don't fail the whole call - audio might still work on some platforms + } + // Check if connection was cancelled after connect if (isUnmountingRef.current || currentConnectionId !== connectionIdRef.current) { logWarn('Connection cancelled after room.connect()');