File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
catalyst_voices/apps/voices/lib Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,19 @@ class VideoManager extends ValueNotifier<VideoManagerState> {
1919 super .dispose ();
2020 }
2121
22- Future <VideoPlayerController > getOrCreateController (
22+ Future <VideoPlayerController > createOrReinitializeController (
2323 VideoCacheKey asset,
2424 ) async {
2525 final key = _createKey (asset.name, asset.package);
2626 if (value.controllers.containsKey (key)) {
27- return value.controllers[key]! ;
27+ final controller = value.controllers[key]! ;
28+
29+ // Re-initialize is needed to properly connect the cached controller
30+ // to a new VideoPlayer widget instance, even though controller state remains unchanged
31+ // it has to do with internal logic of VideoPlayer widget that is not exposed to us
32+ await controller.initialize ();
33+ await controller.play ();
34+ return controller;
2835 }
2936 final controller = await _initializeController (asset.name, package: asset.package);
3037
Original file line number Diff line number Diff line change @@ -58,6 +58,6 @@ class _VoicesVideoPlayerState extends State<VoicesVideoPlayer> with AutomaticKee
5858 }
5959
6060 Future <VideoPlayerController > _getController () {
61- return VideoManagerScope .of (context).getOrCreateController (widget.asset);
61+ return VideoManagerScope .of (context).createOrReinitializeController (widget.asset);
6262 }
6363}
You can’t perform that action at this time.
0 commit comments