|
|
@@ -1,10 +1,10 @@
|
|
|
+import 'package:auto_orientation/auto_orientation.dart';
|
|
|
import 'package:chewie/chewie.dart';
|
|
|
import 'package:chewie/src/chewie_player.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
-import 'package:auto_orientation/auto_orientation.dart';
|
|
|
|
|
|
void main() {
|
|
|
runApp(
|
|
|
@@ -37,41 +37,42 @@ class _ChewieDemoState extends State<ChewieDemo> {
|
|
|
_videoPlayerController2 = VideoPlayerController.network(
|
|
|
'https://www.sample-videos.com/video123/mp4/480/big_buck_bunny_480p_20mb.mp4');
|
|
|
_chewieController = ChewieController(
|
|
|
- videoPlayerController: _videoPlayerController1,
|
|
|
- aspectRatio: 3 / 2,
|
|
|
- autoPlay: true,
|
|
|
- looping: true,
|
|
|
- routePageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondAnimation, provider) {
|
|
|
- return AnimatedBuilder(
|
|
|
- animation: animation,
|
|
|
- builder: (BuildContext context, Widget child) {
|
|
|
- return VideoScaffold(
|
|
|
- child: Scaffold(
|
|
|
- resizeToAvoidBottomPadding: false,
|
|
|
- body: Container(
|
|
|
- alignment: Alignment.center,
|
|
|
- color: Colors.black,
|
|
|
- child: provider,
|
|
|
+ videoPlayerController: _videoPlayerController1,
|
|
|
+ aspectRatio: 3 / 2,
|
|
|
+ autoPlay: true,
|
|
|
+ looping: true,
|
|
|
+ routePageBuilder: (BuildContext context, Animation<double> animation,
|
|
|
+ Animation<double> secondAnimation, provider) {
|
|
|
+ return AnimatedBuilder(
|
|
|
+ animation: animation,
|
|
|
+ builder: (BuildContext context, Widget child) {
|
|
|
+ return VideoScaffold(
|
|
|
+ child: Scaffold(
|
|
|
+ resizeToAvoidBottomPadding: false,
|
|
|
+ body: Container(
|
|
|
+ alignment: Alignment.center,
|
|
|
+ color: Colors.black,
|
|
|
+ child: provider,
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- );
|
|
|
- },
|
|
|
+ );
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+ // Try playing around with some of these other options:
|
|
|
+
|
|
|
+ // showControls: false,
|
|
|
+ // materialProgressColors: ChewieProgressColors(
|
|
|
+ // playedColor: Colors.red,
|
|
|
+ // handleColor: Colors.blue,
|
|
|
+ // backgroundColor: Colors.grey,
|
|
|
+ // bufferedColor: Colors.lightGreen,
|
|
|
+ // ),
|
|
|
+ // placeholder: Container(
|
|
|
+ // color: Colors.grey,
|
|
|
+ // ),
|
|
|
+ // autoInitialize: true,
|
|
|
);
|
|
|
- }
|
|
|
- // Try playing around with some of these other options:
|
|
|
-
|
|
|
- // showControls: false,
|
|
|
- // materialProgressColors: ChewieProgressColors(
|
|
|
- // playedColor: Colors.red,
|
|
|
- // handleColor: Colors.blue,
|
|
|
- // backgroundColor: Colors.grey,
|
|
|
- // bufferedColor: Colors.lightGreen,
|
|
|
- // ),
|
|
|
- // placeholder: Container(
|
|
|
- // color: Colors.grey,
|
|
|
- // ),
|
|
|
- // autoInitialize: true,
|
|
|
- );
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -192,16 +193,15 @@ class _ChewieDemoState extends State<ChewieDemo> {
|
|
|
}
|
|
|
|
|
|
class VideoScaffold extends StatefulWidget {
|
|
|
- final Widget child;
|
|
|
-
|
|
|
const VideoScaffold({Key key, this.child}) : super(key: key);
|
|
|
|
|
|
+ final Widget child;
|
|
|
+
|
|
|
@override
|
|
|
State<StatefulWidget> createState() => _VideoScaffoldState();
|
|
|
}
|
|
|
|
|
|
class _VideoScaffoldState extends State<VideoScaffold> {
|
|
|
-
|
|
|
@override
|
|
|
void initState() {
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
@@ -213,7 +213,7 @@ class _VideoScaffoldState extends State<VideoScaffold> {
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
- dispose(){
|
|
|
+ dispose() {
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
DeviceOrientation.portraitUp,
|
|
|
DeviceOrientation.portraitDown,
|