Skip to content

Commit

Permalink
Merge pull request #838 from daniellampl/master
Browse files Browse the repository at this point in the history
Add bufferingBuilder
  • Loading branch information
Ahmadre authored Sep 3, 2024
2 parents f58a650 + 1383b60 commit b4c3a0c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 6 additions & 0 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class ChewieController extends ChangeNotifier {
this.subtitleBuilder,
this.customControls,
this.errorBuilder,
this.bufferingBuilder,
this.allowedScreenSleep = true,
this.isLive = false,
this.allowFullScreen = true,
Expand Down Expand Up @@ -336,6 +337,7 @@ class ChewieController extends ChangeNotifier {
Subtitles? subtitle,
Widget Function(BuildContext, dynamic)? subtitleBuilder,
Widget? customControls,
WidgetBuilder? bufferingBuilder,
Widget Function(BuildContext, String)? errorBuilder,
bool? allowedScreenSleep,
bool? isLive,
Expand Down Expand Up @@ -385,6 +387,7 @@ class ChewieController extends ChangeNotifier {
subtitleBuilder: subtitleBuilder ?? this.subtitleBuilder,
customControls: customControls ?? this.customControls,
errorBuilder: errorBuilder ?? this.errorBuilder,
bufferingBuilder: bufferingBuilder ?? this.bufferingBuilder,
allowedScreenSleep: allowedScreenSleep ?? this.allowedScreenSleep,
isLive: isLive ?? this.isLive,
allowFullScreen: allowFullScreen ?? this.allowFullScreen,
Expand Down Expand Up @@ -485,6 +488,9 @@ class ChewieController extends ChangeNotifier {
final Widget Function(BuildContext context, String errorMessage)?
errorBuilder;

/// When the video is buffering, you can build a custom widget.
final WidgetBuilder? bufferingBuilder;

/// The Aspect Ratio of the Video. Important to get the correct size of the
/// video!
///
Expand Down
7 changes: 4 additions & 3 deletions lib/src/cupertino/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ class _CupertinoControlsState extends State<CupertinoControls>
child: Stack(
children: [
if (_displayBufferingIndicator)
const Center(
child: CircularProgressIndicator(),
)
_chewieController?.bufferingBuilder?.call(context) ??
const Center(
child: CircularProgressIndicator(),
)
else
_buildHitArea(),
Column(
Expand Down
7 changes: 4 additions & 3 deletions lib/src/material/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ class _MaterialControlsState extends State<MaterialControls>
child: Stack(
children: [
if (_displayBufferingIndicator)
const Center(
child: CircularProgressIndicator(),
)
_chewieController?.bufferingBuilder?.call(context) ??
const Center(
child: CircularProgressIndicator(),
)
else
_buildHitArea(),
_buildActionBar(),
Expand Down
7 changes: 4 additions & 3 deletions lib/src/material/material_desktop_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
child: Stack(
children: [
if (_displayBufferingIndicator)
const Center(
child: CircularProgressIndicator(),
)
_chewieController?.bufferingBuilder?.call(context) ??
const Center(
child: CircularProgressIndicator(),
)
else
_buildHitArea(),
Column(
Expand Down

0 comments on commit b4c3a0c

Please sign in to comment.