|
@@ -1,5 +1,4 @@
|
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
|
-import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:chewie/src/chewie_progress_colors.dart';
|
|
import 'package:chewie/src/chewie_progress_colors.dart';
|
|
|
import 'package:chewie/src/player_with_controls.dart';
|
|
import 'package:chewie/src/player_with_controls.dart';
|
|
@@ -41,12 +40,6 @@ class ChewieState extends State<Chewie> {
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
|
super.initState();
|
|
super.initState();
|
|
|
- if (widget.controller.fullScreenByDefault) {
|
|
|
|
|
- Future.delayed(Duration.zero).then((_){
|
|
|
|
|
- _isFullScreen = true;
|
|
|
|
|
- _pushFullScreenWidget(context);
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
widget.controller.addListener(listener);
|
|
widget.controller.addListener(listener);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -69,9 +62,7 @@ class ChewieState extends State<Chewie> {
|
|
|
_isFullScreen = true;
|
|
_isFullScreen = true;
|
|
|
await _pushFullScreenWidget(context);
|
|
await _pushFullScreenWidget(context);
|
|
|
} else if (_isFullScreen) {
|
|
} else if (_isFullScreen) {
|
|
|
- if (!widget.controller.forceFullScreen) {
|
|
|
|
|
- Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Navigator.of(context, rootNavigator: true).pop();
|
|
|
_isFullScreen = false;
|
|
_isFullScreen = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -88,23 +79,16 @@ class ChewieState extends State<Chewie> {
|
|
|
BuildContext context,
|
|
BuildContext context,
|
|
|
Animation<double> animation,
|
|
Animation<double> animation,
|
|
|
_ChewieControllerProvider controllerProvider) {
|
|
_ChewieControllerProvider controllerProvider) {
|
|
|
- return WillPopScope(
|
|
|
|
|
- child: Scaffold(
|
|
|
|
|
- resizeToAvoidBottomPadding: false,
|
|
|
|
|
- body: Container(
|
|
|
|
|
- alignment: Alignment.center,
|
|
|
|
|
- color: Colors.black,
|
|
|
|
|
- child: controllerProvider,
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- onWillPop: _onPop,
|
|
|
|
|
|
|
+ return Scaffold(
|
|
|
|
|
+ resizeToAvoidBottomPadding: false,
|
|
|
|
|
+ body: Container(
|
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
|
+ color: Colors.black,
|
|
|
|
|
+ child: controllerProvider,
|
|
|
|
|
+ ),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Future<bool> _onPop() async {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
AnimatedWidget _defaultRoutePageBuilder(
|
|
AnimatedWidget _defaultRoutePageBuilder(
|
|
|
BuildContext context,
|
|
BuildContext context,
|
|
|
Animation<double> animation,
|
|
Animation<double> animation,
|
|
@@ -119,10 +103,10 @@ class ChewieState extends State<Chewie> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Widget _fullScreenRoutePageBuilder(
|
|
Widget _fullScreenRoutePageBuilder(
|
|
|
- BuildContext context,
|
|
|
|
|
- Animation<double> animation,
|
|
|
|
|
- Animation<double> secondaryAnimation,
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ BuildContext context,
|
|
|
|
|
+ Animation<double> animation,
|
|
|
|
|
+ Animation<double> secondaryAnimation,
|
|
|
|
|
+ ) {
|
|
|
var controllerProvider = _ChewieControllerProvider(
|
|
var controllerProvider = _ChewieControllerProvider(
|
|
|
controller: widget.controller,
|
|
controller: widget.controller,
|
|
|
child: PlayerWithControls(),
|
|
child: PlayerWithControls(),
|
|
@@ -144,26 +128,21 @@ class ChewieState extends State<Chewie> {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
SystemChrome.setEnabledSystemUIOverlays([]);
|
|
SystemChrome.setEnabledSystemUIOverlays([]);
|
|
|
- /// ?????????????????????????????????????
|
|
|
|
|
|
|
+ if (isAndroid) {
|
|
|
SystemChrome.setPreferredOrientations([
|
|
SystemChrome.setPreferredOrientations([
|
|
|
DeviceOrientation.landscapeLeft,
|
|
DeviceOrientation.landscapeLeft,
|
|
|
DeviceOrientation.landscapeRight,
|
|
DeviceOrientation.landscapeRight,
|
|
|
]);
|
|
]);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (!widget.controller.allowedScreenSleep) {
|
|
if (!widget.controller.allowedScreenSleep) {
|
|
|
Wakelock.enable();
|
|
Wakelock.enable();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// not work yet
|
|
|
|
|
-// if (widget.controller.forceFullScreen) {
|
|
|
|
|
-// await Navigator.pushAndRemoveUntil(context, route, (Route route) => route == null);
|
|
|
|
|
-// } else {
|
|
|
|
|
- await Navigator.of(context, rootNavigator: true).push(route);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ await Navigator.of(context, rootNavigator: true).push(route);
|
|
|
_isFullScreen = false;
|
|
_isFullScreen = false;
|
|
|
widget.controller.exitFullScreen();
|
|
widget.controller.exitFullScreen();
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// The wakelock plugins checks whether it needs to perform an action internally,
|
|
// The wakelock plugins checks whether it needs to perform an action internally,
|
|
|
// so we do not need to check Wakelock.isEnabled.
|
|
// so we do not need to check Wakelock.isEnabled.
|
|
|
Wakelock.disable();
|
|
Wakelock.disable();
|
|
@@ -206,7 +185,6 @@ class ChewieController extends ChangeNotifier {
|
|
|
this.isLive = false,
|
|
this.isLive = false,
|
|
|
this.allowFullScreen = true,
|
|
this.allowFullScreen = true,
|
|
|
this.allowMuting = true,
|
|
this.allowMuting = true,
|
|
|
- this.forceFullScreen = false,
|
|
|
|
|
this.systemOverlaysAfterFullScreen = SystemUiOverlay.values,
|
|
this.systemOverlaysAfterFullScreen = SystemUiOverlay.values,
|
|
|
this.deviceOrientationsAfterFullScreen = const [
|
|
this.deviceOrientationsAfterFullScreen = const [
|
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.portraitUp,
|
|
@@ -216,7 +194,7 @@ class ChewieController extends ChangeNotifier {
|
|
|
],
|
|
],
|
|
|
this.routePageBuilder = null,
|
|
this.routePageBuilder = null,
|
|
|
}) : assert(videoPlayerController != null,
|
|
}) : assert(videoPlayerController != null,
|
|
|
- 'You must provide a controller to play a video') {
|
|
|
|
|
|
|
+ 'You must provide a controller to play a video') {
|
|
|
_initialize();
|
|
_initialize();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -285,9 +263,6 @@ class ChewieController extends ChangeNotifier {
|
|
|
/// Defines if the mute control should be shown
|
|
/// Defines if the mute control should be shown
|
|
|
final bool allowMuting;
|
|
final bool allowMuting;
|
|
|
|
|
|
|
|
- /// Defines if force full screen
|
|
|
|
|
- final bool forceFullScreen;
|
|
|
|
|
-
|
|
|
|
|
/// Defines the system overlays visible after exiting fullscreen
|
|
/// Defines the system overlays visible after exiting fullscreen
|
|
|
final List<SystemUiOverlay> systemOverlaysAfterFullScreen;
|
|
final List<SystemUiOverlay> systemOverlaysAfterFullScreen;
|
|
|
|
|
|
|
@@ -299,8 +274,8 @@ class ChewieController extends ChangeNotifier {
|
|
|
|
|
|
|
|
static ChewieController of(BuildContext context) {
|
|
static ChewieController of(BuildContext context) {
|
|
|
final chewieControllerProvider =
|
|
final chewieControllerProvider =
|
|
|
- context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
|
|
|
|
|
- as _ChewieControllerProvider;
|
|
|
|
|
|
|
+ context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
|
|
|
|
|
+ as _ChewieControllerProvider;
|
|
|
|
|
|
|
|
return chewieControllerProvider.controller;
|
|
return chewieControllerProvider.controller;
|
|
|
}
|
|
}
|
|
@@ -391,4 +366,4 @@ class _ChewieControllerProvider extends InheritedWidget {
|
|
|
@override
|
|
@override
|
|
|
bool updateShouldNotify(_ChewieControllerProvider old) =>
|
|
bool updateShouldNotify(_ChewieControllerProvider old) =>
|
|
|
controller != old.controller;
|
|
controller != old.controller;
|
|
|
-}
|
|
|
|
|
|
|
+}
|