diff --git a/lib/watch_together/providers/watch_together_provider.dart b/lib/watch_together/providers/watch_together_provider.dart index e978464b..097413e7 100644 --- a/lib/watch_together/providers/watch_together_provider.dart +++ b/lib/watch_together/providers/watch_together_provider.dart @@ -486,6 +486,19 @@ class WatchTogetherProvider with ChangeNotifier { appLogger.d('WatchTogether: Host exited player, callback set: ${onHostExitedPlayer != null}'); + // Clear media info so the next mediaSwitch (even same ratingKey) isn't + // treated as a duplicate by the guard in _handleMediaSwitch. + // copyWith uses ?? so it can't set fields to null — construct directly. + _session = WatchSession( + sessionId: _session!.sessionId, + role: _session!.role, + controlMode: _session!.controlMode, + state: _session!.state, + participants: _session!.participants, + errorMessage: _session!.errorMessage, + hostPeerId: _session!.hostPeerId, + ); + // Clear the player callback BEFORE popping so that any mediaSwitch message // arriving during the pop animation routes to MainScreen's handler instead // of the dying VideoPlayerScreen.