Skip to content

Commit

Permalink
wakelock fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
afrah-tezda committed Sep 12, 2024
1 parent edb6d13 commit 1667ee6
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 105 deletions.
9 changes: 5 additions & 4 deletions lib/src/core/better_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:better_player/src/core/better_player_with_controls.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:visibility_detector/visibility_detector.dart';
import 'package:wakelock/wakelock.dart';
import 'package:wakelock_plus/wakelock_plus.dart';


///Widget which uses provided controller to render video player.
class BetterPlayer extends StatefulWidget {
Expand Down Expand Up @@ -102,7 +103,7 @@ class _BetterPlayerState extends State<BetterPlayer>
///full screen is on, then full screen route must be pop and return to normal
///state.
if (_isFullScreen) {
Wakelock.disable();
WakelockPlus.disable();
_navigatorState.maybePop();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: _betterPlayerConfiguration.systemOverlaysAfterFullScreen);
Expand Down Expand Up @@ -244,7 +245,7 @@ class _BetterPlayerState extends State<BetterPlayer>
}

if (!_betterPlayerConfiguration.allowedScreenSleep) {
Wakelock.enable();
WakelockPlus.enable();
}

await Navigator.of(context, rootNavigator: true).push(route);
Expand All @@ -253,7 +254,7 @@ class _BetterPlayerState extends State<BetterPlayer>

// The wakelock plugins checks whether it needs to perform an action internally,
// so we do not need to check Wakelock.isEnabled.
Wakelock.disable();
WakelockPlus.disable();

await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: _betterPlayerConfiguration.systemOverlaysAfterFullScreen);
Expand Down
Loading

0 comments on commit 1667ee6

Please sign in to comment.