Skip to content

Commit b4c3a0c

Browse files
authored
Merge pull request #838 from daniellampl/master
Add bufferingBuilder
2 parents f58a650 + 1383b60 commit b4c3a0c

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

lib/src/chewie_player.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ class ChewieController extends ChangeNotifier {
289289
this.subtitleBuilder,
290290
this.customControls,
291291
this.errorBuilder,
292+
this.bufferingBuilder,
292293
this.allowedScreenSleep = true,
293294
this.isLive = false,
294295
this.allowFullScreen = true,
@@ -336,6 +337,7 @@ class ChewieController extends ChangeNotifier {
336337
Subtitles? subtitle,
337338
Widget Function(BuildContext, dynamic)? subtitleBuilder,
338339
Widget? customControls,
340+
WidgetBuilder? bufferingBuilder,
339341
Widget Function(BuildContext, String)? errorBuilder,
340342
bool? allowedScreenSleep,
341343
bool? isLive,
@@ -385,6 +387,7 @@ class ChewieController extends ChangeNotifier {
385387
subtitleBuilder: subtitleBuilder ?? this.subtitleBuilder,
386388
customControls: customControls ?? this.customControls,
387389
errorBuilder: errorBuilder ?? this.errorBuilder,
390+
bufferingBuilder: bufferingBuilder ?? this.bufferingBuilder,
388391
allowedScreenSleep: allowedScreenSleep ?? this.allowedScreenSleep,
389392
isLive: isLive ?? this.isLive,
390393
allowFullScreen: allowFullScreen ?? this.allowFullScreen,
@@ -485,6 +488,9 @@ class ChewieController extends ChangeNotifier {
485488
final Widget Function(BuildContext context, String errorMessage)?
486489
errorBuilder;
487490

491+
/// When the video is buffering, you can build a custom widget.
492+
final WidgetBuilder? bufferingBuilder;
493+
488494
/// The Aspect Ratio of the Video. Important to get the correct size of the
489495
/// video!
490496
///

lib/src/cupertino/cupertino_controls.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ class _CupertinoControlsState extends State<CupertinoControls>
9494
child: Stack(
9595
children: [
9696
if (_displayBufferingIndicator)
97-
const Center(
98-
child: CircularProgressIndicator(),
99-
)
97+
_chewieController?.bufferingBuilder?.call(context) ??
98+
const Center(
99+
child: CircularProgressIndicator(),
100+
)
100101
else
101102
_buildHitArea(),
102103
Column(

lib/src/material/material_controls.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ class _MaterialControlsState extends State<MaterialControls>
8585
child: Stack(
8686
children: [
8787
if (_displayBufferingIndicator)
88-
const Center(
89-
child: CircularProgressIndicator(),
90-
)
88+
_chewieController?.bufferingBuilder?.call(context) ??
89+
const Center(
90+
child: CircularProgressIndicator(),
91+
)
9192
else
9293
_buildHitArea(),
9394
_buildActionBar(),

lib/src/material/material_desktop_controls.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
8686
child: Stack(
8787
children: [
8888
if (_displayBufferingIndicator)
89-
const Center(
90-
child: CircularProgressIndicator(),
91-
)
89+
_chewieController?.bufferingBuilder?.call(context) ??
90+
const Center(
91+
child: CircularProgressIndicator(),
92+
)
9293
else
9394
_buildHitArea(),
9495
Column(

0 commit comments

Comments
 (0)