Hibok
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

153 строки
3.6 KiB

  1. part of './controller_widget_builder.dart';
  2. enum FullScreenType {
  3. rotateScreen,
  4. rotateBox,
  5. }
  6. showFullScreenIJKPlayer(
  7. BuildContext context,
  8. IjkMediaController controller, {
  9. IJKControllerWidgetBuilder fullscreenControllerWidgetBuilder,
  10. FullScreenType fullScreenType = FullScreenType.rotateBox,
  11. }) async {
  12. if (fullScreenType == FullScreenType.rotateBox) {
  13. _showFullScreenWithRotateBox(
  14. context,
  15. controller,
  16. fullscreenControllerWidgetBuilder: fullscreenControllerWidgetBuilder,
  17. );
  18. return;
  19. }
  20. _showFullScreenWithRotateScreen(
  21. context,
  22. controller,
  23. fullscreenControllerWidgetBuilder,
  24. );
  25. }
  26. _showFullScreenWithRotateScreen(
  27. BuildContext context,
  28. IjkMediaController controller,
  29. IJKControllerWidgetBuilder fullscreenControllerWidgetBuilder) async {
  30. Navigator.push(
  31. context,
  32. FullScreenRoute(
  33. builder: (c) {
  34. return IjkPlayer(
  35. mediaController: controller,
  36. controllerWidgetBuilder: (ctl) =>
  37. fullscreenControllerWidgetBuilder(ctl),
  38. );
  39. },
  40. ),
  41. ).then((_) {
  42. IjkManager.unlockOrientation();
  43. IjkManager.setCurrentOrientation(DeviceOrientation.portraitUp);
  44. });
  45. var info = await controller.getVideoInfo();
  46. Axis axis;
  47. if (info.width == 0 || info.height == 0) {
  48. axis = Axis.horizontal;
  49. } else if (info.width > info.height) {
  50. if (info.degree == 90 || info.degree == 270) {
  51. axis = Axis.vertical;
  52. } else {
  53. axis = Axis.horizontal;
  54. }
  55. } else {
  56. if (info.degree == 90 || info.degree == 270) {
  57. axis = Axis.horizontal;
  58. } else {
  59. axis = Axis.vertical;
  60. }
  61. }
  62. if (axis == Axis.horizontal) {
  63. IjkManager.setLandScape();
  64. } else {
  65. IjkManager.setPortrait();
  66. }
  67. }
  68. _showFullScreenWithRotateBox(
  69. BuildContext context,
  70. IjkMediaController controller, {
  71. IJKControllerWidgetBuilder fullscreenControllerWidgetBuilder,
  72. }) async {
  73. var info = await controller.getVideoInfo();
  74. Axis axis;
  75. if (info.width == 0 || info.height == 0) {
  76. axis = Axis.horizontal;
  77. } else if (info.width > info.height) {
  78. if (info.degree == 90 || info.degree == 270) {
  79. axis = Axis.vertical;
  80. } else {
  81. axis = Axis.horizontal;
  82. }
  83. } else {
  84. if (info.degree == 90 || info.degree == 270) {
  85. axis = Axis.horizontal;
  86. } else {
  87. axis = Axis.vertical;
  88. }
  89. }
  90. Navigator.push(
  91. context,
  92. FullScreenRoute(
  93. builder: (ctx) {
  94. var mediaQueryData = MediaQuery.of(ctx);
  95. int quarterTurns;
  96. if (axis == Axis.horizontal) {
  97. if (mediaQueryData.orientation == Orientation.landscape) {
  98. quarterTurns = 0;
  99. } else {
  100. quarterTurns = 1;
  101. }
  102. } else {
  103. quarterTurns = 0;
  104. }
  105. /*else {
  106. if (mediaQueryData.orientation == Orientation.portrait) {
  107. quarterTurns = 0;
  108. } else {
  109. quarterTurns = -1;
  110. }
  111. }*/
  112. return SafeArea(
  113. child: RotatedBox(
  114. quarterTurns: quarterTurns,
  115. child: IjkPlayer(
  116. mediaController: controller,
  117. controllerWidgetBuilder: (ctl) =>
  118. fullscreenControllerWidgetBuilder(ctl),
  119. ),
  120. ),
  121. );
  122. },
  123. ),
  124. );
  125. }
  126. Widget _buildFullScreenMediaController(
  127. IjkMediaController controller, bool fullScreen) {
  128. return MyDefaultIJKControllerWidget(
  129. controller: controller,
  130. currentFullScreenState: true,
  131. );
  132. }
  133. Widget buildFullscreenMediaController(IjkMediaController controller) {
  134. return _buildFullScreenMediaController(controller, true);
  135. }