Skip to content

Commit

Permalink
feat: replaced wakelock
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Nov 12, 2023
1 parent 839b85e commit 00ea930
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 106 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.1.0
* Updated ExoPlayer version to 2.19.1
* Updated Kotlin version to 1.8.22.
* Replaced wakelock with wakelock_plus.

## 0.0.83
* Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

defaultConfig {
minSdkVersion 16
minSdkVersion 19
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {

defaultConfig {
applicationId "com.jhomlala.better_player_example"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
9 changes: 5 additions & 4 deletions lib/src/core/better_player.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'dart:async';

import 'package:better_player/better_player.dart';
import 'package:better_player/src/configuration/better_player_controller_event.dart';
import 'package:better_player/src/core/better_player_utils.dart';
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 00ea930

Please sign in to comment.