vid_player_test.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import 'package:fis_vid/data_host/data_host.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'index.dart';
  5. import 'view/main/desktop.dart';
  6. class VidPlayerPage extends StatefulWidget {
  7. const VidPlayerPage(this.url, {Key? key}) : super(key: key);
  8. final String url;
  9. @override
  10. State<StatefulWidget> createState() => _VidPlayerPageState();
  11. }
  12. class _VidPlayerPageState extends State<VidPlayerPage> {
  13. late final _dataHost = Get.put(VidDataHost(widget.url));
  14. late final _playerController =
  15. Get.put(VidPlayerController(dataHost: _dataHost));
  16. @override
  17. Widget build(BuildContext context) {
  18. // _playerController.load().then((value) {
  19. // _playerController.play();
  20. // });
  21. return FutureBuilder(
  22. future: _playerController.load(),
  23. builder: (_, snapshot) {
  24. if (snapshot.connectionState == ConnectionState.done) {
  25. if (_playerController.canPlay) {
  26. _playerController.play();
  27. return buildPage();
  28. } else {
  29. return const Material(child: Center(child: Text("Load fila")));
  30. }
  31. } else {
  32. return const Material(
  33. child: Center(child: CircularProgressIndicator()));
  34. }
  35. },
  36. );
  37. }
  38. Widget buildPage() {
  39. return Scaffold(
  40. // appBar: AppBar(),
  41. body: Row(
  42. children: [
  43. _LeftSider(),
  44. _Body(_playerController),
  45. _RightSider(),
  46. ],
  47. ),
  48. );
  49. }
  50. @override
  51. void dispose() {
  52. _playerController.dispose();
  53. super.dispose();
  54. }
  55. }
  56. class _Body extends StatelessWidget {
  57. const _Body(this.controller);
  58. final VidPlayerController controller;
  59. @override
  60. Widget build(BuildContext context) {
  61. const borderSide = BorderSide(color: Colors.grey);
  62. return Expanded(
  63. child: Container(
  64. decoration: const BoxDecoration(
  65. border: Border(left: borderSide, right: borderSide),
  66. ),
  67. child: Column(
  68. mainAxisSize: MainAxisSize.max,
  69. children: [
  70. const Expanded(
  71. // child: VidPlayer(controller),
  72. child: MeasureMainView(),
  73. ),
  74. SizedBox(
  75. height: 160,
  76. // color: Colors.black,
  77. child: controller.totalFramesCount > 1
  78. ? VidPlayerControlBoard(
  79. controller,
  80. )
  81. : Container(),
  82. ),
  83. ],
  84. ),
  85. ),
  86. );
  87. }
  88. }
  89. class _LeftSider extends StatelessWidget {
  90. @override
  91. Widget build(BuildContext context) {
  92. return Container(
  93. width: 180 + 12 * 2,
  94. alignment: Alignment.topCenter,
  95. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
  96. child: ListView.separated(
  97. itemCount: 20,
  98. itemBuilder: (_, index) {
  99. return Container(
  100. width: 180,
  101. height: 180,
  102. alignment: Alignment.center,
  103. decoration: BoxDecoration(
  104. border: Border.all(
  105. color: Colors.grey,
  106. ),
  107. ),
  108. child: const Text("Placeholder"),
  109. );
  110. },
  111. separatorBuilder: (_, index) {
  112. return const SizedBox(height: 8);
  113. },
  114. ),
  115. );
  116. }
  117. }
  118. class _RightSider extends StatelessWidget {
  119. @override
  120. Widget build(BuildContext context) {
  121. return Container(
  122. width: 320,
  123. // height: double.infinity,
  124. alignment: Alignment.topCenter,
  125. child: LayoutBuilder(
  126. builder: (context, constraints) {
  127. final height = constraints.biggest.height / 2;
  128. return Column(
  129. mainAxisSize: MainAxisSize.max,
  130. children: [
  131. Container(
  132. height: height,
  133. padding: const EdgeInsets.all(8),
  134. alignment: Alignment.topLeft,
  135. child: const Text('Measure Tools'),
  136. ),
  137. Container(
  138. height: height,
  139. padding: const EdgeInsets.all(8),
  140. decoration: const BoxDecoration(
  141. border: Border(
  142. top: BorderSide(color: Colors.grey),
  143. ),
  144. ),
  145. alignment: Alignment.topLeft,
  146. child: const Text('Comment'),
  147. ),
  148. ],
  149. );
  150. },
  151. ),
  152. );
  153. }
  154. }