Skip to content

Commit a75b67c

Browse files
author
h.carnot
committed
feat: Make progressIndicatorDelay a Duration
1 parent 63b9756 commit a75b67c

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

example/lib/app/app.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ class _ChewieDemoState extends State<ChewieDemo> {
114114
videoPlayerController: _videoPlayerController1,
115115
autoPlay: true,
116116
looping: true,
117-
progressIndicatorDelayMs: bufferDelay,
117+
progressIndicatorDelay:
118+
bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null,
118119

119120
additionalOptions: (context) {
120121
return <OptionItem>[
@@ -314,7 +315,8 @@ class _ChewieDemoState extends State<ChewieDemo> {
314315
ListTile(
315316
title: const Text("Delay"),
316317
subtitle: DelaySlider(
317-
delay: _chewieController?.progressIndicatorDelayMs,
318+
delay:
319+
_chewieController?.progressIndicatorDelay?.inMilliseconds,
318320
onSave: (delay) async {
319321
if (delay != null) {
320322
bufferDelay = delay == 0 ? null : delay;

lib/src/chewie_player.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class ChewieController extends ChangeNotifier {
280280
this.systemOverlaysAfterFullScreen = SystemUiOverlay.values,
281281
this.deviceOrientationsAfterFullScreen = DeviceOrientation.values,
282282
this.routePageBuilder,
283+
this.progressIndicatorDelay,
283284
this.hideControlsTimer = defaultHideControlsTimer,
284285
this.progressIndicatorDelayMs,
285286
}) : assert(
@@ -325,7 +326,7 @@ class ChewieController extends ChangeNotifier {
325326
List<DeviceOrientation>? deviceOrientationsOnEnterFullScreen,
326327
List<SystemUiOverlay>? systemOverlaysAfterFullScreen,
327328
List<DeviceOrientation>? deviceOrientationsAfterFullScreen,
328-
int? progressIndicatorDelayMs,
329+
Duration? progressIndicatorDelay,
329330
Widget Function(
330331
BuildContext,
331332
Animation<double>,
@@ -379,8 +380,9 @@ class ChewieController extends ChangeNotifier {
379380
this.deviceOrientationsAfterFullScreen,
380381
routePageBuilder: routePageBuilder ?? this.routePageBuilder,
381382
hideControlsTimer: hideControlsTimer ?? this.hideControlsTimer,
382-
progressIndicatorDelayMs:
383-
progressIndicatorDelayMs ?? this.progressIndicatorDelayMs,
383+
progressIndicatorDelay:
384+
progressIndicatorDelay ?? this.progressIndicatorDelay,
385+
hideControlsTimer: hideControlsTimer ?? this.hideControlsTimer,
384386
);
385387
}
386388

@@ -518,7 +520,7 @@ class ChewieController extends ChangeNotifier {
518520
final ChewieRoutePageBuilder? routePageBuilder;
519521

520522
/// [Android] Defines a delay in milliseconds between entering buffering state and displaying the loading spinner. Set null (default) to disable it.
521-
final int? progressIndicatorDelayMs;
523+
final Duration? progressIndicatorDelay;
522524

523525
static ChewieController of(BuildContext context) {
524526
final chewieControllerProvider =

lib/src/material/material_controls.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,10 @@ class _MaterialControlsState extends State<MaterialControls>
564564
if (!mounted) return;
565565

566566
// display the progress bar indicator only after the buffering delay if it has been set
567-
if (chewieController.progressIndicatorDelayMs != null) {
567+
if (chewieController.progressIndicatorDelay != null) {
568568
if (controller.value.isBuffering) {
569569
timerInstance ??= Timer(
570-
Duration(
571-
milliseconds: chewieController.progressIndicatorDelayMs!,
572-
),
570+
chewieController.progressIndicatorDelay!,
573571
handleTimeout,
574572
);
575573
} else {

0 commit comments

Comments
 (0)