main.dart 3.0 KB

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