|
@@ -6,7 +6,9 @@ import 'package:video_player/video_player.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
void main() {
|
|
|
runApp(
|
|
runApp(
|
|
|
- ChewieDemo(),
|
|
|
|
|
|
|
+ MaterialApp(
|
|
|
|
|
+ home: ChewieDemo(),
|
|
|
|
|
+ )
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -26,33 +28,30 @@ class _ChewieDemoState extends State<ChewieDemo> {
|
|
|
VideoPlayerController _videoPlayerController1;
|
|
VideoPlayerController _videoPlayerController1;
|
|
|
VideoPlayerController _videoPlayerController2;
|
|
VideoPlayerController _videoPlayerController2;
|
|
|
ChewieController _chewieController;
|
|
ChewieController _chewieController;
|
|
|
|
|
+ double aspectRatio=1;
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
|
super.initState();
|
|
super.initState();
|
|
|
_videoPlayerController1 = VideoPlayerController.network(
|
|
_videoPlayerController1 = VideoPlayerController.network(
|
|
|
- 'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4');
|
|
|
|
|
|
|
+ 'https://v-cdn.zjol.com.cn/276998.mp4')
|
|
|
|
|
+ ..initialize().then((_){
|
|
|
|
|
+ _chewieController = ChewieController(
|
|
|
|
|
+ videoPlayerController: _videoPlayerController1,
|
|
|
|
|
+ allowedScreenSleep: false,
|
|
|
|
|
+ aspectRatio: _videoPlayerController1.value.aspectRatio,
|
|
|
|
|
+ autoPlay: true,
|
|
|
|
|
+ looping: true,
|
|
|
|
|
+ );
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
_videoPlayerController2 = VideoPlayerController.network(
|
|
_videoPlayerController2 = VideoPlayerController.network(
|
|
|
- 'https://www.sample-videos.com/video123/mp4/480/asdasdas.mp4');
|
|
|
|
|
- _chewieController = ChewieController(
|
|
|
|
|
- videoPlayerController: _videoPlayerController1,
|
|
|
|
|
- aspectRatio: 3 / 2,
|
|
|
|
|
- autoPlay: true,
|
|
|
|
|
- looping: 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,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ 'https://v-cdn.zjol.com.cn/276985.mp4')
|
|
|
|
|
+ ..initialize().then((_){
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -71,100 +70,18 @@ class _ChewieDemoState extends State<ChewieDemo> {
|
|
|
platform: _platform ?? Theme.of(context).platform,
|
|
platform: _platform ?? Theme.of(context).platform,
|
|
|
),
|
|
),
|
|
|
home: Scaffold(
|
|
home: Scaffold(
|
|
|
- appBar: AppBar(
|
|
|
|
|
- title: Text(widget.title),
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+// appBar: AppBar(
|
|
|
|
|
+// title: Text(widget.title),
|
|
|
|
|
+// ),
|
|
|
body: Column(
|
|
body: Column(
|
|
|
children: <Widget>[
|
|
children: <Widget>[
|
|
|
- Expanded(
|
|
|
|
|
- child: Center(
|
|
|
|
|
- child: Chewie(
|
|
|
|
|
- controller: _chewieController,
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ Container(
|
|
|
|
|
+ constraints: BoxConstraints(maxHeight: 300),
|
|
|
|
|
+ child: _chewieController == null ? Container() : Chewie(
|
|
|
|
|
+ controller: _chewieController,
|
|
|
),
|
|
),
|
|
|
|
|
+ color: Colors.black,
|
|
|
),
|
|
),
|
|
|
- FlatButton(
|
|
|
|
|
- onPressed: () {
|
|
|
|
|
- _chewieController.enterFullScreen();
|
|
|
|
|
- },
|
|
|
|
|
- child: Text('Fullscreen'),
|
|
|
|
|
- ),
|
|
|
|
|
- Row(
|
|
|
|
|
- children: <Widget>[
|
|
|
|
|
- Expanded(
|
|
|
|
|
- child: FlatButton(
|
|
|
|
|
- onPressed: () {
|
|
|
|
|
- setState(() {
|
|
|
|
|
- _chewieController.dispose();
|
|
|
|
|
- _videoPlayerController2.pause();
|
|
|
|
|
- _videoPlayerController2.seekTo(Duration(seconds: 0));
|
|
|
|
|
- _chewieController = ChewieController(
|
|
|
|
|
- videoPlayerController: _videoPlayerController1,
|
|
|
|
|
- aspectRatio: 3 / 2,
|
|
|
|
|
- autoPlay: true,
|
|
|
|
|
- looping: true,
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- child: Padding(
|
|
|
|
|
- child: Text("Video 1"),
|
|
|
|
|
- padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- Expanded(
|
|
|
|
|
- child: FlatButton(
|
|
|
|
|
- onPressed: () {
|
|
|
|
|
- setState(() {
|
|
|
|
|
- _chewieController.dispose();
|
|
|
|
|
- _videoPlayerController1.pause();
|
|
|
|
|
- _videoPlayerController1.seekTo(Duration(seconds: 0));
|
|
|
|
|
- _chewieController = ChewieController(
|
|
|
|
|
- videoPlayerController: _videoPlayerController2,
|
|
|
|
|
- aspectRatio: 3 / 2,
|
|
|
|
|
- autoPlay: true,
|
|
|
|
|
- looping: true,
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- child: Padding(
|
|
|
|
|
- padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
- child: Text("Error Video"),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- )
|
|
|
|
|
- ],
|
|
|
|
|
- ),
|
|
|
|
|
- Row(
|
|
|
|
|
- children: <Widget>[
|
|
|
|
|
- Expanded(
|
|
|
|
|
- child: FlatButton(
|
|
|
|
|
- onPressed: () {
|
|
|
|
|
- setState(() {
|
|
|
|
|
- _platform = TargetPlatform.android;
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- child: Padding(
|
|
|
|
|
- child: Text("Android controls"),
|
|
|
|
|
- padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- Expanded(
|
|
|
|
|
- child: FlatButton(
|
|
|
|
|
- onPressed: () {
|
|
|
|
|
- setState(() {
|
|
|
|
|
- _platform = TargetPlatform.iOS;
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- child: Padding(
|
|
|
|
|
- padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
- child: Text("iOS controls"),
|
|
|
|
|
- ),
|
|
|
|
|
- ),
|
|
|
|
|
- )
|
|
|
|
|
- ],
|
|
|
|
|
- )
|
|
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|