video_page.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'dart:io';
  2. import 'dart:math';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/services.dart';
  6. import 'package:get_it/get_it.dart';
  7. import 'package:provider/provider.dart';
  8. import 'package:sport/application.dart';
  9. import 'package:sport/bean/carousel.dart';
  10. import 'package:sport/bean/game.dart';
  11. import 'package:sport/pages/game/game_detail.dart';
  12. import 'package:sport/provider/game_model.dart';
  13. import 'package:sport/router/navigator_util.dart';
  14. import 'package:sport/widgets/image.dart';
  15. import 'package:sport/widgets/video.dart';
  16. import 'package:umeng_common_sdk/umeng_common_sdk.dart';
  17. import 'package:url_launcher/url_launcher.dart';
  18. import 'package:video_player/video_player.dart';
  19. import 'package:visibility_detector/visibility_detector.dart';
  20. class VideoPage extends StatefulWidget {
  21. final String url;
  22. final bool autoPlay;
  23. final bool loop;
  24. const VideoPage({Key? key, required this.url, this.autoPlay = false, this.loop = true}) : super(key: key);
  25. @override
  26. State<StatefulWidget> createState() => _VideoState();
  27. }
  28. class _VideoState extends State<VideoPage> {
  29. @override
  30. void initState() {
  31. super.initState();
  32. SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeRight] : [DeviceOrientation.landscapeLeft]);
  33. SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
  34. }
  35. @override
  36. void dispose() {
  37. SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
  38. SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top]);
  39. super.dispose();
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. return Scaffold(
  44. backgroundColor: Colors.white,
  45. body: Stack(
  46. fit: StackFit.expand,
  47. children: [
  48. VideoWidget(
  49. carousel: Carousel(
  50. url: widget.url,
  51. id: 0,
  52. type: "",
  53. gameId: 0,
  54. outerUrl: '',
  55. outerDesc: '',
  56. cover: null,
  57. position: 0,
  58. ),
  59. autoPlay: widget.autoPlay,
  60. loop: widget.loop,
  61. ),
  62. Positioned(
  63. left: 8,top: 12,
  64. child:
  65. IconButton(
  66. icon: arrowBack(),
  67. onPressed: () {
  68. Navigator.pop(context);
  69. },
  70. ),)
  71. ],
  72. ),
  73. );
  74. }
  75. }