Skip to content

Commit

Permalink
Merge pull request fluttercommunity#192 from cbenhagen/showControlsOn…
Browse files Browse the repository at this point in the history
…Initialize

Add showControlsOnInitialize property
  • Loading branch information
cbenhagen authored Sep 5, 2019
2 parents 699feb7 + ab9277d commit e518f9c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 5 additions & 1 deletion lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ChewieController extends ChangeNotifier {
this.materialProgressColors,
this.placeholder,
this.overlay,
this.showControlsOnInitialize = true,
this.showControls = true,
this.customControls,
this.errorBuilder,
Expand Down Expand Up @@ -213,7 +214,10 @@ class ChewieController extends ChangeNotifier {
/// Whether or not the video should loop
final bool looping;

/// Whether or not to show the controls
/// Weather or not to show the controls when initializing the widget.
final bool showControlsOnInitialize;

/// Whether or not to show the controls at all
final bool showControls;

/// Defines customised controls. Check [MaterialControls] or
Expand Down
10 changes: 6 additions & 4 deletions lib/src/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,13 @@ class _CupertinoControlsState extends State<CupertinoControls> {
_startHideTimer();
}

_initTimer = Timer(Duration(milliseconds: 200), () {
setState(() {
_hideStuff = false;
if (chewieController.showControlsOnInitialize) {
_initTimer = Timer(Duration(milliseconds: 200), () {
setState(() {
_hideStuff = false;
});
});
});
}
}

void _onExpandCollapse() {
Expand Down
14 changes: 8 additions & 6 deletions lib/src/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _MaterialControlsState extends State<MaterialControls> {
double _latestVolume;
bool _hideStuff = true;
Timer _hideTimer;
Timer _showTimer;
Timer _initTimer;
Timer _showAfterExpandCollapseTimer;
bool _dragging = false;

Expand Down Expand Up @@ -85,7 +85,7 @@ class _MaterialControlsState extends State<MaterialControls> {
void _dispose() {
controller.removeListener(_updateState);
_hideTimer?.cancel();
_showTimer?.cancel();
_initTimer?.cancel();
_showAfterExpandCollapseTimer?.cancel();
}

Expand Down Expand Up @@ -291,11 +291,13 @@ class _MaterialControlsState extends State<MaterialControls> {
_startHideTimer();
}

_showTimer = Timer(Duration(milliseconds: 200), () {
setState(() {
_hideStuff = false;
if (chewieController.showControlsOnInitialize) {
_initTimer = Timer(Duration(milliseconds: 200), () {
setState(() {
_hideStuff = false;
});
});
});
}
}

void _onExpandCollapse() {
Expand Down

0 comments on commit e518f9c

Please sign in to comment.