@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.
- package/README.md +6 -0
- package/lib/ctx/ctx.js +12 -17
- package/lib/ctx/ctx.test.js +54 -19
- package/lib/ctx/intercom.test.d.ts +1 -0
- package/lib/ctx/intercom.test.js +85 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -1
- package/lib/renderer/capabilities.d.ts +8 -0
- package/lib/renderer/capabilities.js +19 -0
- package/lib/renderer/context.d.ts +5 -0
- package/lib/renderer/context.js +6 -0
- package/lib/renderer/directionControl.d.ts +6 -0
- package/lib/renderer/directionControl.js +3 -0
- package/lib/renderer/font-manifest.json +9 -0
- package/lib/renderer/font.less +5 -0
- package/lib/renderer/glyphs.d.ts +1 -0
- package/lib/renderer/glyphs.js +256 -0
- package/lib/renderer/index.module.less +48 -0
- package/lib/renderer/overlay.d.ts +6 -0
- package/lib/renderer/overlay.js +18 -0
- package/lib/renderer/ptzZoom.d.ts +6 -0
- package/lib/renderer/ptzZoom.js +3 -0
- package/lib/renderer/text.d.ts +4 -0
- package/lib/renderer/text.js +32 -0
- package/lib/renderer/text.module.less +4 -0
- package/lib/renderer/viewport.d.ts +7 -0
- package/lib/renderer/viewport.js +24 -0
- package/lib/res/lynx-signal/index.d.ts +1 -0
- package/lib/res/lynx-signal/index.js +22 -0
- package/lib/res/lynx-signal/signalFour0.png +0 -0
- package/lib/res/lynx-signal/signalFour1.png +0 -0
- package/lib/res/lynx-signal/signalFour2.png +0 -0
- package/lib/res/lynx-signal/signalFour3.png +0 -0
- package/lib/res/lynx-signal/signalFour4.png +0 -0
- package/lib/res/lynx-signal/signalThree0.png +0 -0
- package/lib/res/lynx-signal/signalThree1.png +0 -0
- package/lib/res/lynx-signal/signalThree2.png +0 -0
- package/lib/res/lynx-signal/signalThree3.png +0 -0
- package/lib/res/player-charging.png +0 -0
- package/lib/res/player-more-arrow.png +0 -0
- package/lib/res/player-solar.png +0 -0
- package/lib/ui/bottomLeftContent.js +121 -53
- package/lib/ui/bottomRightContent.js +10 -5
- package/lib/ui/scrollHintArrow.d.ts +23 -0
- package/lib/ui/scrollHintArrow.js +83 -0
- package/lib/ui/topLeftContent.js +4 -2
- package/lib/ui/topRightContent.js +4 -2
- package/lib/ui/ui.d.ts +5 -0
- package/lib/ui/ui.js +46 -23
- package/lib/widgets/battery/battery.js +7 -5
- package/lib/widgets/battery/batteryFull.js +7 -5
- package/lib/widgets/battery/statusIcon.d.ts +6 -0
- package/lib/widgets/battery/statusIcon.js +36 -0
- package/lib/widgets/battery/statusIcon.less +24 -0
- package/lib/widgets/captureResult/captureResult.js +2 -1
- package/lib/widgets/captureToast/captureToast.d.ts +10 -0
- package/lib/widgets/captureToast/captureToast.js +58 -0
- package/lib/widgets/floodlight/floodlight.js +2 -1
- package/lib/widgets/flowLowTip/flowLowTip.js +2 -1
- package/lib/widgets/fullScreen/fullScreen.js +2 -1
- package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
- package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
- package/lib/widgets/fullScreen/verticalScreen.js +2 -1
- package/lib/widgets/moveInteractiveControl/controlButton.js +2 -1
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +16 -5
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +24 -4
- package/lib/widgets/multiCamera/landscapeTip.js +8 -2
- package/lib/widgets/multiCamera/moveablePtzControl.js +5 -3
- package/lib/widgets/multiCamera/multiPtz.js +2 -1
- package/lib/widgets/multiCamera/ptzMoveableTip.js +8 -2
- package/lib/widgets/multiCamera/switchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileMultiPtz.js +2 -1
- package/lib/widgets/multiCamera/tileSwitchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileTip.js +8 -2
- package/lib/widgets/muted/muted.js +2 -1
- package/lib/widgets/muted/muted.test.js +66 -52
- package/lib/widgets/ptz/ptz.js +2 -1
- package/lib/widgets/ptz/ptzControl.js +4 -3
- package/lib/widgets/ptzControlTip/ptzControlTip.js +9 -4
- package/lib/widgets/ptzControlTip/ptzControlTip.less +6 -0
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +2 -1
- package/lib/widgets/recordVideo/recordVideo.js +47 -169
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +4 -2
- package/lib/widgets/recordVideo/recordVideo.test.js +169 -2
- package/lib/widgets/recordVideo/recordVideoTimer.d.ts +3 -0
- package/lib/widgets/recordVideo/recordVideoTimer.js +26 -0
- package/lib/widgets/resolution/fullResolutionControl.js +29 -19
- package/lib/widgets/resolution/resolution.js +3 -2
- package/lib/widgets/screenshot/screenshot.js +48 -122
- package/lib/widgets/screenshot/screenshot.permissions.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.permissions.test.js +137 -0
- package/lib/widgets/screenshot/screenshot.test.js +108 -113
- package/lib/widgets/signal4G/signal4G.js +4 -1
- package/lib/widgets/siren/siren.js +2 -1
- package/lib/widgets/tempHumidity/tempHumidity.js +2 -1
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +2 -1
- package/lib/widgets/trialBadge/index.js +8 -3
- package/lib/widgets/trialBadge/index.less +24 -0
- package/lib/widgets/tryExperience/tryExperience.js +2 -1
- package/lib/widgets/videoBitKBP/videoBitKBP.js +2 -1
- package/lib/widgets/voiceIntercom/voiceIntercom.js +57 -81
- package/lib/widgets/voiceIntercom/voiceIntercom.less +35 -0
- package/lib/widgets/voiceIntercom/voiceIntercom.test.d.ts +1 -0
- package/lib/widgets/voiceIntercom/voiceIntercom.test.js +135 -0
- package/lib/widgets/zoomTurntable/lynxDockLayout.d.ts +6 -0
- package/lib/widgets/zoomTurntable/lynxDockLayout.js +30 -0
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +5 -7
- package/lib/widgets/zoomTurntable/turntable/index.js +3 -1
- package/lib/widgets/zoomTurntable/turntable/lynx.d.ts +5 -0
- package/lib/widgets/zoomTurntable/turntable/lynx.js +273 -0
- package/lib/widgets/zoomTurntable/turntable/lynx.less +9 -0
- package/lib/widgets/zoomTurntable/turntable/lynxModel.d.ts +37 -0
- package/lib/widgets/zoomTurntable/turntable/lynxModel.js +122 -0
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.d.ts +3 -0
- package/lib/widgets/zoomTurntable/turntable/lynxPaint.js +36 -0
- package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +5 -3
- package/lib/widgets/zoomTurntable/zoomTurntableDock.js +4 -4
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +32 -19
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +17 -3
- package/package.json +15 -7
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import { View
|
|
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(
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
});
|
package/lib/widgets/ptz/ptz.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { View
|
|
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(
|
|
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,
|
|
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(
|
|
39
|
+
return /*#__PURE__*/React.createElement(OverlayView, {
|
|
35
40
|
className: clsx('playerControlTipContainer')
|
|
36
41
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
37
|
-
mode:
|
|
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
|
|
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, {
|
|
4
|
-
import { View,
|
|
5
|
-
import {
|
|
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 {
|
|
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
|
|
107
|
-
|
|
108
|
-
|
|
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 = ++
|
|
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 !==
|
|
127
|
-
|
|
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
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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:
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
};
|