fix(video): keep native player alive across rotation (#575)

Wrap the native player in a GlobalKey so an orientation change re-parents
the existing platform view instead of tearing it down and reloading the
stream.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Francis Lavoie 2026-07-02 17:23:26 -04:00 • committed by GitHub
parent ef1b1ded5d
commit b8648426f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -312,7 +312,14 @@ class _VideoChatState extends State<VideoChat>
final player = GestureDetector(
onLongPress: _videoStore.handleToggleOverlay,
child: _videoStore is NativeVideoStore
? NativeVideo(nativeVideoStore: _videoStore)
? NativeVideo(
// GlobalKey so the native platform view is *reparented* (not
// rebuilt) across the portrait↔landscape layout swap — without
// it, rotating destroys and recreates the player, forcing a
// reload. Mirrors the WebView Video below.
key: _videoKey,
nativeVideoStore: _videoStore,
)
: Video(
key: _videoKey,
videoStore: _videoStore as VideoStore,