@cloud-app-dev/vidc 2.3.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/.umirc.ts +2 -2
  2. package/es/Config/interface.d.ts +2 -1
  3. package/es/DomMove/demo.d.ts +2 -0
  4. package/es/DomMove/demo.js +16 -0
  5. package/es/DomMove/index.d.ts +16 -0
  6. package/es/DomMove/index.js +145 -0
  7. package/es/DomMove/utils.d.ts +8 -0
  8. package/es/{Picture/component/MoveContent → DomMove}/utils.js +19 -0
  9. package/es/Drawer/index.d.ts +2 -2
  10. package/es/Drawer/interface.d.ts +4 -174
  11. package/es/ErrorBoundary/index.d.ts +18 -0
  12. package/es/ErrorBoundary/index.js +79 -0
  13. package/es/List/DynamicGridList/Demo.js +40 -27
  14. package/es/List/DynamicGridList/index.d.ts +20 -29
  15. package/es/List/DynamicGridList/index.js +40 -63
  16. package/es/List/DynamicList/index.css +15 -0
  17. package/es/List/DynamicList/index.d.ts +14 -0
  18. package/es/List/DynamicList/index.js +105 -0
  19. package/es/List/DynamicList/interface.d.ts +19 -0
  20. package/es/List/DynamicList/utils.d.ts +4 -0
  21. package/es/List/DynamicList/utils.js +6 -0
  22. package/es/List/GridList/Demo.js +27 -4
  23. package/es/List/GridList/index.css +1 -0
  24. package/es/List/GridList/index.d.ts +2 -2
  25. package/es/List/GridList/index.js +8 -12
  26. package/es/List/GridList/interface.d.ts +1 -1
  27. package/es/List/VList/index.js +2 -3
  28. package/es/List/index.css +2 -54
  29. package/es/List/index.d.ts +6 -7
  30. package/es/List/index.js +14 -153
  31. package/es/List/interface.d.ts +3 -61
  32. package/es/LoaderApp/index.d.ts +1 -1
  33. package/es/LoaderApp/index.js +27 -46
  34. package/es/LoaderApp/interface.d.ts +3 -0
  35. package/es/LoaderApp/loader.d.ts +6 -7
  36. package/es/LoaderApp/loader.js +20 -30
  37. package/es/LoaderApp/sandbox.back.d.ts +18 -0
  38. package/es/LoaderApp/sandbox.back.js +356 -0
  39. package/es/LoaderApp/sandbox.d.ts +12 -0
  40. package/es/LoaderApp/sandbox.js +110 -0
  41. package/es/LoaderApp/utils.d.ts +5 -1
  42. package/es/LoaderApp/utils.js +98 -2
  43. package/es/Map/AMap.d.ts +1572 -0
  44. package/es/Map/BasicMap/AMapInstance.d.ts +15 -0
  45. package/es/Map/BasicMap/AMapInstance.js +66 -0
  46. package/es/Map/BasicMap/LeafletInstance.d.ts +15 -0
  47. package/es/Map/BasicMap/LeafletInstance.js +98 -0
  48. package/es/Map/BasicMap/index.css +24 -0
  49. package/es/Map/BasicMap/index.d.ts +9 -0
  50. package/es/Map/BasicMap/index.js +103 -0
  51. package/es/Map/ClusterLayer/hook.d.ts +5 -0
  52. package/es/Map/ClusterLayer/hook.js +144 -0
  53. package/es/Map/ClusterLayer/index.css +26 -0
  54. package/es/Map/ClusterLayer/index.d.ts +5 -0
  55. package/es/Map/ClusterLayer/index.js +31 -0
  56. package/es/Map/ClusterLayer/props.d.ts +8 -0
  57. package/es/Map/Config/index.d.ts +7 -0
  58. package/es/{InitialConfig → Map/Config}/index.js +35 -36
  59. package/es/Map/Config/utils.d.ts +2 -0
  60. package/es/{List/DynamicDeviceList → Map/Config}/utils.js +48 -45
  61. package/es/Map/Context/index.d.ts +11 -0
  62. package/es/Map/Context/index.js +66 -0
  63. package/es/Map/FindPio/index.css +7 -0
  64. package/es/Map/FindPio/index.d.ts +4 -0
  65. package/es/Map/FindPio/index.js +16 -0
  66. package/es/{WorkerFlow/Demo.d.ts → Map/InfoWindow/demo.d.ts} +0 -0
  67. package/es/{List/DynamicDeviceList/Demo.js → Map/InfoWindow/demo.js} +27 -25
  68. package/es/Map/InfoWindow/index.d.ts +8 -0
  69. package/es/Map/InfoWindow/index.js +74 -0
  70. package/es/Map/LevelCenter/DragMarker/index.d.ts +12 -0
  71. package/es/Map/LevelCenter/DragMarker/index.js +48 -0
  72. package/es/{List/DeviceList → Map/LevelCenter}/index.css +0 -0
  73. package/es/Map/LevelCenter/index.d.ts +13 -0
  74. package/es/Map/LevelCenter/index.js +42 -0
  75. package/es/Map/LoaderMap/index.d.ts +12 -0
  76. package/es/Map/LoaderMap/index.js +58 -0
  77. package/es/Map/ResetTools/index.css +32 -0
  78. package/es/Map/ResetTools/index.d.ts +9 -0
  79. package/es/Map/ResetTools/index.js +61 -0
  80. package/es/Map/SinglePoint/Marker/index.d.ts +7 -0
  81. package/es/Map/SinglePoint/Marker/index.js +29 -0
  82. package/es/Map/SinglePoint/icon/Place_icon_OnLine_Hover.svg +15 -0
  83. package/es/Map/SinglePoint/icon/Place_icon_OnLine_Normal.svg +15 -0
  84. package/es/Map/SinglePoint/icon/Place_icon_OutLine_Hover.svg +15 -0
  85. package/es/Map/SinglePoint/icon/Place_icon_OutLine_Normal.svg +15 -0
  86. package/es/Map/SinglePoint/index.css +29 -0
  87. package/es/Map/SinglePoint/index.d.ts +7 -0
  88. package/es/Map/SinglePoint/index.js +32 -0
  89. package/es/Map/hook/useMapType.d.ts +4 -0
  90. package/es/Map/hook/useMapType.js +13 -0
  91. package/es/Map/icon.d.ts +2 -0
  92. package/es/Map/icon.js +10 -0
  93. package/es/Map/index.d.ts +23 -0
  94. package/es/Map/index.js +25 -0
  95. package/es/Map/interface.d.ts +55 -0
  96. package/es/Map/points.json +61247 -0
  97. package/es/{Picture/component/MoveContent → Map/useMarker}/index.css +0 -0
  98. package/es/Map/useMarker/index.d.ts +11 -0
  99. package/es/{WorkerFlow/Form/FormAuth.js → Map/useMarker/index.js} +57 -80
  100. package/es/Map/withMap/index.d.ts +2 -0
  101. package/es/Map/withMap/index.js +12 -0
  102. package/es/Modal/index.js +7 -5
  103. package/es/Picture/component/RectMenu/index.d.ts +1 -1
  104. package/es/Picture/index.d.ts +1 -1
  105. package/es/Picture/index.js +2 -2
  106. package/es/Player/api/index.d.ts +2 -8
  107. package/es/Player/api/index.js +29 -35
  108. package/es/Player/contraller_bar/left_bar.js +2 -2
  109. package/es/Player/contraller_bar/right_bar.d.ts +1 -1
  110. package/es/Player/contraller_bar/right_bar.js +13 -27
  111. package/es/Player/demo.js +21 -24
  112. package/es/Player/event/index.js +5 -1
  113. package/es/Player/frontend_player.d.ts +2 -3
  114. package/es/Player/frontend_player.js +35 -52
  115. package/es/Player/frontend_timeline.d.ts +3 -2
  116. package/es/Player/frontend_timeline.js +20 -9
  117. package/es/Player/live_heart.js +45 -12
  118. package/es/Player/message.js +23 -12
  119. package/es/Player/player.d.ts +29 -7
  120. package/es/Player/segment_player.d.ts +1 -1
  121. package/es/Player/segment_player.js +50 -39
  122. package/es/Player/segment_timeline.js +14 -13
  123. package/es/Player/single_player.js +59 -14
  124. package/es/Player/timeline.js +8 -6
  125. package/es/Player/util.d.ts +4 -25
  126. package/es/Player/util.js +47 -55
  127. package/es/PlayerExt/index.css +2 -2
  128. package/es/PlayerExt/index.d.ts +3 -1
  129. package/es/PlayerExt/index.js +19 -5
  130. package/es/ScreenPlayer/Live.d.ts +5 -0
  131. package/es/ScreenPlayer/Live.js +109 -0
  132. package/es/ScreenPlayer/LiveTools.d.ts +15 -0
  133. package/es/ScreenPlayer/LiveTools.js +95 -0
  134. package/es/ScreenPlayer/PlayerWithExt.d.ts +22 -0
  135. package/es/ScreenPlayer/PlayerWithExt.js +156 -0
  136. package/es/ScreenPlayer/Record.d.ts +5 -0
  137. package/es/{WorkerFlow/index.js → ScreenPlayer/Record.js} +286 -273
  138. package/es/ScreenPlayer/RecordTools.d.ts +17 -0
  139. package/es/ScreenPlayer/RecordTools.js +102 -0
  140. package/es/ScreenPlayer/SegmentTimeLine.d.ts +10 -0
  141. package/es/ScreenPlayer/SegmentTimeLine.js +40 -0
  142. package/es/ScreenPlayer/TimeSlider.d.ts +127 -0
  143. package/es/ScreenPlayer/TimeSlider.js +530 -0
  144. package/es/ScreenPlayer/demo.d.ts +2 -0
  145. package/es/ScreenPlayer/demo.js +25 -0
  146. package/es/ScreenPlayer/demo2.d.ts +2 -0
  147. package/es/ScreenPlayer/demo2.js +153 -0
  148. package/es/ScreenPlayer/index.css +49 -0
  149. package/es/ScreenPlayer/index.d.ts +5 -0
  150. package/es/ScreenPlayer/index.js +8 -0
  151. package/es/ScreenPlayer/interface.d.ts +81 -0
  152. package/es/ScreenPlayer/useRecordList.d.ts +3 -0
  153. package/es/{WorkerFlow/Form/UserAndGroupSelect.js → ScreenPlayer/useRecordList.js} +173 -176
  154. package/es/ScreenPlayer/useVideoFit.d.ts +5 -0
  155. package/es/ScreenPlayer/useVideoFit.js +46 -0
  156. package/es/ScreenPlayer/utils.d.ts +25 -0
  157. package/es/ScreenPlayer/utils.js +84 -0
  158. package/es/Timeout/index.d.ts +33 -0
  159. package/es/Timeout/index.js +83 -0
  160. package/es/Tree/demo.js +9 -12
  161. package/es/Tree/index.css +55 -29
  162. package/es/Tree/index.d.ts +20 -19
  163. package/es/Tree/index.js +70 -185
  164. package/es/index.d.ts +8 -9
  165. package/es/index.js +8 -9
  166. package/es/useInfiniteScroll/index.d.ts +16 -0
  167. package/es/{useHttp → useInfiniteScroll}/index.js +79 -43
  168. package/es/useVirtualList/index.d.ts +13 -0
  169. package/es/useVirtualList/index.js +175 -0
  170. package/es/withErrorBoundary/index.d.ts +9 -0
  171. package/es/withErrorBoundary/index.js +45 -0
  172. package/package.json +18 -21
  173. package/release-build.sh +44 -0
  174. package/test.js +48 -0
  175. package/es/DeviceIcon/icon.d.ts +0 -9
  176. package/es/DeviceIcon/icon.js +0 -138
  177. package/es/DeviceIcon/index.css +0 -8
  178. package/es/DeviceIcon/index.d.ts +0 -14
  179. package/es/DeviceIcon/index.js +0 -37
  180. package/es/DeviceSelect/TreeType.d.ts +0 -7
  181. package/es/DeviceSelect/TreeType.js +0 -36
  182. package/es/DeviceSelect/demo.d.ts +0 -3
  183. package/es/DeviceSelect/demo.js +0 -22
  184. package/es/DeviceSelect/index.css +0 -11
  185. package/es/DeviceSelect/index.d.ts +0 -13
  186. package/es/DeviceSelect/index.js +0 -191
  187. package/es/Dict/cache.d.ts +0 -3
  188. package/es/Dict/cache.js +0 -21
  189. package/es/Dict/device.d.ts +0 -28
  190. package/es/Dict/device.js +0 -117
  191. package/es/Dict/hook.d.ts +0 -3
  192. package/es/Dict/hook.js +0 -98
  193. package/es/Dict/index.d.ts +0 -9
  194. package/es/Dict/index.js +0 -10
  195. package/es/Dict/interface.d.ts +0 -16
  196. package/es/Dict/utils.d.ts +0 -10
  197. package/es/Dict/utils.js +0 -44
  198. package/es/InitialConfig/index.d.ts +0 -8
  199. package/es/InitialConfig/utils.d.ts +0 -20
  200. package/es/InitialConfig/utils.js +0 -110
  201. package/es/InitialRequest/index.d.ts +0 -9
  202. package/es/InitialRequest/index.js +0 -97
  203. package/es/InitialRequest/utils.d.ts +0 -10
  204. package/es/InitialRequest/utils.js +0 -116
  205. package/es/List/CheckExt.d.ts +0 -9
  206. package/es/List/CheckExt.js +0 -36
  207. package/es/List/DeviceList/index.d.ts +0 -11
  208. package/es/List/DeviceList/index.js +0 -50
  209. package/es/List/DynamicDeviceList/Demo.d.ts +0 -3
  210. package/es/List/DynamicDeviceList/index.css +0 -39
  211. package/es/List/DynamicDeviceList/index.d.ts +0 -12
  212. package/es/List/DynamicDeviceList/index.js +0 -205
  213. package/es/List/DynamicDeviceList/interface.d.ts +0 -37
  214. package/es/List/DynamicDeviceList/utils.d.ts +0 -16
  215. package/es/List/ListExt/index.css +0 -3
  216. package/es/List/ListExt/index.d.ts +0 -19
  217. package/es/List/ListExt/index.js +0 -44
  218. package/es/Picture/component/MoveContent/index.d.ts +0 -39
  219. package/es/Picture/component/MoveContent/index.js +0 -244
  220. package/es/Picture/component/MoveContent/utils.d.ts +0 -4
  221. package/es/Title/index.css +0 -25
  222. package/es/Title/index.d.ts +0 -12
  223. package/es/Title/index.js +0 -30
  224. package/es/Tree/BaseTree/index.css +0 -64
  225. package/es/Tree/BaseTree/index.d.ts +0 -24
  226. package/es/Tree/BaseTree/index.js +0 -83
  227. package/es/UserSelect/demo.d.ts +0 -3
  228. package/es/UserSelect/demo.js +0 -21
  229. package/es/UserSelect/index.css +0 -16
  230. package/es/UserSelect/index.d.ts +0 -18
  231. package/es/UserSelect/index.js +0 -194
  232. package/es/WorkerFlow/Demo.js +0 -57
  233. package/es/WorkerFlow/Form/Approver.d.ts +0 -10
  234. package/es/WorkerFlow/Form/Approver.js +0 -33
  235. package/es/WorkerFlow/Form/Condition.d.ts +0 -11
  236. package/es/WorkerFlow/Form/Condition.js +0 -235
  237. package/es/WorkerFlow/Form/EmptyUserSet.d.ts +0 -8
  238. package/es/WorkerFlow/Form/EmptyUserSet.js +0 -137
  239. package/es/WorkerFlow/Form/FormAuth.d.ts +0 -8
  240. package/es/WorkerFlow/Form/GroupList.d.ts +0 -12
  241. package/es/WorkerFlow/Form/GroupList.js +0 -44
  242. package/es/WorkerFlow/Form/GroupSelect.d.ts +0 -8
  243. package/es/WorkerFlow/Form/GroupSelect.js +0 -167
  244. package/es/WorkerFlow/Form/GroupSelectModalContent.d.ts +0 -6
  245. package/es/WorkerFlow/Form/GroupSelectModalContent.js +0 -177
  246. package/es/WorkerFlow/Form/Handle.d.ts +0 -10
  247. package/es/WorkerFlow/Form/Handle.js +0 -33
  248. package/es/WorkerFlow/Form/LevelGroupSelect.d.ts +0 -12
  249. package/es/WorkerFlow/Form/LevelGroupSelect.js +0 -208
  250. package/es/WorkerFlow/Form/Notifier.d.ts +0 -8
  251. package/es/WorkerFlow/Form/Notifier.js +0 -16
  252. package/es/WorkerFlow/Form/UserAndGroupSelect.d.ts +0 -8
  253. package/es/WorkerFlow/Form/UserSelect.d.ts +0 -8
  254. package/es/WorkerFlow/Form/UserSelect.js +0 -150
  255. package/es/WorkerFlow/Form/UserSelectModalContent.d.ts +0 -6
  256. package/es/WorkerFlow/Form/UserSelectModalContent.js +0 -166
  257. package/es/WorkerFlow/Form/UserSet.d.ts +0 -14
  258. package/es/WorkerFlow/Form/UserSet.js +0 -308
  259. package/es/WorkerFlow/Form/UsersHandleType.d.ts +0 -7
  260. package/es/WorkerFlow/Form/UsersHandleType.js +0 -32
  261. package/es/WorkerFlow/Form/utils.d.ts +0 -3
  262. package/es/WorkerFlow/Form/utils.js +0 -47
  263. package/es/WorkerFlow/Nodes/Add.d.ts +0 -7
  264. package/es/WorkerFlow/Nodes/Add.js +0 -98
  265. package/es/WorkerFlow/Nodes/AddOption.d.ts +0 -10
  266. package/es/WorkerFlow/Nodes/AddOption.js +0 -23
  267. package/es/WorkerFlow/Nodes/AddOptionList.d.ts +0 -8
  268. package/es/WorkerFlow/Nodes/AddOptionList.js +0 -46
  269. package/es/WorkerFlow/Nodes/Approver.d.ts +0 -11
  270. package/es/WorkerFlow/Nodes/Approver.js +0 -53
  271. package/es/WorkerFlow/Nodes/Condition.d.ts +0 -10
  272. package/es/WorkerFlow/Nodes/Condition.js +0 -140
  273. package/es/WorkerFlow/Nodes/Constants.d.ts +0 -35
  274. package/es/WorkerFlow/Nodes/Constants.js +0 -150
  275. package/es/WorkerFlow/Nodes/End.d.ts +0 -7
  276. package/es/WorkerFlow/Nodes/End.js +0 -16
  277. package/es/WorkerFlow/Nodes/Handle.d.ts +0 -11
  278. package/es/WorkerFlow/Nodes/Handle.js +0 -52
  279. package/es/WorkerFlow/Nodes/Node.d.ts +0 -8
  280. package/es/WorkerFlow/Nodes/Node.js +0 -26
  281. package/es/WorkerFlow/Nodes/Notifier.d.ts +0 -11
  282. package/es/WorkerFlow/Nodes/Notifier.js +0 -52
  283. package/es/WorkerFlow/Nodes/Render.d.ts +0 -8
  284. package/es/WorkerFlow/Nodes/Render.js +0 -16
  285. package/es/WorkerFlow/Nodes/Start.d.ts +0 -12
  286. package/es/WorkerFlow/Nodes/Start.js +0 -26
  287. package/es/WorkerFlow/Nodes/TitleElement.d.ts +0 -10
  288. package/es/WorkerFlow/Nodes/TitleElement.js +0 -127
  289. package/es/WorkerFlow/Nodes/Wrap.d.ts +0 -13
  290. package/es/WorkerFlow/Nodes/Wrap.js +0 -35
  291. package/es/WorkerFlow/OperatorContext.d.ts +0 -4
  292. package/es/WorkerFlow/OperatorContext.js +0 -3
  293. package/es/WorkerFlow/Tools.d.ts +0 -8
  294. package/es/WorkerFlow/Tools.js +0 -78
  295. package/es/WorkerFlow/XML/CanvasTag.d.ts +0 -3
  296. package/es/WorkerFlow/XML/CanvasTag.js +0 -142
  297. package/es/WorkerFlow/XML/EndEvent.d.ts +0 -1
  298. package/es/WorkerFlow/XML/EndEvent.js +0 -14
  299. package/es/WorkerFlow/XML/ExclusiveGateway.d.ts +0 -9
  300. package/es/WorkerFlow/XML/ExclusiveGateway.js +0 -101
  301. package/es/WorkerFlow/XML/Root.d.ts +0 -1
  302. package/es/WorkerFlow/XML/Root.js +0 -5
  303. package/es/WorkerFlow/XML/StartEvent.d.ts +0 -5
  304. package/es/WorkerFlow/XML/StartEvent.js +0 -28
  305. package/es/WorkerFlow/XML/UserTask.d.ts +0 -5
  306. package/es/WorkerFlow/XML/UserTask.js +0 -93
  307. package/es/WorkerFlow/XML/index.d.ts +0 -4
  308. package/es/WorkerFlow/XML/index.js +0 -100
  309. package/es/WorkerFlow/XML/utils.d.ts +0 -6
  310. package/es/WorkerFlow/XML/utils.js +0 -97
  311. package/es/WorkerFlow/data.json +0 -83
  312. package/es/WorkerFlow/index.css +0 -779
  313. package/es/WorkerFlow/index.d.ts +0 -13
  314. package/es/WorkerFlow/interface.d.ts +0 -93
  315. package/es/WorkerFlow/template.d.ts +0 -2
  316. package/es/WorkerFlow/template.js +0 -17
  317. package/es/WorkerFlow/utils.d.ts +0 -14
  318. package/es/WorkerFlow/utils.js +0 -212
  319. package/es/useHttp/index.d.ts +0 -8
@@ -16,7 +16,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  import React, { useCallback, useMemo } from 'react';
17
17
  import { useTimes } from './timeline';
18
18
  import useBarStatus from './contraller_bar/useBarStatus';
19
- import { dateFormat } from './util';
19
+ import moment from 'moment';
20
+ import { FMT } from './util';
20
21
  import "./style/timeline.css";
21
22
 
22
23
  function SegmentTimeLine(_ref) {
@@ -36,11 +37,11 @@ function SegmentTimeLine(_ref) {
36
37
 
37
38
  var indexDuration = useMemo(function () {
38
39
  return segments.map(function (v) {
39
- return v.duration;
40
+ return (v.endTime - v.beginTime) / 1000;
40
41
  }).reduce(function (a, b, i) {
41
42
  return i >= index ? a : a + b;
42
43
  }, 0);
43
- }, [index]);
44
+ }, [index, segments]);
44
45
  var playPercent = useMemo(function () {
45
46
  return (currentTime + indexDuration) / duration * 100;
46
47
  }, [currentTime, duration, indexDuration]);
@@ -66,7 +67,7 @@ function SegmentTimeLine(_ref) {
66
67
  } else {
67
68
  api.seekTo(currentTime);
68
69
  }
69
- }, [api, segments, index]);
70
+ }, [segments, api, index, setIndex]);
70
71
  return /*#__PURE__*/React.createElement("div", {
71
72
  className: "player-timeline-layout player-segment-timeline-layout ".concat(status === 0 ? 'hide-time-line' : '')
72
73
  }, /*#__PURE__*/React.createElement("div", {
@@ -85,7 +86,7 @@ function SegmentTimeLine(_ref) {
85
86
  return seekWithLine(e, i);
86
87
  },
87
88
  style: {
88
- width: "".concat(v.duration / duration * 100, "%")
89
+ width: "".concat((v.endTime / 1000 - v.beginTime / 1000) / duration * 100, "%")
89
90
  }
90
91
  }));
91
92
  }), /*#__PURE__*/React.createElement("div", {
@@ -110,24 +111,24 @@ function TipTitle(_ref2) {
110
111
  if (index === 0) {
111
112
  var _start = begin;
112
113
 
113
- var _end = begin + segments[0].duration * 1000;
114
+ var _end = begin + (segments[0].endTime - segments[0].beginTime);
114
115
 
115
116
  return {
116
- start: dateFormat(_start),
117
- end: dateFormat(_end)
117
+ start: moment(_start).format(FMT),
118
+ end: moment(_end).format(FMT)
118
119
  };
119
120
  }
120
121
 
121
122
  var indexDuration = segments.map(function (v) {
122
- return v.duration;
123
+ return v.endTime - v.beginTime;
123
124
  }).reduce(function (a, b, i) {
124
125
  return i >= index ? a : a + b;
125
126
  }, 0);
126
- var start = begin + indexDuration * 1000;
127
- var end = start + segments[index].duration * 1000;
127
+ var start = begin + indexDuration;
128
+ var end = start + (segments[index].endTime - segments[index].beginTime);
128
129
  return {
129
- start: dateFormat(start),
130
- end: dateFormat(end)
130
+ start: moment(start).format(FMT),
131
+ end: moment(end).format(FMT)
131
132
  };
132
133
  }, [index, segments, begin]),
133
134
  start = _useMemo.start,
@@ -1,3 +1,5 @@
1
+ import _useToggle3 from "ahooks/es/useToggle";
2
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -32,7 +34,9 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
32
34
  isLive = _a.isLive,
33
35
  errorReloadTimer = _a.errorReloadTimer,
34
36
  children = _a.children,
35
- props = __rest(_a, ["className", "url", "type", "hideContrallerBar", "isLive", "errorReloadTimer", "children"]);
37
+ onCanPlayerInit = _a.onCanPlayerInit,
38
+ extActions = _a.extActions,
39
+ props = __rest(_a, ["className", "url", "type", "hideContrallerBar", "isLive", "errorReloadTimer", "children", "onCanPlayerInit", "extActions"]);
36
40
 
37
41
  var autoPlay = props.autoPlay,
38
42
  preload = props.preload,
@@ -55,7 +59,12 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
55
59
  }),
56
60
  _useState2 = _slicedToArray(_useState, 2),
57
61
  state = _useState2[0],
58
- setState = _useState2[1]; // 视频格式判断,外部可以强制指定,也可以通过url自动判断
62
+ setState = _useState2[1];
63
+
64
+ var _useToggle = _useToggle3('contain', 'fill'),
65
+ _useToggle2 = _slicedToArray(_useToggle, 2),
66
+ fit = _useToggle2[0],
67
+ toggle = _useToggle2[1].toggle; // 视频格式判断,外部可以强制指定,也可以通过url自动判断
59
68
 
60
69
 
61
70
  var vType = useMemo(function () {
@@ -93,34 +102,66 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
93
102
  }, []); // 特殊接口实现 reload是可能被重写的,但是API只暴露原生的方法
94
103
 
95
104
  var reload = function reload() {
96
- return playReload(video, flv, hls, url);
105
+ return playReload(video, event, flv, hls, url);
97
106
  };
98
107
 
99
108
  var unload = function unload() {
100
109
  return playUnload(video, flv, hls);
101
- }; // 合并api
110
+ }; // 合并api,加上代理
102
111
 
103
112
 
104
113
  var playApi = useMemo(function () {
105
- return Object.assign(Object.assign({}, api), {
114
+ if (!api) {
115
+ return undefined;
116
+ }
117
+
118
+ var map = Object.assign({
106
119
  reload: reload,
107
- unload: unload
120
+ unload: unload,
121
+ toggleFit: toggle
122
+ }, extActions);
123
+ return new Proxy(api, {
124
+ get: function get(target, key) {
125
+ var _a;
126
+
127
+ return (_a = map[key]) !== null && _a !== void 0 ? _a : target[key];
128
+ },
129
+ set: function set() {
130
+ return true;
131
+ }
132
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps
133
+ }, [api]); // 代理Event
134
+
135
+ var playEvent = useMemo(function () {
136
+ if (!event) {
137
+ return undefined;
138
+ }
139
+
140
+ return new Proxy(event, {
141
+ get: function get(target, key) {
142
+ return target[key];
143
+ },
144
+ set: function set() {
145
+ return true;
146
+ }
108
147
  });
109
- }, [api]); // ref暴露接口
148
+ }, [event]); // ref暴露接口
110
149
 
111
150
  useImperativeHandle(ref, function () {
112
151
  return {
113
152
  video: video,
114
153
  container: state.container,
115
154
  api: playApi,
116
- event: event,
117
- plugins: [flv, hls]
155
+ event: playEvent,
156
+ plugins: [flv, hls],
157
+ fit: fit
118
158
  };
119
- }, [api, event, video]);
159
+ }, [video, state.container, playApi, playEvent, flv, hls, fit]);
120
160
  useEffect(function () {
121
161
  if (api && event && video) {
122
- props.onCanPlayerInit && props.onCanPlayerInit();
123
- }
162
+ onCanPlayerInit && onCanPlayerInit();
163
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
164
+
124
165
  }, [api, event, video]);
125
166
  return /*#__PURE__*/React.createElement("div", {
126
167
  className: "lm-player-container ".concat(className),
@@ -128,6 +169,9 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
128
169
  }, /*#__PURE__*/React.createElement("div", {
129
170
  className: "player-mask-layout"
130
171
  }, /*#__PURE__*/React.createElement("video", {
172
+ style: {
173
+ objectFit: fit
174
+ },
131
175
  autoPlay: autoPlay,
132
176
  preload: preload,
133
177
  muted: muted,
@@ -152,7 +196,7 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
152
196
  leftMidExtContents: leftMidExtContents,
153
197
  reload: (_b = props.reload) !== null && _b !== void 0 ? _b : reload,
154
198
  hideTimeProgress: !!customTimeLine
155
- })), !isLive ? customTimeLine ? customTimeLine : /*#__PURE__*/React.createElement(Timeline, {
199
+ })), customTimeLine ? customTimeLine : !hideContrallerBar ? /*#__PURE__*/React.createElement(Timeline, {
156
200
  api: playApi,
157
201
  event: event
158
202
  }) : null, /*#__PURE__*/React.createElement(ErrorEvent, {
@@ -181,6 +225,7 @@ SinglePlayer.defaultProps = {
181
225
  mediaDataSource: {},
182
226
  config: {}
183
227
  },
184
- hlsConfig: {}
228
+ hlsConfig: {},
229
+ extActions: {}
185
230
  };
186
231
  export default /*#__PURE__*/React.memo(SinglePlayer);
@@ -22,11 +22,11 @@ export function useTimes(api, event, isHide) {
22
22
  state = _useState2[0],
23
23
  setState = _useState2[1];
24
24
 
25
- if (isHide) {
26
- return [0, 0, 0];
27
- }
28
-
29
25
  useEffect(function () {
26
+ if (isHide) {
27
+ return undefined;
28
+ }
29
+
30
30
  var getCurrentTime = function getCurrentTime() {
31
31
  return setState(function (old) {
32
32
  return Object.assign(Object.assign({}, old), {
@@ -58,8 +58,10 @@ export function useTimes(api, event, isHide) {
58
58
  event.removeEventListener('suspend', getBuffered);
59
59
  event.removeEventListener('seeked', seekendPlay);
60
60
  };
61
- }, [event, api]);
62
- return [state.currentTime, state.buffered, api.getDuration()];
61
+ }, [event, api, isHide]);
62
+ return useMemo(function () {
63
+ return [state.currentTime, state.buffered, api.getDuration()];
64
+ }, [state.currentTime, state.buffered]);
63
65
  }
64
66
 
65
67
  function TimeLine(_ref) {
@@ -1,5 +1,6 @@
1
1
  import Flvjs from 'flv.zv.js';
2
2
  import Hls, { HlsConfig } from 'hls.js';
3
+ import type VideoEventInstance from './event';
3
4
  import type { FlvPlayerConfig } from './player';
4
5
  /**
5
6
  * 创建HLS对象
@@ -13,7 +14,7 @@ export declare function createHlsPlayer(video: HTMLVideoElement, url: string, hl
13
14
  * @param {*} options
14
15
  */
15
16
  export declare function createFlvPlayer(video: HTMLVideoElement, url: string, isLive?: boolean, flvConfig?: FlvPlayerConfig): Flvjs.Player;
16
- export declare const playReload: (video: HTMLVideoElement, flv?: Flvjs.Player, hls?: Hls, url?: string) => void;
17
+ export declare const playReload: (video: HTMLVideoElement, event: VideoEventInstance, flv?: Flvjs.Player, hls?: Hls, url?: string) => void;
17
18
  export declare const playUnload: (video: HTMLVideoElement, flv?: Flvjs.Player, hls?: Hls) => void;
18
19
  /**
19
20
  * 获取播放文件类型
@@ -21,28 +22,6 @@ export declare const playUnload: (video: HTMLVideoElement, flv?: Flvjs.Player, h
21
22
  */
22
23
  export declare function getVideoType(url: string): "flv" | "native" | "m3u8";
23
24
  export declare function timeStamp(second: number): string;
24
- /**
25
- * 日期格式化
26
- * @param {*} timetemp
27
- */
28
- export declare function dateFormat(timetemp: number): string;
29
- /**
30
- * 全屏
31
- * @param {*} element
32
- */
33
- export declare function fullscreen(element: HTMLElement): void;
34
- /**
35
- * exitFullscreen 退出全屏
36
- * @param {Objct} element 选择器
37
- */
38
- export declare function exitFullscreen(): void;
39
- /**
40
- * 判读是否支持全屏
41
- */
42
- export declare function fullscreenEnabled(): boolean;
43
- /**
44
- * [isFullscreen 判断浏览器是否全屏]
45
- * @return [全屏则返回当前调用全屏的元素,不全屏返回false]
46
- */
47
- export declare function isFullscreen(ele: HTMLElement): boolean;
48
25
  export declare function getRandom(): string;
26
+ export declare function tryCatch(fn: () => void | Promise<any>): Promise<void>;
27
+ export declare const FMT = "YYYY-MM-DD HH:mm:ss";
package/es/Player/util.js CHANGED
@@ -1,5 +1,11 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
5
+ import { __awaiter } from "tslib";
1
6
  import Flvjs from 'flv.zv.js';
2
7
  import Hls from 'hls.js';
8
+ import Events from './event/eventName';
3
9
  /**
4
10
  * 创建HLS对象
5
11
  * @param {*} video
@@ -54,14 +60,16 @@ export function createFlvPlayer(video, url, isLive, flvConfig) {
54
60
  player.load();
55
61
  return player;
56
62
  }
57
- export var playReload = function playReload(video, flv, hls, url) {
63
+ export var playReload = function playReload(video, event, flv, hls, url) {
58
64
  video.pause();
59
65
  video.removeAttribute('src');
60
66
 
61
67
  if (flv) {
62
68
  flv.unload();
63
69
  flv.load();
64
- flv.play();
70
+ tryCatch(function () {
71
+ return flv.play();
72
+ });
65
73
  }
66
74
 
67
75
  if (hls) {
@@ -70,13 +78,19 @@ export var playReload = function playReload(video, flv, hls, url) {
70
78
  hls.stopLoad();
71
79
  hls.startLoad();
72
80
  hls.loadSource(url);
73
- video.play();
81
+ tryCatch(function () {
82
+ return video.play();
83
+ });
74
84
  }
75
85
 
76
86
  if (!flv && !hls) {
77
87
  video.setAttribute('src', url);
78
- video.play();
88
+ tryCatch(function () {
89
+ return video.play();
90
+ });
79
91
  }
92
+
93
+ event.emit(Events.RELOAD);
80
94
  };
81
95
  export var playUnload = function playUnload(video, flv, hls) {
82
96
  video.pause();
@@ -117,56 +131,34 @@ export function timeStamp(second) {
117
131
 
118
132
  return "".concat(h < 10 ? '0' + h : h, ":").concat(m < 10 ? '0' + m : m, ":").concat(s < 10 ? '0' + s : s);
119
133
  }
120
- /**
121
- * 日期格式化
122
- * @param {*} timetemp
123
- */
124
-
125
- export function dateFormat(timetemp) {
126
- var date = new Date(timetemp);
127
- var YYYY = date.getFullYear();
128
- var DD = date.getDate();
129
- var MM = date.getMonth() + 1;
130
- var hh = date.getHours();
131
- var mm = date.getMinutes();
132
- var ss = date.getSeconds();
133
- return "".concat(YYYY, ".").concat(MM > 9 ? MM : '0' + MM, ".").concat(DD > 9 ? DD : '0' + DD, " ").concat(hh > 9 ? hh : '0' + hh, ".").concat(mm > 9 ? mm : '0' + mm, ".").concat(ss > 9 ? ss : '0' + ss);
134
- }
135
- /**
136
- * 全屏
137
- * @param {*} element
138
- */
139
-
140
- export function fullscreen(element) {
141
- element.requestFullscreen();
142
- }
143
- /**
144
- * exitFullscreen 退出全屏
145
- * @param {Objct} element 选择器
146
- */
147
-
148
- export function exitFullscreen() {
149
- document.exitFullscreen();
150
- }
151
- /**
152
- * 判读是否支持全屏
153
- */
154
-
155
- export function fullscreenEnabled() {
156
- return document.fullscreenEnabled;
157
- }
158
- /**
159
- * [isFullscreen 判断浏览器是否全屏]
160
- * @return [全屏则返回当前调用全屏的元素,不全屏返回false]
161
- */
162
-
163
- export function isFullscreen(ele) {
164
- if (!ele) {
165
- return false;
166
- }
167
-
168
- return document.fullscreenElement === ele;
169
- }
170
134
  export function getRandom() {
171
135
  return Math.random().toString(36).substr(2);
172
- }
136
+ }
137
+ export function tryCatch(fn) {
138
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
139
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
140
+ while (1) {
141
+ switch (_context.prev = _context.next) {
142
+ case 0:
143
+ _context.prev = 0;
144
+ _context.next = 3;
145
+ return fn();
146
+
147
+ case 3:
148
+ _context.next = 8;
149
+ break;
150
+
151
+ case 5:
152
+ _context.prev = 5;
153
+ _context.t0 = _context["catch"](0);
154
+ console.debug(_context.t0);
155
+
156
+ case 8:
157
+ case "end":
158
+ return _context.stop();
159
+ }
160
+ }
161
+ }, _callee, null, [[0, 5]]);
162
+ }));
163
+ }
164
+ export var FMT = 'YYYY-MM-DD HH:mm:ss';
@@ -1,4 +1,4 @@
1
- .lm-player-ext-layput {
1
+ .lm-player-ext-layout {
2
2
  background-color: #000;
3
3
  width: 100%;
4
4
  height: 100%;
@@ -8,6 +8,6 @@
8
8
  align-items: center;
9
9
  justify-content: center;
10
10
  }
11
- .lm-player-ext-layput .lm-player-PlaySource {
11
+ .lm-player-ext-layout .lm-player-PlaySource {
12
12
  font-size: 66px;
13
13
  }
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import { ISegmentType } from '../Player/player';
2
3
  import './index.less';
3
4
  export declare type PlayModeType = 1 | 2;
4
5
  export interface IPluginProps {
5
6
  url?: string;
7
+ segments?: ISegmentType[];
6
8
  children: JSX.Element;
7
9
  /**
8
10
  * @description 模式1浏览器模式,2插件模式
@@ -38,5 +40,5 @@ export declare function getLocalPlayPath(url: string, params?: string): string;
38
40
  export declare function usePlugin(mode: PlayModeType, key: any): {
39
41
  needInstall: boolean;
40
42
  };
41
- export declare function ExtModel({ url, children, mode, pluginDownloadUrl, pluginParams }: IPluginProps): JSX.Element;
43
+ export declare function ExtModel({ url, children, mode, pluginDownloadUrl, segments, pluginParams }: IPluginProps): JSX.Element;
42
44
  export { ExtModel as default };
@@ -77,6 +77,7 @@ export function ExtModel(_ref) {
77
77
  children = _ref.children,
78
78
  mode = _ref.mode,
79
79
  pluginDownloadUrl = _ref.pluginDownloadUrl,
80
+ segments = _ref.segments,
80
81
  pluginParams = _ref.pluginParams;
81
82
 
82
83
  var _useState3 = useState({
@@ -87,8 +88,10 @@ export function ExtModel(_ref) {
87
88
  setState = _useState4[1];
88
89
 
89
90
  var hasUrl = useMemo(function () {
90
- return !!url;
91
- }, [url]);
91
+ return !!url || Array.isArray(segments) && segments.find(function (v) {
92
+ return v.url;
93
+ });
94
+ }, [url, segments]);
92
95
 
93
96
  var _usePlugin = usePlugin(mode, state.forceKey),
94
97
  needInstall = _usePlugin.needInstall;
@@ -96,10 +99,17 @@ export function ExtModel(_ref) {
96
99
  var playUrl = useMemo(function () {
97
100
  return mode === 2 && url ? getLocalPlayPath(url, pluginParams) : url;
98
101
  }, [url, mode]);
102
+ var playSegments = useMemo(function () {
103
+ return mode === 2 && segments ? segments.map(function (v) {
104
+ return Object.assign(Object.assign({}, v), {
105
+ url: v.url ? getLocalPlayPath(v.url, pluginParams) : v.url
106
+ });
107
+ }) : segments;
108
+ }, [segments, mode]);
99
109
 
100
110
  if (needInstall) {
101
111
  return /*#__PURE__*/React.createElement("div", {
102
- className: "lm-player-ext-layput"
112
+ className: "lm-player-ext-layout"
103
113
  }, /*#__PURE__*/React.createElement("div", {
104
114
  style: {
105
115
  marginTop: -60,
@@ -132,14 +142,18 @@ export function ExtModel(_ref) {
132
142
 
133
143
  if (!hasUrl) {
134
144
  return /*#__PURE__*/React.createElement("div", {
135
- className: "lm-player-ext-layput"
145
+ className: "lm-player-ext-layout"
136
146
  }, /*#__PURE__*/React.createElement(IconFont, {
137
147
  type: "lm-player-PlaySource"
138
148
  }));
139
149
  }
140
150
 
141
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(children, {
151
+ return /*#__PURE__*/React.createElement("div", {
152
+ className: "lm-player-ext-layout"
153
+ }, /*#__PURE__*/React.cloneElement(children, url ? {
142
154
  url: playUrl
155
+ } : {
156
+ segments: playSegments
143
157
  }));
144
158
  }
145
159
  export { ExtModel as default };
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { ILivePlayerProps } from './interface';
3
+ import './index.less';
4
+ declare function LivePlayer({ list, children }: ILivePlayerProps): JSX.Element;
5
+ export default LivePlayer;
@@ -0,0 +1,109 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import React, { useMemo, useRef, useState } from 'react';
14
+ import { ScreenType, mergeFill } from './utils';
15
+ import { LivePlayerWithExt } from './PlayerWithExt';
16
+ import Tools from './LiveTools';
17
+ import "./index.css";
18
+
19
+ function LivePlayer(_ref) {
20
+ var _ref$list = _ref.list,
21
+ list = _ref$list === void 0 ? [] : _ref$list,
22
+ children = _ref.children;
23
+
24
+ var _useState = useState({
25
+ screenNum: 4,
26
+ selectIndex: 0,
27
+ mode: 1
28
+ }),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ state = _useState2[0],
31
+ setState = _useState2[1];
32
+
33
+ var domRef = useRef(null); // 缓存所有player对象
34
+
35
+ var playerRef = useRef([]);
36
+ var screenType = useMemo(function () {
37
+ return ScreenType.find(function (v) {
38
+ return v.name === state.screenNum;
39
+ });
40
+ }, [state.screenNum]);
41
+ var screenList = useMemo(function () {
42
+ return mergeFill(state.screenNum, list, {});
43
+ }, [list, state.screenNum]); // 获取选中player对象
44
+
45
+ var getPlayerItem = function getPlayerItem() {
46
+ var _a;
47
+
48
+ return (_a = playerRef.current[state.selectIndex]) === null || _a === void 0 ? void 0 : _a.current;
49
+ }; // 更新状态
50
+
51
+
52
+ var updateState = function updateState(newState) {
53
+ var obj = {};
54
+
55
+ if (newState.hasOwnProperty('screenNum')) {
56
+ obj.screenNum = newState.screenNum;
57
+
58
+ if (obj.screenNum < state.selectIndex) {
59
+ obj.selectIndex = 0;
60
+ }
61
+ }
62
+
63
+ if (newState.hasOwnProperty('mode')) {
64
+ obj.mode = newState.mode;
65
+ }
66
+
67
+ setState(function (old) {
68
+ return Object.assign(Object.assign({}, old), obj);
69
+ });
70
+ };
71
+
72
+ return /*#__PURE__*/React.createElement("div", {
73
+ className: "split-screen-player-wrapper",
74
+ ref: domRef
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: "player-layout"
77
+ }, screenList.map(function (item, index) {
78
+ return /*#__PURE__*/React.createElement(LivePlayerWithExt, Object.assign({}, item, {
79
+ mode: state.mode,
80
+ isLive: true,
81
+ key: "".concat(item.url, "-").concat(index),
82
+ updatePlayer: function updatePlayer(player) {
83
+ return playerRef.current[index] = player;
84
+ },
85
+ className: state.selectIndex === index ? 'player-current-index' : '',
86
+ onClick: function onClick() {
87
+ return setState(function (old) {
88
+ return Object.assign(Object.assign({}, old), {
89
+ selectIndex: index
90
+ });
91
+ });
92
+ },
93
+ style: {
94
+ width: screenType.width,
95
+ height: screenType.height
96
+ }
97
+ }));
98
+ })), /*#__PURE__*/React.createElement(Tools, {
99
+ getPlayerItem: getPlayerItem,
100
+ screenNum: state.screenNum,
101
+ mode: state.mode,
102
+ containerRef: domRef,
103
+ updateState: updateState
104
+ }), children && /*#__PURE__*/React.cloneElement(children, {
105
+ selectIndex: state.selectIndex
106
+ }));
107
+ }
108
+
109
+ export default LivePlayer;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ExportPlayerType } from '../Player/player';
3
+ import { PlayModeType } from '../PlayerExt';
4
+ interface IToolsProps {
5
+ containerRef: React.MutableRefObject<HTMLDivElement>;
6
+ updateState: (state: {
7
+ screenNum?: number;
8
+ mode?: PlayModeType;
9
+ }) => void;
10
+ screenNum: number;
11
+ mode: PlayModeType;
12
+ getPlayerItem: () => ExportPlayerType | undefined;
13
+ }
14
+ declare function LiveTools({ containerRef, updateState, screenNum, getPlayerItem, mode }: IToolsProps): JSX.Element;
15
+ export default LiveTools;