@@ -23,15 +23,20 @@ class ApiVideoPlayer extends StatefulWidget {
23
23
{super .key,
24
24
required this .controller,
25
25
this .fit = BoxFit .contain,
26
+ this .controlsVisibilityDuration = const Duration (seconds: 4 ),
26
27
this .style,
27
28
this .child});
28
29
29
30
/// Creates a player with api.video style.
30
31
factory ApiVideoPlayer .styleFromApiVideo (
31
- {Key ? key, required ApiVideoPlayerController controller, Widget ? child}) {
32
+ {Key ? key,
33
+ required ApiVideoPlayerController controller,
34
+ Duration controlsVisibilityDuration = const Duration (seconds: 4 ),
35
+ Widget ? child}) {
32
36
return ApiVideoPlayer (
33
37
key: key,
34
38
controller: controller,
39
+ controlsVisibilityDuration: controlsVisibilityDuration,
35
40
style: PlayerStyle .defaultStyle,
36
41
child: child);
37
42
}
@@ -45,6 +50,9 @@ class ApiVideoPlayer extends StatefulWidget {
45
50
/// The controller for the player.
46
51
final ApiVideoPlayerController controller;
47
52
53
+ /// The duration to wait before hiding the controls.
54
+ final Duration controlsVisibilityDuration;
55
+
48
56
/// The style of the player.
49
57
final PlayerStyle ? style;
50
58
@@ -60,7 +68,8 @@ class ApiVideoPlayer extends StatefulWidget {
60
68
}
61
69
62
70
class _ApiVideoPlayerState extends State <ApiVideoPlayer > {
63
- final _opacityController = TimedOpacityController ();
71
+ late final _opacityController =
72
+ TimedOpacityController (duration: widget.controlsVisibilityDuration);
64
73
65
74
@override
66
75
Widget build (BuildContext context) {
@@ -77,4 +86,10 @@ class _ApiVideoPlayerState extends State<ApiVideoPlayer> {
77
86
_opacityController.showForDuration ();
78
87
})));
79
88
}
89
+
90
+ @override
91
+ void dispose () {
92
+ _opacityController.dispose ();
93
+ super .dispose ();
94
+ }
80
95
}
0 commit comments