vid_player_test.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. 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(controller)
  79. : Container(),
  80. ),
  81. ],
  82. ),
  83. ),
  84. );
  85. }
  86. }
  87. class _LeftSider extends StatelessWidget {
  88. @override
  89. Widget build(BuildContext context) {
  90. return Container(
  91. width: 180 + 12 * 2,
  92. alignment: Alignment.topCenter,
  93. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
  94. child: ListView.separated(
  95. itemCount: 20,
  96. itemBuilder: (_, index) {
  97. return Container(
  98. width: 180,
  99. height: 180,
  100. alignment: Alignment.center,
  101. decoration: BoxDecoration(
  102. border: Border.all(
  103. color: Colors.grey,
  104. ),
  105. ),
  106. child: const Text("Placeholder"),
  107. );
  108. },
  109. separatorBuilder: (_, index) {
  110. return const SizedBox(height: 8);
  111. },
  112. ),
  113. );
  114. }
  115. }
  116. class _RightSider extends StatelessWidget {
  117. @override
  118. Widget build(BuildContext context) {
  119. return Container(
  120. width: 320,
  121. // height: double.infinity,
  122. alignment: Alignment.topCenter,
  123. child: LayoutBuilder(
  124. builder: (context, constraints) {
  125. final height = constraints.biggest.height / 2;
  126. return Column(
  127. mainAxisSize: MainAxisSize.max,
  128. children: [
  129. Container(
  130. height: height,
  131. padding: const EdgeInsets.all(8),
  132. alignment: Alignment.topLeft,
  133. child: const Text('Measure Tools'),
  134. ),
  135. Container(
  136. height: height,
  137. padding: const EdgeInsets.all(8),
  138. decoration: const BoxDecoration(
  139. border: Border(
  140. top: BorderSide(color: Colors.grey),
  141. ),
  142. ),
  143. alignment: Alignment.topLeft,
  144. child: const Text('Comment'),
  145. ),
  146. ],
  147. );
  148. },
  149. ),
  150. );
  151. }
  152. }