@ray-js/ipc-player-integration 0.0.68-beta.0 → 0.0.69-beta.0

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 (153) hide show
  1. package/README.md +0 -6
  2. package/lib/ctx/ctx.album.test.d.ts +1 -0
  3. package/lib/ctx/ctx.album.test.js +197 -0
  4. package/lib/ctx/ctx.composition.js +13 -3
  5. package/lib/ctx/ctx.js +48 -35
  6. package/lib/ctx/multiCameraCtx.d.ts +2 -0
  7. package/lib/ctx/multiCameraCtx.js +17 -1
  8. package/lib/ctx/multiCameraCtx.test.d.ts +1 -0
  9. package/lib/ctx/multiCameraCtx.test.js +65 -0
  10. package/lib/i18n/index.d.ts +12 -0
  11. package/lib/i18n/strings.d.ts +6 -0
  12. package/lib/i18n/strings.js +6 -0
  13. package/lib/index.d.ts +0 -4
  14. package/lib/index.js +1 -3
  15. package/lib/interface.d.ts +18 -3
  16. package/lib/ui/absoluteContent.d.ts +2 -0
  17. package/lib/ui/absoluteContent.js +3 -0
  18. package/lib/ui/bottomCoverHeight.d.ts +2 -0
  19. package/lib/ui/bottomCoverHeight.js +6 -0
  20. package/lib/ui/bottomCoverHeight.test.d.ts +1 -0
  21. package/lib/ui/bottomCoverHeight.test.js +15 -0
  22. package/lib/ui/bottomLeftContent.js +65 -123
  23. package/lib/ui/bottomRightContent.js +13 -11
  24. package/lib/ui/topLeftContent.js +2 -4
  25. package/lib/ui/topRightContent.js +2 -4
  26. package/lib/ui/ui.d.ts +0 -5
  27. package/lib/ui/ui.js +100 -93
  28. package/lib/utils/captureResult.d.ts +12 -0
  29. package/lib/utils/captureResult.js +70 -0
  30. package/lib/utils/captureResult.test.d.ts +1 -0
  31. package/lib/utils/captureResult.test.js +223 -0
  32. package/lib/utils/fullLinkTracking.d.ts +5 -0
  33. package/lib/utils/fullLinkTracking.js +71 -0
  34. package/lib/utils/navigation.d.ts +2 -1
  35. package/lib/utils/navigation.js +13 -3
  36. package/lib/widgets/battery/battery.js +5 -7
  37. package/lib/widgets/battery/batteryFull.js +5 -7
  38. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  39. package/lib/widgets/captureResult/captureResult.js +85 -0
  40. package/lib/widgets/captureResult/captureResult.less +144 -0
  41. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  42. package/lib/widgets/captureResult/captureResult.test.js +84 -0
  43. package/lib/widgets/captureResult/index.d.ts +2 -0
  44. package/lib/widgets/captureResult/index.js +2 -0
  45. package/lib/widgets/floodlight/floodlight.js +1 -2
  46. package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
  47. package/lib/widgets/fullScreen/fullScreen.js +31 -44
  48. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +2 -2
  49. package/lib/widgets/fullScreen/fullTravelRouteControl.js +6 -3
  50. package/lib/widgets/fullScreen/verticalScreen.js +1 -2
  51. package/lib/widgets/index.d.ts +1 -0
  52. package/lib/widgets/index.js +2 -1
  53. package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
  54. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +5 -16
  55. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
  56. package/lib/widgets/multiCamera/index.less +1 -0
  57. package/lib/widgets/multiCamera/landscapeTip.js +2 -5
  58. package/lib/widgets/multiCamera/moveablePtzControl.js +7 -9
  59. package/lib/widgets/multiCamera/multiPtz.js +2 -3
  60. package/lib/widgets/multiCamera/ptzMoveableTip.js +2 -5
  61. package/lib/widgets/multiCamera/switchLayout.js +1 -2
  62. package/lib/widgets/multiCamera/tileMultiPtz.js +2 -3
  63. package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
  64. package/lib/widgets/multiCamera/tileTip.js +2 -5
  65. package/lib/widgets/muted/muted.js +1 -2
  66. package/lib/widgets/muted/muted.test.js +52 -66
  67. package/lib/widgets/ptz/ptz.js +1 -2
  68. package/lib/widgets/ptz/ptzControl.js +3 -4
  69. package/lib/widgets/ptzControlTip/ptzControlTip.js +4 -9
  70. package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
  71. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
  72. package/lib/widgets/recordVideo/recordVideo.js +178 -32
  73. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  74. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
  75. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
  76. package/lib/widgets/recordVideo/recordVideo.test.js +3 -169
  77. package/lib/widgets/resolution/fullResolutionControl.js +19 -29
  78. package/lib/widgets/resolution/resolution.js +2 -3
  79. package/lib/widgets/screenshot/screenshot.js +125 -35
  80. package/lib/widgets/screenshot/screenshot.less +1 -40
  81. package/lib/widgets/screenshot/screenshot.test.js +113 -108
  82. package/lib/widgets/signal4G/signal4G.js +1 -4
  83. package/lib/widgets/siren/siren.js +1 -2
  84. package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
  85. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
  86. package/lib/widgets/trialBadge/index.d.ts +2 -1
  87. package/lib/widgets/trialBadge/index.js +20 -17
  88. package/lib/widgets/trialBadge/index.less +0 -24
  89. package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
  90. package/lib/widgets/trialBadge/useTrialBadge.js +21 -3
  91. package/lib/widgets/tryExperience/tryExperience.js +1 -2
  92. package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
  93. package/lib/widgets/voiceIntercom/voiceIntercom.js +24 -50
  94. package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -16
  95. package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
  96. package/lib/widgets/zoomTurntable/turntable/index.js +1 -3
  97. package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +3 -5
  98. package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
  99. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +19 -32
  100. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +3 -24
  101. package/package.json +7 -15
  102. package/lib/renderer/capabilities.d.ts +0 -8
  103. package/lib/renderer/capabilities.js +0 -19
  104. package/lib/renderer/context.d.ts +0 -5
  105. package/lib/renderer/context.js +0 -6
  106. package/lib/renderer/directionControl.d.ts +0 -6
  107. package/lib/renderer/directionControl.js +0 -3
  108. package/lib/renderer/font-manifest.json +0 -9
  109. package/lib/renderer/font.less +0 -5
  110. package/lib/renderer/glyphs.d.ts +0 -1
  111. package/lib/renderer/glyphs.js +0 -256
  112. package/lib/renderer/index.module.less +0 -48
  113. package/lib/renderer/overlay.d.ts +0 -4
  114. package/lib/renderer/overlay.js +0 -6
  115. package/lib/renderer/ptzZoom.d.ts +0 -6
  116. package/lib/renderer/ptzZoom.js +0 -3
  117. package/lib/renderer/text.d.ts +0 -4
  118. package/lib/renderer/text.js +0 -32
  119. package/lib/renderer/text.module.less +0 -4
  120. package/lib/renderer/viewport.d.ts +0 -7
  121. package/lib/renderer/viewport.js +0 -24
  122. package/lib/res/lynx-signal/index.d.ts +0 -1
  123. package/lib/res/lynx-signal/index.js +0 -22
  124. package/lib/res/lynx-signal/signalFour0.png +0 -0
  125. package/lib/res/lynx-signal/signalFour1.png +0 -0
  126. package/lib/res/lynx-signal/signalFour2.png +0 -0
  127. package/lib/res/lynx-signal/signalFour3.png +0 -0
  128. package/lib/res/lynx-signal/signalFour4.png +0 -0
  129. package/lib/res/lynx-signal/signalThree0.png +0 -0
  130. package/lib/res/lynx-signal/signalThree1.png +0 -0
  131. package/lib/res/lynx-signal/signalThree2.png +0 -0
  132. package/lib/res/lynx-signal/signalThree3.png +0 -0
  133. package/lib/res/player-charging.png +0 -0
  134. package/lib/res/player-more-arrow.png +0 -0
  135. package/lib/res/player-solar.png +0 -0
  136. package/lib/ui/scrollHintArrow.d.ts +0 -23
  137. package/lib/ui/scrollHintArrow.js +0 -83
  138. package/lib/widgets/battery/statusIcon.d.ts +0 -6
  139. package/lib/widgets/battery/statusIcon.js +0 -36
  140. package/lib/widgets/battery/statusIcon.less +0 -24
  141. package/lib/widgets/captureToast/captureToast.d.ts +0 -9
  142. package/lib/widgets/captureToast/captureToast.js +0 -73
  143. package/lib/widgets/recordVideo/recordVideoTimer.d.ts +0 -3
  144. package/lib/widgets/recordVideo/recordVideoTimer.js +0 -26
  145. package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +0 -6
  146. package/lib/widgets/zoomTurntable/lynxDockLayout.js +0 -30
  147. package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +0 -5
  148. package/lib/widgets/zoomTurntable/turntable/lynx.js +0 -273
  149. package/lib/widgets/zoomTurntable/turntable/lynx.less +0 -9
  150. package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +0 -37
  151. package/lib/widgets/zoomTurntable/turntable/lynxModel.js +0 -122
  152. package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +0 -3
  153. package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +0 -36
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
- import { act, renderHook as renderPlayerHook } from '@testing-library/react-hooks/dom';
1
+ import { act, renderHook } from '@testing-library/react-hooks/dom';
3
2
  import { atom, getDefaultStore } from 'jotai';
4
- import { PlayerRenderModeContext } from '../../renderer/context';
5
3
  import { IntercomMode } from '../../interface';
6
4
  import { Muted } from './muted';
7
5
  jest.mock('@ray-js/ray', () => ({
@@ -29,67 +27,55 @@ const createProps = function () {
29
27
  }
30
28
  };
31
29
  };
32
- describe.each(['webview', 'lynx'])('%s speaker interactions', renderMode => {
33
- const renderHook = callback => renderPlayerHook(callback, {
34
- wrapper: _ref => {
35
- let {
36
- children
37
- } = _ref;
38
- return /*#__PURE__*/React.createElement(PlayerRenderModeContext.Provider, {
39
- value: renderMode
40
- }, children);
41
- }
42
- });
43
- it.each([[IntercomMode.OneWay, true], [IntercomMode.OneWay, false], [IntercomMode.TwoWay, true], [IntercomMode.TwoWay, false]])('blocks speaker changes and control events during talk in mode=%s, muted=%s', (mode, muted) => {
44
- const props = createProps(true, mode, muted);
45
- const {
46
- result,
47
- unmount
48
- } = renderHook(() => Muted(props));
49
- act(() => result.current.props.onClick());
50
- expect(props.setMute).not.toHaveBeenCalled();
51
- expect(props.event.emit).not.toHaveBeenCalled();
52
- expect(result.current.props.className).toContain('ipc-player-plugin-muted-disabled');
53
- unmount();
54
- });
55
- it.each([[false, IntercomMode.OneWay, true, false], [false, IntercomMode.OneWay, false, true], [false, IntercomMode.TwoWay, true, false], [false, IntercomMode.TwoWay, false, true]])('keeps speaker switching when talking=%s, mode=%s, muted=%s', (talking, mode, muted, target) => {
56
- const props = createProps(talking, mode, muted);
57
- const {
58
- result,
59
- unmount
60
- } = renderHook(() => Muted(props));
61
- act(() => result.current.props.onClick());
62
- expect(props.setMute).toHaveBeenCalledTimes(1);
63
- expect(props.setMute).toHaveBeenCalledWith(target);
64
- expect(result.current.props.className).not.toContain('ipc-player-plugin-muted-disabled');
65
- unmount();
66
- });
67
- it.each([IntercomMode.OneWay, IntercomMode.TwoWay])('uses shared talk state after remount and unlocks when talk ends in mode=%s', mode => {
68
- const props = createProps(false, mode);
69
- const store = getDefaultStore();
70
- const first = renderHook(() => Muted(props));
71
- act(() => store.set(props.intercom, true));
72
- act(() => first.result.current.props.onClick());
73
- expect(props.setMute).not.toHaveBeenCalled();
74
- first.unmount();
75
- const second = renderHook(() => Muted(props));
76
- act(() => second.result.current.props.onClick());
77
- expect(props.setMute).not.toHaveBeenCalled();
78
- act(() => store.set(props.intercom, false));
79
- act(() => second.result.current.props.onClick());
80
- expect(props.setMute).toHaveBeenCalledWith(false);
81
- second.unmount();
82
- });
83
- it.each([[IntercomMode.OneWay, IntercomMode.TwoWay], [IntercomMode.TwoWay, IntercomMode.OneWay]])('keeps the speaker locked when active talk changes from %s to %s', (mode, nextMode) => {
84
- const props = createProps(true, mode);
85
- const {
86
- result,
87
- unmount
88
- } = renderHook(() => Muted(props));
89
- act(() => getDefaultStore().set(props.intercomMode, nextMode));
90
- act(() => result.current.props.onClick());
91
- expect(props.setMute).not.toHaveBeenCalled();
92
- expect(props.event.emit).not.toHaveBeenCalled();
93
- unmount();
94
- });
30
+ it.each([[IntercomMode.OneWay, true], [IntercomMode.OneWay, false], [IntercomMode.TwoWay, true], [IntercomMode.TwoWay, false]])('blocks speaker changes and control events during talk in mode=%s, muted=%s', (mode, muted) => {
31
+ const props = createProps(true, mode, muted);
32
+ const {
33
+ result,
34
+ unmount
35
+ } = renderHook(() => Muted(props));
36
+ act(() => result.current.props.onClick());
37
+ expect(props.setMute).not.toHaveBeenCalled();
38
+ expect(props.event.emit).not.toHaveBeenCalled();
39
+ expect(result.current.props.className).toContain('ipc-player-plugin-muted-disabled');
40
+ unmount();
41
+ });
42
+ it.each([[false, IntercomMode.OneWay, true, false], [false, IntercomMode.OneWay, false, true], [false, IntercomMode.TwoWay, true, false], [false, IntercomMode.TwoWay, false, true]])('keeps speaker switching when talking=%s, mode=%s, muted=%s', (talking, mode, muted, target) => {
43
+ const props = createProps(talking, mode, muted);
44
+ const {
45
+ result,
46
+ unmount
47
+ } = renderHook(() => Muted(props));
48
+ act(() => result.current.props.onClick());
49
+ expect(props.setMute).toHaveBeenCalledTimes(1);
50
+ expect(props.setMute).toHaveBeenCalledWith(target);
51
+ expect(result.current.props.className).not.toContain('ipc-player-plugin-muted-disabled');
52
+ unmount();
53
+ });
54
+ it.each([IntercomMode.OneWay, IntercomMode.TwoWay])('uses shared talk state after remount and unlocks when talk ends in mode=%s', mode => {
55
+ const props = createProps(false, mode);
56
+ const store = getDefaultStore();
57
+ const first = renderHook(() => Muted(props));
58
+ act(() => store.set(props.intercom, true));
59
+ act(() => first.result.current.props.onClick());
60
+ expect(props.setMute).not.toHaveBeenCalled();
61
+ first.unmount();
62
+ const second = renderHook(() => Muted(props));
63
+ act(() => second.result.current.props.onClick());
64
+ expect(props.setMute).not.toHaveBeenCalled();
65
+ act(() => store.set(props.intercom, false));
66
+ act(() => second.result.current.props.onClick());
67
+ expect(props.setMute).toHaveBeenCalledWith(false);
68
+ second.unmount();
69
+ });
70
+ it.each([[IntercomMode.OneWay, IntercomMode.TwoWay], [IntercomMode.TwoWay, IntercomMode.OneWay]])('keeps the speaker locked when active talk changes from %s to %s', (mode, nextMode) => {
71
+ const props = createProps(true, mode);
72
+ const {
73
+ result,
74
+ unmount
75
+ } = renderHook(() => Muted(props));
76
+ act(() => getDefaultStore().set(props.intercomMode, nextMode));
77
+ act(() => result.current.props.onClick());
78
+ expect(props.setMute).not.toHaveBeenCalled();
79
+ expect(props.event.emit).not.toHaveBeenCalled();
80
+ unmount();
95
81
  });
@@ -1,9 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { View } from '@ray-js/ray';
2
+ import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import React, { useEffect, useState, useContext } from 'react';
5
5
  import { useMemoizedFn } from 'ahooks';
6
- import { PlayerText as Text } from '../../renderer/text';
7
6
  import { UIEventContext } from '../../ui/context';
8
7
  import { usePtz } from '../../hooks';
9
8
  import { useStore } from '../../ctx/store';
@@ -1,11 +1,11 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext, useEffect, useRef, useState } from 'react';
3
+ import { CoverView } from '@ray-js/ray';
3
4
  import clsx from 'clsx';
4
5
  import _find from 'lodash/find';
5
6
  import _get from 'lodash/get';
7
+ import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
6
8
  import { getDpIdByCode, publishDps } from '@ray-js/ray-ipc-utils';
7
- import { usePlayerOverlayHost } from '../../renderer/overlay';
8
- import IpcPtzZoom from '../../renderer/ptzZoom';
9
9
  import { Storage } from '../../utils/storage';
10
10
  import { useMemoizedFn } from '../../hooks';
11
11
  import { useComponentHideState } from '../../ui/hooks';
@@ -39,7 +39,6 @@ const getPtzData = devId => {
39
39
  }];
40
40
  };
41
41
  export const PtzControl = props => {
42
- const OverlayView = usePlayerOverlayHost();
43
42
  const {
44
43
  devId,
45
44
  addContent
@@ -135,7 +134,7 @@ export const PtzControl = props => {
135
134
  ptzTimeId.current = null;
136
135
  }
137
136
  };
138
- return /*#__PURE__*/React.createElement(OverlayView, {
137
+ return /*#__PURE__*/React.createElement(CoverView, {
139
138
  className: clsx('ipc-player-plugin-full-screen-ptz-control', {
140
139
  'ipc-player-plugin-full-screen-ptz-control-hide': !isPtzActive || shouldHide,
141
140
  'ipc-player-plugin-full-screen-ptz-disappear': screenType === 'vertical'
@@ -1,9 +1,6 @@
1
1
  import React, { useState } from 'react';
2
- import { View, Image, setStorage } from '@ray-js/ray';
2
+ import { View, Image, CoverView, Text, setStorage } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import { usePlayerOverlayHost } from '../../renderer/overlay';
5
- import { PlayerText as Text } from '../../renderer/text';
6
- import { usePlayerRenderMode } from '../../renderer/context';
7
4
  import { useStore } from '../../ctx/store';
8
5
  import { ptzControlTipId, widgetLabs, widgetClick } from '../../ui/constant';
9
6
  import { PlayState } from '../../interface';
@@ -11,12 +8,10 @@ import './ptzControlTip.less';
11
8
  import { playerPtzControlTip } from '../../res';
12
9
  import Strings from '../../i18n';
13
10
  export const PtzControlTip = props => {
14
- const OverlayView = usePlayerOverlayHost();
15
11
  const {
16
12
  devId,
17
13
  deleteContent
18
14
  } = props;
19
- const isLynx = usePlayerRenderMode() === 'lynx';
20
15
  const [showTipModal, setShowTipModal] = useState(true);
21
16
  const {
22
17
  playState
@@ -36,12 +31,12 @@ export const PtzControlTip = props => {
36
31
  });
37
32
  };
38
33
  if (showTipModal && playState === PlayState.PLAYING) {
39
- return /*#__PURE__*/React.createElement(OverlayView, {
34
+ return /*#__PURE__*/React.createElement(CoverView, {
40
35
  className: clsx('playerControlTipContainer')
41
36
  }, /*#__PURE__*/React.createElement(Image, {
42
- mode: isLynx ? 'aspectFit' : 'widthFix',
37
+ mode: "widthFix",
43
38
  src: playerPtzControlTip,
44
- className: clsx('controlTipImage', isLynx && 'controlTipImageLynx')
39
+ className: clsx('controlTipImage')
45
40
  }), /*#__PURE__*/React.createElement(Text, {
46
41
  className: clsx('controlTipText')
47
42
  }, Strings.getLang('ipc_player_ptz_control_tip')), /*#__PURE__*/React.createElement(View, {
@@ -39,9 +39,3 @@
39
39
  color: #ffffff;
40
40
  }
41
41
  }
42
-
43
- // Original PNG is 404 x 158. Lynx needs both dimensions; widthFix is WebView-only.
44
- .playerControlTipContainer .controlTipImageLynx {
45
- height: calc(66.4851485149px * var(--ipc-player-size-scale, 1));
46
- flex-shrink: 0;
47
- }
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
- import { View } from '@ray-js/ray';
2
+ import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import { PlayerText as Text } from '../../renderer/text';
5
4
  import { PlayState } from '../../interface';
6
5
  import { useStore } from '../../ctx/store';
7
6
  import { useDpSupport } from '../../hooks/useDpSupport';
@@ -1,19 +1,80 @@
1
- import React, { useEffect, useRef, useContext } from 'react';
2
- import { View, getSystemInfoSync } from '@ray-js/ray';
3
- import { useMemoizedFn } from 'ahooks';
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import React, { useState, useEffect, useRef, useContext } from 'react';
4
+ import { View, Text, getSystemInfoSync } from '@ray-js/ray';
5
+ import { useSetState, useUpdateEffect } from 'ahooks';
4
6
  import clsx from 'clsx';
5
- import { PlayerText as Text } from '../../renderer/text';
7
+ import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
6
8
  import Strings from '../../i18n';
7
9
  import { PlayState } from '../../interface';
10
+ import { getCaptureResultSummary } from '../../utils/captureResult';
11
+ import { CaptureResultToast } from '../captureResult/captureResult';
8
12
  import { UIEventContext } from '../../ui/context';
9
13
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
10
14
  import { useStore, getDefaultStore } from '../../ctx/store';
11
- import RecordVideoTimer from './recordVideoTimer';
12
- import CaptureToast from '../captureToast/captureToast';
13
15
  import './recordVideo.less';
16
+ const CLOSE_TIME = 5000;
14
17
  const RESET_TIMER = 3000;
15
18
  const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
16
19
  const RECORD_VIDEO_TIMER_ID = 'record_video_timer_id';
20
+ function formatTimeDiff(diff) {
21
+ const padWithZero = true;
22
+ const diffMs = Math.abs(diff);
23
+ const minutes = Math.floor(diffMs / (1000 * 60));
24
+ const sec = Math.floor(diffMs % (1000 * 60) / 1000);
25
+ const formattedMinutes = String(minutes).padStart(2, '0');
26
+ const formattedSec = String(sec).padStart(2, '0');
27
+ return [formattedMinutes, formattedSec];
28
+ }
29
+ function useTime() {
30
+ const timer = useRef();
31
+ const startTime = useRef(0);
32
+ if (!startTime.current) {
33
+ startTime.current = new Date().getTime();
34
+ }
35
+ const [diffTime, setDiffTime] = useState(0);
36
+ useEffect(() => {
37
+ // @ts-ignore
38
+ timer.current = setInterval(() => {
39
+ const now = new Date().getTime();
40
+ setDiffTime(now - startTime.current);
41
+ }, 1000);
42
+ return () => {
43
+ clearInterval(timer.current);
44
+ };
45
+ }, []);
46
+ const cancel = () => {
47
+ clearInterval(timer.current);
48
+ };
49
+ if (!diffTime) {
50
+ return {
51
+ min: '00',
52
+ sec: '00',
53
+ cancel
54
+ };
55
+ }
56
+ const ret = formatTimeDiff(diffTime);
57
+ return {
58
+ min: ret[0],
59
+ sec: ret[1]
60
+ };
61
+ }
62
+ function TimeRecord() {
63
+ const {
64
+ min,
65
+ sec,
66
+ cancel
67
+ } = useTime();
68
+ return /*#__PURE__*/React.createElement(View, {
69
+ className: "ipc-player-plugin-record-video-toast-time"
70
+ }, /*#__PURE__*/React.createElement(View, {
71
+ className: "ipc-player-plugin-record-video-toast-time-warp"
72
+ }, min), /*#__PURE__*/React.createElement(View, {
73
+ className: "ipc-player-plugin-record-video-toast-time-delimiter"
74
+ }, ":"), /*#__PURE__*/React.createElement(View, {
75
+ className: "ipc-player-plugin-record-video-toast-time-warp"
76
+ }, sec));
77
+ }
17
78
  export function RecordVideo(props) {
18
79
  const {
19
80
  event
@@ -32,32 +93,76 @@ export function RecordVideo(props) {
32
93
  const {
33
94
  recording,
34
95
  brandColor,
96
+ screenType,
35
97
  recordingDisabled,
36
98
  playState
37
99
  } = useStore({
38
100
  recording: recordingAtom,
39
101
  brandColor: props.brandColor,
102
+ screenType: props.screenType,
40
103
  recordingDisabled: props.recordingDisabled,
41
104
  playState: props.playState
42
105
  });
43
- const removeRecordTimer = useMemoizedFn(() => deleteContent('absolute', RECORD_VIDEO_TIMER_ID));
106
+ const [state, setState] = useSetState({
107
+ showShot: false,
108
+ shotUrl: '',
109
+ shotCount: 0
110
+ });
111
+ const recordResultRequestIdRef = useRef(0);
44
112
  useEffect(() => {
45
- if (!recording) removeRecordTimer();
46
- }, [recording, removeRecordTimer]);
113
+ return () => {
114
+ recordResultRequestIdRef.current += 1;
115
+ };
116
+ }, []);
117
+ const showRecordResult = async recordInfo => {
118
+ var _props$multiCameraCtx;
119
+ const requestId = ++recordResultRequestIdRef.current;
120
+ const lensIndices = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.split_info) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.map(lens => lens.index);
121
+ const summary = await getCaptureResultSummary(recordInfo, {
122
+ multiLens: props.multiLens,
123
+ lensIndices,
124
+ devId
125
+ });
126
+ if (requestId !== recordResultRequestIdRef.current) return;
127
+ if (!summary) return;
128
+ setState({
129
+ showShot: true,
130
+ shotUrl: summary.thumbnailPath,
131
+ shotCount: summary.isMultiLens ? summary.count : 0
132
+ });
133
+ };
47
134
 
48
135
  /**
49
136
  * 针对 playState为非连接中状态时,如果处于录制中, 结束录制
50
137
  */
51
138
  useEffect(() => {
52
139
  (async () => {
53
- if (playState !== PlayState.PLAYING) {
54
- if (recording) {
55
- await setRecording(false);
140
+ if (playState !== PlayState.PLAYING && recording) {
141
+ try {
142
+ const recordInfo = await setRecording(false);
143
+ await showRecordResult(recordInfo);
144
+ } catch {
145
+ // setRecording reports the native failure through the configured toast.
56
146
  }
57
147
  }
58
148
  })();
59
149
  }, [playState, recording]);
60
150
 
151
+ /** 设置5秒后关闭录制成功弹窗 */
152
+ const timer = useRef();
153
+ const timeToCloseRecordToast = () => {
154
+ clearTimeout(timer.current);
155
+ // @ts-ignore
156
+ timer.current = setTimeout(() => {
157
+ setState({
158
+ showShot: false,
159
+ shotUrl: '',
160
+ shotCount: 0
161
+ });
162
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
163
+ }, CLOSE_TIME);
164
+ };
165
+
61
166
  /** 设置3秒后还原禁止结束录像状态 */
62
167
  const recordDisabledTimer = useRef();
63
168
  const timeToResetRecordDisabled = () => {
@@ -67,22 +172,56 @@ export function RecordVideo(props) {
67
172
  setRecordingDisabled(false);
68
173
  }, RESET_TIMER);
69
174
  };
70
- const showRecordToast = imageUrl => {
175
+ useUpdateEffect(() => {
176
+ if (state.showShot && screenType) {
177
+ showRecordToast();
178
+ }
179
+ }, [state.showShot, screenType]);
180
+ useUpdateEffect(() => {
181
+ if (recording) {
182
+ showRecordTimer();
183
+ } else {
184
+ deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
185
+ }
186
+ }, [recording]);
187
+
188
+ /** 跳转相册 */
189
+ const handCheck = () => {
190
+ setState({
191
+ showShot: false,
192
+ shotUrl: '',
193
+ shotCount: 0
194
+ });
195
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
196
+ clearInterval(timer.current);
197
+ goToIpcPageNativeRoute('ipc_album_panel', devId);
198
+ };
199
+
200
+ /** 添加录制成功弹窗 */
201
+ const showRecordToast = () => {
71
202
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
72
203
  addContent('absolute', {
73
204
  id: RECORD_VIDEO_SUCCESS_TOAST_ID,
74
- absoluteNoCoverView: true,
75
- content: CaptureToast,
76
- initProps: {
77
- kind: 'record',
78
- imageUrl,
79
- captureId: Date.now(),
80
- screenType: props.screenType,
81
- brandColor: props.brandColor,
82
- devId,
83
- deleteContent
205
+ absoluteContentClassName: 'ipc-player-plugin-record-success-toast-wrap',
206
+ absolutePosition: {
207
+ top: screenType === 'vertical' ? '12px' : '60px',
208
+ left: screenType === 'vertical' ? '16px' : '50%',
209
+ right: screenType === 'vertical' ? '16px' : 'unset',
210
+ display: 'flex',
211
+ width: screenType === 'vertical' ? 'auto' : '400px',
212
+ marginLeft: screenType === 'vertical' ? '0' : '-200px'
213
+ },
214
+ content: () => {
215
+ return /*#__PURE__*/React.createElement(CaptureResultToast, {
216
+ brandColor: brandColor,
217
+ count: state.shotCount,
218
+ kind: "record",
219
+ onCheck: handCheck,
220
+ thumbnailPath: state.shotUrl
221
+ });
84
222
  }
85
223
  });
224
+ timeToCloseRecordToast();
86
225
  };
87
226
  const showRecordTimer = () => {
88
227
  deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
@@ -90,19 +229,22 @@ export function RecordVideo(props) {
90
229
  id: RECORD_VIDEO_TIMER_ID,
91
230
  absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
92
231
  content: () => /*#__PURE__*/React.createElement(View, {
93
- className: "ipc-player-plugin-record-video-toast ipc-player-plugin-record-video-toast-show"
232
+ className: clsx('ipc-player-plugin-record-video-toast', {
233
+ 'ipc-player-plugin-record-video-toast-show': recording,
234
+ 'ipc-player-plugin-record-video-toast-hide': !recording
235
+ })
94
236
  }, /*#__PURE__*/React.createElement(View, {
95
237
  className: "ipc-player-plugin-record-video-toast-point",
96
238
  style: {
97
239
  backgroundColor: brandColor
98
240
  }
99
- }), /*#__PURE__*/React.createElement(RecordVideoTimer, null))
241
+ }), /*#__PURE__*/React.createElement(TimeRecord, null))
100
242
  });
101
243
  };
102
244
  const handRecordVideo = async () => {
103
- var _props$event, _props$event2;
245
+ var _props$event;
104
246
  const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
105
- ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
247
+ ev.emit(widgetClick, {
106
248
  widgetId: widgetLabs.RECORD_VIDEO
107
249
  });
108
250
  event.emit(pauseTimeToHideAllComponent);
@@ -112,7 +254,14 @@ export function RecordVideo(props) {
112
254
  if (recordingDisabled) {
113
255
  return false;
114
256
  }
115
- deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
257
+ recordResultRequestIdRef.current += 1;
258
+ if (state.showShot) {
259
+ setState({
260
+ showShot: false
261
+ });
262
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
263
+ clearTimeout(timer.current);
264
+ }
116
265
  // 发送忽略进入后台停止预览的标记
117
266
  const {
118
267
  platform
@@ -128,13 +277,11 @@ export function RecordVideo(props) {
128
277
  }
129
278
  if (target) {
130
279
  setRecordingDisabled(true);
131
- showRecordTimer();
132
280
  /** 录制开始后3秒后才可结束 */
133
281
  timeToResetRecordDisabled();
134
282
  } else {
135
283
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
136
- removeRecordTimer();
137
- showRecordToast(recordInfo.tempImagePath);
284
+ await showRecordResult(recordInfo);
138
285
  }
139
286
  } catch (err) {
140
287
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
@@ -144,7 +291,6 @@ export function RecordVideo(props) {
144
291
  toast({
145
292
  title: errMsg
146
293
  });
147
- removeRecordTimer();
148
294
  }
149
295
  return true;
150
296
  };
@@ -1,116 +1,59 @@
1
1
  .ipc-player-plugin-record-video-icon {
2
- font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
3
2
  color: var(--iconColor);
3
+ font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
4
  }
5
+
5
6
  .ipc-player-plugin-record-video-toast-wrap {
6
- z-index: 400;
7
7
  position: absolute;
8
8
  top: calc(7px * var(--ipc-player-size-scale, 1));
9
9
  left: 50%;
10
+ z-index: 400;
10
11
  transform: translateX(-50%);
11
12
  }
12
13
 
13
- // 计时器显示
14
14
  .ipc-player-plugin-record-video-toast-show {
15
15
  transform: translate(0, 0) !important;
16
16
  transition: transform ease-in 3s;
17
17
  }
18
- // 计时器隐藏
18
+
19
19
  .ipc-player-plugin-record-video-toast-hide {
20
20
  transform: translate(0, -110%) !important;
21
21
  transition: transform 0.3s ease-in-out;
22
22
  }
23
23
 
24
24
  .ipc-player-plugin-record-video-toast {
25
- transform: translate(0, -110%);
26
25
  display: flex;
27
- padding: calc(12px * var(--ipc-player-size-scale, 1));
28
26
  align-items: center;
29
- background-color: var(--shot-card-bg-color);
27
+ padding: calc(12px * var(--ipc-player-size-scale, 1));
28
+ background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)),
29
+ #000000;
30
30
  border-radius: calc(8px * var(--ipc-player-size-scale, 1));
31
- // background-color: #fff;
32
- background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)), #000000;
31
+ transform: translate(0, -110%);
32
+
33
33
  .ipc-player-plugin-record-video-toast-point {
34
34
  width: calc(6px * var(--ipc-player-size-scale, 1));
35
35
  height: calc(6px * var(--ipc-player-size-scale, 1));
36
36
  border-radius: calc(6px * var(--ipc-player-size-scale, 1));
37
37
  }
38
+
38
39
  .ipc-player-plugin-record-video-toast-time {
39
- font-size: calc(12px * var(--ipc-player-size-scale, 1));;
40
- font-weight: 700;
41
- color: var(--fontColor);
42
- margin-left: calc(8px * var(--ipc-player-size-scale, 1));;
43
40
  display: flex;
44
41
  align-items: center;
42
+ margin-left: calc(8px * var(--ipc-player-size-scale, 1));
43
+ color: var(--fontColor);
44
+ font-weight: 700;
45
+ font-size: calc(12px * var(--ipc-player-size-scale, 1));
46
+
45
47
  .ipc-player-plugin-record-video-toast-time-warp {
46
48
  text-align: center;
47
49
  }
50
+
48
51
  .ipc-player-plugin-record-video-toast-time-delimiter {
49
- margin: 0 calc(2px * var(--ipc-player-size-scale, 1));;
52
+ margin: 0 calc(2px * var(--ipc-player-size-scale, 1));
50
53
  }
51
54
  }
52
55
  }
53
56
 
54
- /** 录制成功弹窗 */
55
57
  .ipc-player-plugin-record-success-toast-wrap {
56
58
  position: absolute;
57
59
  }
58
- .ipc-player-plugin-record-success-toast {
59
- flex: 1;
60
- border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
61
- background-color: var(--shot-card-bg-color);
62
- display: flex;
63
- align-items: center;
64
- padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
65
- z-index: 100;
66
- .ipc-player-plugin-record-success-toast-image-box {
67
- border-radius: calc(4px * var(--ipc-player-size-scale, 1));
68
- overflow: hidden;
69
- width: calc(66px * var(--ipc-player-size-scale, 1));
70
- height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
71
- position: relative;
72
- }
73
- .ipc-player-plugin-record-success-toast-image {
74
- width: 100%;
75
- height: 100%;
76
- object-fit: cover;
77
- }
78
- .ipc-player-plugin-record-success-play-icon-box {
79
- width: 30px;
80
- height: 30px;
81
- background-color: rgba(0, 0, 0, 0.2);
82
- border-radius: 50%;
83
- overflow: hidden;
84
- position: absolute;
85
- top: 50%;
86
- left: 50%;
87
- transform: translate(-50%, -50%);
88
- display: flex;
89
- align-items: center;
90
- justify-content: center;
91
- }
92
- .ipc-player-plugin-record-success-play-icon {
93
- font-size: calc(18px * var(--ipc-player-size-scale, 1)) !important;
94
- color: #ffffff;
95
- }
96
- .ipc-player-plugin-record-success-toast-title {
97
- flex: 1;
98
- margin-left: calc(12px * var(--ipc-player-size-scale, 1));
99
- font-size: calc(14px * var(--ipc-player-size-scale, 1));
100
- color: var(--fontColor);
101
- margin-right: calc(12px * var(--ipc-player-size-scale, 1));
102
- word-break: break-word;
103
-
104
- }
105
- .ipc-player-plugin-record-success-toast-bottom {
106
- border: 1px solid #1989FA;
107
- min-width: calc(52px * var(--ipc-player-size-scale, 1));
108
- max-width: calc(100px * var(--ipc-player-size-scale, 1));
109
- border-radius: calc(4px * var(--ipc-player-size-scale, 1));
110
- padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
111
- font-size: calc(14px * var(--ipc-player-size-scale, 1));
112
- white-space: nowrap;
113
- overflow: hidden;
114
- text-overflow: ellipsis;
115
- }
116
- }