Skip to content

Commit 87fa77d

Browse files
authored
fix(cat-voices): freezed video (#2756)
* fix: freezed video * chore: rename function to more meaningful name
1 parent 9c701cc commit 87fa77d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

catalyst_voices/apps/voices/lib/app/view/video_cache/app_video_manager.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff 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

catalyst_voices/apps/voices/lib/widgets/video/video_player.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)