Skip to content

Commit 385c4e5

Browse files
committed
feat: auto-recover livekit player when specific track dies
When a specific user stream track (livekit-video://identity/sid) is unpublished, fallback to current-stream instead of retrying the same dead address every frame. This lets EnsureVideoIsPlaying and EnsureAudioIsPlaying self-heal by scanning for any available track.
1 parent 7d03932 commit 385c4e5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Explorer/Assets/DCL/SDKComponents/MediaStream/LivekitPlayer.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ public void EnsureVideoIsPlaying()
5757
if (playingAddress == null) return;
5858
if (IsVideoOpened) return;
5959

60-
var address = playingAddress.Value;
60+
// If a specific user stream died, fallback to current-stream (first available track)
61+
if (playingAddress.Value.IsUserStream(out _))
62+
{
63+
OpenMedia(LivekitAddress.CurrentStream());
64+
return;
65+
}
6166

62-
OpenMedia(address);
67+
OpenMedia(playingAddress.Value);
6368
}
6469

6570
public void EnsureAudioIsPlaying()
@@ -68,9 +73,14 @@ public void EnsureAudioIsPlaying()
6873
if (playingAddress == null) return;
6974
if (isAudioOpened) return;
7075

71-
var address = playingAddress.Value;
76+
// If a specific user stream died, fallback to current-stream (first available track)
77+
if (playingAddress.Value.IsUserStream(out _))
78+
{
79+
OpenMedia(LivekitAddress.CurrentStream());
80+
return;
81+
}
7282

73-
OpenMedia(address);
83+
OpenMedia(playingAddress.Value);
7484
}
7585

7686
public void OpenMedia(LivekitAddress livekitAddress)

0 commit comments

Comments
 (0)