@ray-js/ipc-player-integration 0.0.70 → 0.0.71-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 (120) hide show
  1. package/README.md +6 -0
  2. package/lib/ctx/ctx.js +12 -17
  3. package/lib/ctx/ctx.test.js +54 -19
  4. package/lib/ctx/intercom.test.d.ts +1 -0
  5. package/lib/ctx/intercom.test.js +85 -0
  6. package/lib/index.d.ts +4 -0
  7. package/lib/index.js +3 -1
  8. package/lib/renderer/capabilities.d.ts +8 -0
  9. package/lib/renderer/capabilities.js +19 -0
  10. package/lib/renderer/context.d.ts +5 -0
  11. package/lib/renderer/context.js +6 -0
  12. package/lib/renderer/directionControl.d.ts +6 -0
  13. package/lib/renderer/directionControl.js +3 -0
  14. package/lib/renderer/font-manifest.json +9 -0
  15. package/lib/renderer/font.less +5 -0
  16. package/lib/renderer/glyphs.d.ts +1 -0
  17. package/lib/renderer/glyphs.js +256 -0
  18. package/lib/renderer/index.module.less +48 -0
  19. package/lib/renderer/overlay.d.ts +6 -0
  20. package/lib/renderer/overlay.js +18 -0
  21. package/lib/renderer/ptzZoom.d.ts +6 -0
  22. package/lib/renderer/ptzZoom.js +3 -0
  23. package/lib/renderer/text.d.ts +4 -0
  24. package/lib/renderer/text.js +32 -0
  25. package/lib/renderer/text.module.less +4 -0
  26. package/lib/renderer/viewport.d.ts +7 -0
  27. package/lib/renderer/viewport.js +24 -0
  28. package/lib/res/lynx-signal/index.d.ts +1 -0
  29. package/lib/res/lynx-signal/index.js +22 -0
  30. package/lib/res/lynx-signal/signalFour0.png +0 -0
  31. package/lib/res/lynx-signal/signalFour1.png +0 -0
  32. package/lib/res/lynx-signal/signalFour2.png +0 -0
  33. package/lib/res/lynx-signal/signalFour3.png +0 -0
  34. package/lib/res/lynx-signal/signalFour4.png +0 -0
  35. package/lib/res/lynx-signal/signalThree0.png +0 -0
  36. package/lib/res/lynx-signal/signalThree1.png +0 -0
  37. package/lib/res/lynx-signal/signalThree2.png +0 -0
  38. package/lib/res/lynx-signal/signalThree3.png +0 -0
  39. package/lib/res/player-charging.png +0 -0
  40. package/lib/res/player-more-arrow.png +0 -0
  41. package/lib/res/player-solar.png +0 -0
  42. package/lib/ui/bottomLeftContent.js +121 -53
  43. package/lib/ui/bottomRightContent.js +10 -5
  44. package/lib/ui/scrollHintArrow.d.ts +23 -0
  45. package/lib/ui/scrollHintArrow.js +83 -0
  46. package/lib/ui/topLeftContent.js +4 -2
  47. package/lib/ui/topRightContent.js +4 -2
  48. package/lib/ui/ui.d.ts +5 -0
  49. package/lib/ui/ui.js +46 -23
  50. package/lib/widgets/battery/battery.js +7 -5
  51. package/lib/widgets/battery/batteryFull.js +7 -5
  52. package/lib/widgets/battery/statusIcon.d.ts +6 -0
  53. package/lib/widgets/battery/statusIcon.js +36 -0
  54. package/lib/widgets/battery/statusIcon.less +24 -0
  55. package/lib/widgets/captureResult/captureResult.js +2 -1
  56. package/lib/widgets/captureToast/captureToast.d.ts +10 -0
  57. package/lib/widgets/captureToast/captureToast.js +58 -0
  58. package/lib/widgets/floodlight/floodlight.js +2 -1
  59. package/lib/widgets/flowLowTip/flowLowTip.js +2 -1
  60. package/lib/widgets/fullScreen/fullScreen.js +2 -1
  61. package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
  62. package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
  63. package/lib/widgets/fullScreen/verticalScreen.js +2 -1
  64. package/lib/widgets/moveInteractiveControl/controlButton.js +2 -1
  65. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +16 -5
  66. package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +24 -4
  67. package/lib/widgets/multiCamera/landscapeTip.js +8 -2
  68. package/lib/widgets/multiCamera/moveablePtzControl.js +5 -3
  69. package/lib/widgets/multiCamera/multiPtz.js +2 -1
  70. package/lib/widgets/multiCamera/ptzMoveableTip.js +8 -2
  71. package/lib/widgets/multiCamera/switchLayout.js +2 -1
  72. package/lib/widgets/multiCamera/tileMultiPtz.js +2 -1
  73. package/lib/widgets/multiCamera/tileSwitchLayout.js +2 -1
  74. package/lib/widgets/multiCamera/tileTip.js +8 -2
  75. package/lib/widgets/muted/muted.js +2 -1
  76. package/lib/widgets/muted/muted.test.js +66 -52
  77. package/lib/widgets/ptz/ptz.js +2 -1
  78. package/lib/widgets/ptz/ptzControl.js +4 -3
  79. package/lib/widgets/ptzControlTip/ptzControlTip.js +9 -4
  80. package/lib/widgets/ptzControlTip/ptzControlTip.less +6 -0
  81. package/lib/widgets/realTimeMagnification/realTimeMagnification.js +2 -1
  82. package/lib/widgets/recordVideo/recordVideo.js +47 -169
  83. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +4 -2
  84. package/lib/widgets/recordVideo/recordVideo.test.js +169 -2
  85. package/lib/widgets/recordVideo/recordVideoTimer.d.ts +3 -0
  86. package/lib/widgets/recordVideo/recordVideoTimer.js +26 -0
  87. package/lib/widgets/resolution/fullResolutionControl.js +29 -19
  88. package/lib/widgets/resolution/resolution.js +3 -2
  89. package/lib/widgets/screenshot/screenshot.js +48 -122
  90. package/lib/widgets/screenshot/screenshot.permissions.test.d.ts +1 -0
  91. package/lib/widgets/screenshot/screenshot.permissions.test.js +137 -0
  92. package/lib/widgets/screenshot/screenshot.test.js +108 -113
  93. package/lib/widgets/signal4G/signal4G.js +4 -1
  94. package/lib/widgets/siren/siren.js +2 -1
  95. package/lib/widgets/tempHumidity/tempHumidity.js +2 -1
  96. package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +2 -1
  97. package/lib/widgets/trialBadge/index.js +8 -3
  98. package/lib/widgets/trialBadge/index.less +24 -0
  99. package/lib/widgets/tryExperience/tryExperience.js +2 -1
  100. package/lib/widgets/videoBitKBP/videoBitKBP.js +2 -1
  101. package/lib/widgets/voiceIntercom/voiceIntercom.js +57 -81
  102. package/lib/widgets/voiceIntercom/voiceIntercom.less +35 -0
  103. package/lib/widgets/voiceIntercom/voiceIntercom.test.d.ts +1 -0
  104. package/lib/widgets/voiceIntercom/voiceIntercom.test.js +135 -0
  105. package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +6 -0
  106. package/lib/widgets/zoomTurntable/lynxDockLayout.js +30 -0
  107. package/lib/widgets/zoomTurntable/turntable/index.d.ts +5 -7
  108. package/lib/widgets/zoomTurntable/turntable/index.js +3 -1
  109. package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +5 -0
  110. package/lib/widgets/zoomTurntable/turntable/lynx.js +273 -0
  111. package/lib/widgets/zoomTurntable/turntable/lynx.less +9 -0
  112. package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +37 -0
  113. package/lib/widgets/zoomTurntable/turntable/lynxModel.js +122 -0
  114. package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +3 -0
  115. package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +36 -0
  116. package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +5 -3
  117. package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
  118. package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +32 -19
  119. package/lib/widgets/zoomTurntable/zoomTurntableTip.js +17 -3
  120. package/package.json +15 -7
@@ -1,6 +1,8 @@
1
1
  import React, { useMemo, useState } from 'react';
2
- import { View, CoverView, Text } from '@ray-js/ray';
2
+ import { View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
+ import { usePlayerOverlayHost, usePlayerOverlayFillStyle } from '../../renderer/overlay';
5
+ import { PlayerText as Text } from '../../renderer/text';
4
6
  import { useStore } from '../../ctx/store';
5
7
  import { ptzMoveableTipId } from '../../ui/constant';
6
8
  import { PlayState } from '../../interface';
@@ -9,6 +11,8 @@ import { multiPrefix } from './constants';
9
11
  import { Storage } from '../../utils/storage';
10
12
  import './index.less';
11
13
  export const PtzMoveableTip = props => {
14
+ const OverlayView = usePlayerOverlayHost();
15
+ const overlayStyle = usePlayerOverlayFillStyle();
12
16
  const {
13
17
  devId,
14
18
  positionLeft = 24,
@@ -44,7 +48,9 @@ export const PtzMoveableTip = props => {
44
48
  storage.set(ptzMoveableTipId, true);
45
49
  };
46
50
  if (showTipModal && playState === PlayState.PLAYING) {
47
- return /*#__PURE__*/React.createElement(CoverView, null, /*#__PURE__*/React.createElement(View, {
51
+ return /*#__PURE__*/React.createElement(OverlayView, {
52
+ style: overlayStyle
53
+ }, /*#__PURE__*/React.createElement(View, {
48
54
  className: clsx(`${multiPrefix}-tile-tip-content`, `${multiPrefix}-ptz-tip`),
49
55
  style: {
50
56
  left: positionInfo.content
@@ -1,6 +1,7 @@
1
- import { Text, View } from '@ray-js/ray';
1
+ import { View } from '@ray-js/ray';
2
2
  import clsx from 'clsx';
3
3
  import React, { useMemo } from 'react';
4
+ import { PlayerText as Text } from '../../renderer/text';
4
5
  import { useStore } from '../../ctx/store';
5
6
  import { MultiCameraLayoutStyle, MultiCameraScreenMode } from '../../interface';
6
7
  import { multiPrefix } from './constants';
@@ -1,9 +1,10 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { View, Text } from '@ray-js/ray';
2
+ import { View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import React from 'react';
5
5
  import { useMemoizedFn } from 'ahooks';
6
6
  import Color from 'color';
7
+ import { PlayerText as Text } from '../../renderer/text';
7
8
  import { useStore } from '../../ctx/store';
8
9
  import { multiPrefix } from './constants';
9
10
  import './index.less';
@@ -1,6 +1,7 @@
1
- import { View, Text } from '@ray-js/ray';
1
+ import { View } from '@ray-js/ray';
2
2
  import React, { useMemo } from 'react';
3
3
  import clsx from 'clsx';
4
+ import { PlayerText as Text } from '../../renderer/text';
4
5
  import { MultiCameraLayoutStyle } from '../../interface';
5
6
  import { multiPrefix } from './constants';
6
7
  import { useStore } from '../../ctx/store';
@@ -1,6 +1,8 @@
1
1
  import React, { useState } from 'react';
2
- import { View, CoverView, Text } from '@ray-js/ray';
2
+ import { View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
+ import { usePlayerOverlayHost, usePlayerOverlayFillStyle } from '../../renderer/overlay';
5
+ import { PlayerText as Text } from '../../renderer/text';
4
6
  import { useStore } from '../../ctx/store';
5
7
  import { tileTipId } from '../../ui/constant';
6
8
  import { PlayState } from '../../interface';
@@ -9,6 +11,8 @@ import { multiPrefix } from './constants';
9
11
  import { Storage } from '../../utils/storage';
10
12
  import './index.less';
11
13
  export const TileTip = props => {
14
+ const OverlayView = usePlayerOverlayHost();
15
+ const overlayStyle = usePlayerOverlayFillStyle();
12
16
  const {
13
17
  devId,
14
18
  deleteContent,
@@ -37,7 +41,9 @@ export const TileTip = props => {
37
41
  }
38
42
  };
39
43
  if (playState === PlayState.PLAYING) {
40
- return /*#__PURE__*/React.createElement(CoverView, null, /*#__PURE__*/React.createElement(View, {
44
+ return /*#__PURE__*/React.createElement(OverlayView, {
45
+ style: overlayStyle
46
+ }, /*#__PURE__*/React.createElement(View, {
41
47
  className: clsx(`${multiPrefix}-tile-tip-content`, `${multiPrefix}-${showTipModal}`)
42
48
  }), /*#__PURE__*/React.createElement(Text, {
43
49
  className: clsx(`${multiPrefix}-tile-tip-text`, `${multiPrefix}-${showTipModal}`)
@@ -1,6 +1,7 @@
1
- import { View, Text } from '@ray-js/ray';
1
+ import { View } from '@ray-js/ray';
2
2
  import React, { useContext } from 'react';
3
3
  import clsx from 'clsx';
4
+ import { PlayerText as Text } from '../../renderer/text';
4
5
  import { useStore } from '../../ctx/store';
5
6
  import { UIEventContext } from '../../ui/context';
6
7
  import { widgetLabs, widgetClick, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
@@ -1,5 +1,7 @@
1
- import { act, renderHook } from '@testing-library/react-hooks/dom';
1
+ import React from 'react';
2
+ import { act, renderHook as renderPlayerHook } from '@testing-library/react-hooks/dom';
2
3
  import { atom, getDefaultStore } from 'jotai';
4
+ import { PlayerRenderModeContext } from '../../renderer/context';
3
5
  import { IntercomMode } from '../../interface';
4
6
  import { Muted } from './muted';
5
7
  jest.mock('@ray-js/ray', () => ({
@@ -27,55 +29,67 @@ const createProps = function () {
27
29
  }
28
30
  };
29
31
  };
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();
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
+ });
81
95
  });
@@ -1,8 +1,9 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { View, Text } from '@ray-js/ray';
2
+ import { View } 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';
6
7
  import { UIEventContext } from '../../ui/context';
7
8
  import { usePtz } from '../../hooks';
8
9
  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';
4
3
  import clsx from 'clsx';
5
4
  import _find from 'lodash/find';
6
5
  import _get from 'lodash/get';
7
- import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
8
6
  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,6 +39,7 @@ const getPtzData = devId => {
39
39
  }];
40
40
  };
41
41
  export const PtzControl = props => {
42
+ const OverlayView = usePlayerOverlayHost();
42
43
  const {
43
44
  devId,
44
45
  addContent
@@ -134,7 +135,7 @@ export const PtzControl = props => {
134
135
  ptzTimeId.current = null;
135
136
  }
136
137
  };
137
- return /*#__PURE__*/React.createElement(CoverView, {
138
+ return /*#__PURE__*/React.createElement(OverlayView, {
138
139
  className: clsx('ipc-player-plugin-full-screen-ptz-control', {
139
140
  'ipc-player-plugin-full-screen-ptz-control-hide': !isPtzActive || shouldHide,
140
141
  'ipc-player-plugin-full-screen-ptz-disappear': screenType === 'vertical'
@@ -1,6 +1,9 @@
1
1
  import React, { useState } from 'react';
2
- import { View, Image, CoverView, Text, setStorage } from '@ray-js/ray';
2
+ import { View, Image, 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';
4
7
  import { useStore } from '../../ctx/store';
5
8
  import { ptzControlTipId, widgetLabs, widgetClick } from '../../ui/constant';
6
9
  import { PlayState } from '../../interface';
@@ -8,10 +11,12 @@ import './ptzControlTip.less';
8
11
  import { playerPtzControlTip } from '../../res';
9
12
  import Strings from '../../i18n';
10
13
  export const PtzControlTip = props => {
14
+ const OverlayView = usePlayerOverlayHost();
11
15
  const {
12
16
  devId,
13
17
  deleteContent
14
18
  } = props;
19
+ const isLynx = usePlayerRenderMode() === 'lynx';
15
20
  const [showTipModal, setShowTipModal] = useState(true);
16
21
  const {
17
22
  playState
@@ -31,12 +36,12 @@ export const PtzControlTip = props => {
31
36
  });
32
37
  };
33
38
  if (showTipModal && playState === PlayState.PLAYING) {
34
- return /*#__PURE__*/React.createElement(CoverView, {
39
+ return /*#__PURE__*/React.createElement(OverlayView, {
35
40
  className: clsx('playerControlTipContainer')
36
41
  }, /*#__PURE__*/React.createElement(Image, {
37
- mode: "widthFix",
42
+ mode: isLynx ? 'aspectFit' : 'widthFix',
38
43
  src: playerPtzControlTip,
39
- className: clsx('controlTipImage')
44
+ className: clsx('controlTipImage', isLynx && 'controlTipImageLynx')
40
45
  }), /*#__PURE__*/React.createElement(Text, {
41
46
  className: clsx('controlTipText')
42
47
  }, Strings.getLang('ipc_player_ptz_control_tip')), /*#__PURE__*/React.createElement(View, {
@@ -39,3 +39,9 @@
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,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
- import { View, Text } from '@ray-js/ray';
2
+ import { View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
+ import { PlayerText as Text } from '../../renderer/text';
4
5
  import { PlayState } from '../../interface';
5
6
  import { useStore } from '../../ctx/store';
6
7
  import { useDpSupport } from '../../hooks/useDpSupport';
@@ -1,80 +1,22 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
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';
3
+ import React, { useEffect, useRef, useContext } from 'react';
4
+ import { View, getSystemInfoSync } from '@ray-js/ray';
5
+ import { useMemoizedFn } from 'ahooks';
6
6
  import clsx from 'clsx';
7
- import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
7
+ import { getCaptureResultSummary } from '../../utils/captureResult';
8
+ import { PlayerText as Text } from '../../renderer/text';
8
9
  import Strings from '../../i18n';
9
10
  import { PlayState } from '../../interface';
10
- import { getCaptureResultSummary } from '../../utils/captureResult';
11
- import { CaptureResultToast } from '../captureResult/captureResult';
12
11
  import { UIEventContext } from '../../ui/context';
13
12
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
14
13
  import { useStore, getDefaultStore } from '../../ctx/store';
14
+ import RecordVideoTimer from './recordVideoTimer';
15
+ import CaptureToast from '../captureToast/captureToast';
15
16
  import './recordVideo.less';
16
- const CLOSE_TIME = 5000;
17
17
  const RESET_TIMER = 3000;
18
18
  const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
19
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
- }
78
20
  export function RecordVideo(props) {
79
21
  const {
80
22
  event
@@ -93,76 +35,52 @@ export function RecordVideo(props) {
93
35
  const {
94
36
  recording,
95
37
  brandColor,
96
- screenType,
97
38
  recordingDisabled,
98
39
  playState
99
40
  } = useStore({
100
41
  recording: recordingAtom,
101
42
  brandColor: props.brandColor,
102
- screenType: props.screenType,
103
43
  recordingDisabled: props.recordingDisabled,
104
44
  playState: props.playState
105
45
  });
106
- const [state, setState] = useSetState({
107
- showShot: false,
108
- shotUrl: '',
109
- shotCount: 0
110
- });
111
- const recordResultRequestIdRef = useRef(0);
112
- useEffect(() => {
113
- return () => {
114
- recordResultRequestIdRef.current += 1;
115
- };
46
+ const requestIdRef = useRef(0);
47
+ useEffect(() => () => {
48
+ requestIdRef.current += 1;
116
49
  }, []);
117
50
  const showRecordResult = async recordInfo => {
118
51
  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);
52
+ const requestId = ++requestIdRef.current;
121
53
  const summary = await getCaptureResultSummary(recordInfo, {
122
54
  multiLens: props.multiLens,
123
- lensIndices,
55
+ 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),
124
56
  devId
125
57
  });
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
- });
58
+ if (requestId !== requestIdRef.current || !summary) return;
59
+ showRecordToast(summary.thumbnailPath, summary.isMultiLens ? summary.count : 0);
133
60
  };
61
+ const removeRecordTimer = useMemoizedFn(() => deleteContent('absolute', RECORD_VIDEO_TIMER_ID));
62
+ useEffect(() => {
63
+ if (!recording) removeRecordTimer();
64
+ }, [recording, removeRecordTimer]);
134
65
 
135
66
  /**
136
67
  * 针对 playState为非连接中状态时,如果处于录制中, 结束录制
137
68
  */
138
69
  useEffect(() => {
139
70
  (async () => {
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.
71
+ if (playState !== PlayState.PLAYING) {
72
+ if (recording) {
73
+ try {
74
+ const recordInfo = await setRecording(false);
75
+ await showRecordResult(recordInfo);
76
+ } catch {
77
+ // setRecording reports native failures through its toast.
78
+ }
146
79
  }
147
80
  }
148
81
  })();
149
82
  }, [playState, recording]);
150
83
 
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
-
166
84
  /** 设置3秒后还原禁止结束录像状态 */
167
85
  const recordDisabledTimer = useRef();
168
86
  const timeToResetRecordDisabled = () => {
@@ -172,56 +90,23 @@ export function RecordVideo(props) {
172
90
  setRecordingDisabled(false);
173
91
  }, RESET_TIMER);
174
92
  };
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 = () => {
93
+ const showRecordToast = (imageUrl, count) => {
202
94
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
203
95
  addContent('absolute', {
204
96
  id: RECORD_VIDEO_SUCCESS_TOAST_ID,
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
- });
97
+ absoluteNoCoverView: true,
98
+ content: CaptureToast,
99
+ initProps: {
100
+ kind: 'record',
101
+ count,
102
+ imageUrl,
103
+ captureId: Date.now(),
104
+ screenType: props.screenType,
105
+ brandColor: props.brandColor,
106
+ devId,
107
+ deleteContent
222
108
  }
223
109
  });
224
- timeToCloseRecordToast();
225
110
  };
226
111
  const showRecordTimer = () => {
227
112
  deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
@@ -229,22 +114,19 @@ export function RecordVideo(props) {
229
114
  id: RECORD_VIDEO_TIMER_ID,
230
115
  absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
231
116
  content: () => /*#__PURE__*/React.createElement(View, {
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
- })
117
+ className: "ipc-player-plugin-record-video-toast ipc-player-plugin-record-video-toast-show"
236
118
  }, /*#__PURE__*/React.createElement(View, {
237
119
  className: "ipc-player-plugin-record-video-toast-point",
238
120
  style: {
239
121
  backgroundColor: brandColor
240
122
  }
241
- }), /*#__PURE__*/React.createElement(TimeRecord, null))
123
+ }), /*#__PURE__*/React.createElement(RecordVideoTimer, null))
242
124
  });
243
125
  };
244
126
  const handRecordVideo = async () => {
245
- var _props$event;
127
+ var _props$event, _props$event2;
246
128
  const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
247
- ev.emit(widgetClick, {
129
+ ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
248
130
  widgetId: widgetLabs.RECORD_VIDEO
249
131
  });
250
132
  event.emit(pauseTimeToHideAllComponent);
@@ -254,14 +136,7 @@ export function RecordVideo(props) {
254
136
  if (recordingDisabled) {
255
137
  return false;
256
138
  }
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
- }
139
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
265
140
  // 发送忽略进入后台停止预览的标记
266
141
  const {
267
142
  platform
@@ -277,20 +152,23 @@ export function RecordVideo(props) {
277
152
  }
278
153
  if (target) {
279
154
  setRecordingDisabled(true);
155
+ showRecordTimer();
280
156
  /** 录制开始后3秒后才可结束 */
281
157
  timeToResetRecordDisabled();
282
158
  } else {
283
159
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
160
+ removeRecordTimer();
284
161
  await showRecordResult(recordInfo);
285
162
  }
286
163
  } catch (err) {
287
164
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
288
165
  console.log('录制失败', err);
289
- const errObj = err.innerError || err || {};
166
+ const errObj = (err === null || err === void 0 ? void 0 : err.innerError) || err || {};
290
167
  const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_record_tip');
291
168
  toast({
292
169
  title: errMsg
293
170
  });
171
+ removeRecordTimer();
294
172
  }
295
173
  return true;
296
174
  };