Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlalabsg committed Aug 1, 2020
2 parents 64f44fb + 23b0518 commit f92a95b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.12
* Fixed duration called on null
* Added new control events

## 0.0.11
* Fixed iOS crash on dispose
* Added player headers support
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ This plugin is based on [Chewie](https://github.com/brianegan/chewie). Chewie is
✔️ Refactored player controls
✔️ Playlist support
✔️ Video in ListView support
✔️ Subtitles support (HTML tags support)
✔️ Headers support
✔️ Subtitles support (HTML tags support)
✔️ Headers support


## Install
Expand Down
2 changes: 2 additions & 0 deletions lib/src/configuration/better_player_event_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ enum BetterPlayerEventType {
PROGRESS,
FINISHED,
EXCEPTION,
CONTROLS_VISIBLE,
CONTROLS_HIDDEN,
}
7 changes: 6 additions & 1 deletion lib/src/controls/better_player_material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ class _BetterPlayerMaterialControlsState
}

void _onPlayPause() {
bool isFinished = _latestValue.position >= _latestValue.duration;
bool isFinished = false;

if (_latestValue?.position != null && _latestValue?.duration != null) {
isFinished = _latestValue.position >= _latestValue.duration;
}

setState(() {
if (_controller.value.isPlaying) {
Expand Down Expand Up @@ -491,6 +495,7 @@ class _BetterPlayerMaterialControlsState
}

void _onPlayerHide() {
_betterPlayerController.toggleControlsVisibility(!_hideStuff);
widget.onControlsVisibilityChanged(!_hideStuff);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ class BetterPlayerController extends ChangeNotifier {
return videoPlayerController.value.isBuffering;
}

void toggleControlsVisibility(bool isVisible) {
_postEvent(isVisible
? BetterPlayerEvent(BetterPlayerEventType.CONTROLS_VISIBLE)
: BetterPlayerEvent(BetterPlayerEventType.CONTROLS_HIDDEN));
}

void _postEvent(BetterPlayerEvent betterPlayerEvent) {
for (Function eventListener in _eventListeners) {
if (eventListener != null) {
Expand Down

0 comments on commit f92a95b

Please sign in to comment.