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:
parent
ef1b1ded5d
commit
b8648426f8
1 changed files with 8 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue