Skip to content

Commit

Permalink
Merge pull request #82 from lamarios/fix/fix-player-full-screen
Browse files Browse the repository at this point in the history
fix player full screen
  • Loading branch information
lamarios authored Apr 2, 2023
2 parents 314c54a + 14f8117 commit 6b39315
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
13 changes: 12 additions & 1 deletion lib/controllers/miniPayerController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MiniPlayerController extends GetxController {
int selectedFullScreenIndex = 0;
bool isPip = false;
bool isHidden = true;
bool isFullScreen = false;
double progress = 0;
Video? currentlyPlaying;
double opacity = 0;
Expand All @@ -61,7 +62,11 @@ class MiniPlayerController extends GetxController {
}

bool handleBackButton(bool stopDefaultButtonEvent, RouteInfo info) {
if (!isMini) {
if (isFullScreen) {
isFullScreen = false;
update();
return false;
} else if (!isMini) {
// we block the backbutton behavior and we make the player small
showMiniPlayer();
return true;
Expand Down Expand Up @@ -309,6 +314,12 @@ class MiniPlayerController extends GetxController {
case BetterPlayerEventType.pipStop:
isPip = false;
break;
case BetterPlayerEventType.openFullscreen:
isFullScreen = true;
break;
case BetterPlayerEventType.hideFullscreen:
isFullScreen = false;
break;
default:
break;
}
Expand Down
8 changes: 6 additions & 2 deletions lib/controllers/playerController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class PlayerController extends GetxController {
break;
case BetterPlayerEventType.pipStart:
case BetterPlayerEventType.pipStop:
case BetterPlayerEventType.openFullscreen:
case BetterPlayerEventType.hideFullscreen:
MiniPlayerController.to()?.handleVideoEvent(event);
break;
default:
Expand All @@ -136,6 +138,8 @@ class PlayerController extends GetxController {
}

switchVideo(Video video) {
videoController?.exitFullScreen();
MiniPlayerController.to()?.handleVideoEvent(BetterPlayerEvent(BetterPlayerEventType.hideFullscreen));
disposeControllers();
this.video = video;
playVideo();
Expand Down Expand Up @@ -197,7 +201,6 @@ class PlayerController extends GetxController {
imageUrl: video.getBestThumbnail()?.url ?? '',
));


videoController = BetterPlayerController(
BetterPlayerConfiguration(
deviceOrientationsOnFullScreen: [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, DeviceOrientation.portraitDown, DeviceOrientation.portraitUp],
Expand All @@ -209,8 +212,9 @@ class PlayerController extends GetxController {
autoPlay: true,
allowedScreenSleep: false,
fit: BoxFit.contain,

controlsConfiguration: BetterPlayerControlsConfiguration(
enablePlayPause: false,
enablePlayPause: false,
overflowModalColor: colors.background,
overflowModalTextColor: overFlowTextColor,
overflowMenuIconsColor: overFlowTextColor,
Expand Down
5 changes: 2 additions & 3 deletions lib/views/miniPlayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../utils.dart';

class MiniPlayer extends StatelessWidget {
GlobalKey playerKey = GlobalKey();

MiniPlayer({Key? key}) : super(key: key);
const MiniPlayer({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -47,7 +46,7 @@ class MiniPlayer extends StatelessWidget {

return AnimatedPositioned(
left: 0,
top: _.top,
top: _.isFullScreen ? 10000 : _.top,
bottom: _.getBottom,
right: 0,
duration: _.isDragging ? Duration.zero : animationDuration,
Expand Down
4 changes: 2 additions & 2 deletions lib/views/video/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import '../../models/video.dart';
class VideoPlayer extends StatefulWidget {
final Video video;
final bool miniPlayer;
bool? playNow;
final bool? playNow;

VideoPlayer({super.key, required this.video, required this.miniPlayer, this.playNow});
const VideoPlayer({super.key, required this.video, required this.miniPlayer, this.playNow});

@override
State<VideoPlayer> createState() => VideoPlayerState();
Expand Down
26 changes: 13 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "98d1d33ed129b372846e862de23a0fc365745f4d7b5e786ce667fcbbb7ac5c07"
sha256: a36ec4843dc30ea6bf652bf25e3448db6c5e8bcf4aa55f063a5d1dad216d8214
url: "https://pub.dev"
source: hosted
version: "55.0.0"
version: "58.0.0"
after_layout:
dependency: "direct main"
description:
Expand All @@ -21,10 +21,10 @@ packages:
dependency: transitive
description:
name: analyzer
sha256: "881348aed9b0b425882c97732629a6a31093c8ff20fc4b3b03fb9d3d50a3a126"
sha256: cc4242565347e98424ce9945c819c192ec0838cb9d1f6aa4a97cc96becbc5b27
url: "https://pub.dev"
source: hosted
version: "5.7.1"
version: "5.10.0"
application_icon:
dependency: "direct main"
description:
Expand Down Expand Up @@ -70,7 +70,7 @@ packages:
description:
path: "."
ref: master
resolved-ref: "203c2cc45456b41743ef464bc5132701d06d0260"
resolved-ref: "7fa406a7689cd744baca81fd67d9c70efb55563a"
url: "https://github.com/lamarios/betterplayer.git"
source: git
version: "0.0.83"
Expand Down Expand Up @@ -674,10 +674,10 @@ packages:
dependency: transitive
description:
name: path_provider_foundation
sha256: "026b97a6c29da75181a37aae2eba9227f5fe13cb2838c6b975ce209328b8ab4e"
sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.2.1"
path_provider_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -738,10 +738,10 @@ packages:
dependency: transitive
description:
name: pointycastle
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
sha256: c3120a968135aead39699267f4c74bc9a08e4e909e86bc1b0af5bfd78691123c
url: "https://pub.dev"
source: hosted
version: "3.6.2"
version: "3.7.2"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -983,18 +983,18 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "845530e5e05db5500c1a4c1446785d60cbd8f9bd45e21e7dd643a3273bb4bbd1"
sha256: dd729390aa936bf1bdf5cd1bc7468ff340263f80a2c4f569416507667de8e3c8
url: "https://pub.dev"
source: hosted
version: "6.0.25"
version: "6.0.26"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "7ab1e5b646623d6a2537aa59d5d039f90eebef75a7c25e105f6f75de1f7750c3"
sha256: "3dedc66ca3c0bef9e6a93c0999aee102556a450afcc1b7bcfeace7a424927d92"
url: "https://pub.dev"
source: hosted
version: "6.1.2"
version: "6.1.3"
url_launcher_linux:
dependency: transitive
description:
Expand Down

0 comments on commit 6b39315

Please sign in to comment.