main.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import 'package:chewie/chewie.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:video_player/video_player.dart';
  5. void main() => runApp(new ChewieDemo());
  6. class ChewieDemo extends StatefulWidget {
  7. final String title;
  8. ChewieDemo({this.title = 'Chewie Demo'});
  9. @override
  10. State<StatefulWidget> createState() {
  11. return new _ChewieDemoState();
  12. }
  13. }
  14. class _ChewieDemoState extends State<ChewieDemo> {
  15. TargetPlatform _platform;
  16. VideoPlayerController controller;
  17. @override
  18. Widget build(BuildContext context) {
  19. return new MaterialApp(
  20. title: widget.title,
  21. theme: new ThemeData.light().copyWith(
  22. platform: _platform ?? Theme.of(context).platform,
  23. ),
  24. home: new Scaffold(
  25. appBar: new AppBar(
  26. title: new Text(widget.title),
  27. ),
  28. body: new Column(
  29. children: <Widget>[
  30. new Expanded(
  31. child: new Center(
  32. child: new Chewie(
  33. controller,
  34. aspectRatio: 3 / 2,
  35. autoPlay: true,
  36. looping: true,
  37. // Try playing around with some of these other options:
  38. // progressColors: new VideoProgressColors(
  39. // playedColor: Colors.red,
  40. // handleColor: Colors.blue,
  41. // disabledColor: Colors.grey,
  42. // bufferedColor: Colors.lightGreen,
  43. // ),
  44. // placeholder: new Container(
  45. // color: Colors.grey,
  46. // ),
  47. // autoInitialize: true,
  48. ),
  49. ),
  50. ),
  51. new Row(
  52. children: <Widget>[
  53. new Expanded(
  54. child: new FlatButton(
  55. onPressed: () {
  56. setState(() {
  57. _platform = TargetPlatform.android;
  58. });
  59. },
  60. child: new Padding(
  61. child: new Text("Android controls"),
  62. padding: new EdgeInsets.symmetric(vertical: 16.0),
  63. ),
  64. )),
  65. new Expanded(
  66. child: new FlatButton(
  67. onPressed: () {
  68. setState(() {
  69. _platform = TargetPlatform.iOS;
  70. });
  71. },
  72. child: new Padding(
  73. padding: new EdgeInsets.symmetric(vertical: 16.0),
  74. child: new Text("iOS controls"),
  75. ),
  76. ),
  77. )
  78. ],
  79. )
  80. ],
  81. ),
  82. ),
  83. );
  84. }
  85. @override
  86. void initState() {
  87. controller = new VideoPlayerController(
  88. 'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
  89. );
  90. super.initState();
  91. }
  92. }