@ray-js/ipc-player-integration 0.0.67-beta.1 → 0.0.68-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.composition.js +3 -13
- package/lib/ctx/ctx.js +35 -48
- package/lib/ctx/multiCameraCtx.d.ts +0 -2
- package/lib/ctx/multiCameraCtx.js +1 -17
- package/lib/i18n/index.d.ts +0 -12
- package/lib/i18n/strings.d.ts +0 -6
- package/lib/i18n/strings.js +0 -6
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -1
- package/lib/interface.d.ts +3 -18
- 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 +4 -0
- package/lib/renderer/overlay.js +6 -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 +122 -56
- 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 +93 -100
- package/lib/utils/navigation.d.ts +1 -2
- package/lib/utils/navigation.js +3 -13
- 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/captureToast/captureToast.d.ts +9 -0
- package/lib/widgets/captureToast/captureToast.js +73 -0
- package/lib/widgets/floodlight/floodlight.js +2 -1
- package/lib/widgets/flowLowTip/flowLowTip.js +2 -1
- package/lib/widgets/fullScreen/fullScreen.js +18 -4
- 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/index.d.ts +0 -1
- package/lib/widgets/index.js +1 -2
- 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/index.less +0 -1
- package/lib/widgets/multiCamera/landscapeTip.js +5 -2
- package/lib/widgets/multiCamera/moveablePtzControl.js +9 -7
- package/lib/widgets/multiCamera/multiPtz.js +3 -2
- package/lib/widgets/multiCamera/ptzMoveableTip.js +5 -2
- package/lib/widgets/multiCamera/switchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileMultiPtz.js +3 -2
- package/lib/widgets/multiCamera/tileSwitchLayout.js +2 -1
- package/lib/widgets/multiCamera/tileTip.js +5 -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 +32 -178
- package/lib/widgets/recordVideo/recordVideo.less +74 -17
- package/lib/widgets/recordVideo/recordVideo.test.js +169 -3
- 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 +35 -125
- package/lib/widgets/screenshot/screenshot.less +40 -1
- 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.d.ts +1 -2
- package/lib/widgets/trialBadge/index.js +17 -20
- package/lib/widgets/trialBadge/index.less +24 -0
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +2 -3
- package/lib/widgets/trialBadge/useTrialBadge.js +3 -21
- package/lib/widgets/tryExperience/tryExperience.js +2 -1
- package/lib/widgets/videoBitKBP/videoBitKBP.js +2 -1
- package/lib/widgets/voiceIntercom/voiceIntercom.js +50 -24
- package/lib/widgets/voiceIntercom/voiceIntercom.less +16 -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 +24 -3
- package/package.json +15 -7
- package/lib/ctx/ctx.album.test.d.ts +0 -1
- package/lib/ctx/ctx.album.test.js +0 -197
- package/lib/ctx/multiCameraCtx.test.d.ts +0 -1
- package/lib/ctx/multiCameraCtx.test.js +0 -65
- package/lib/ui/absoluteContent.d.ts +0 -2
- package/lib/ui/absoluteContent.js +0 -3
- package/lib/utils/captureResult.d.ts +0 -12
- package/lib/utils/captureResult.js +0 -70
- package/lib/utils/captureResult.test.d.ts +0 -1
- package/lib/utils/captureResult.test.js +0 -223
- package/lib/utils/fullLinkTracking.d.ts +0 -5
- package/lib/utils/fullLinkTracking.js +0 -71
- package/lib/widgets/captureResult/captureResult.d.ts +0 -16
- package/lib/widgets/captureResult/captureResult.js +0 -85
- package/lib/widgets/captureResult/captureResult.less +0 -144
- package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
- package/lib/widgets/captureResult/captureResult.test.js +0 -84
- package/lib/widgets/captureResult/index.d.ts +0 -2
- package/lib/widgets/captureResult/index.js +0 -2
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +0 -1
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +0 -106
|
@@ -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,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
5
|
-
import { useSetState, useUpdateEffect } from 'ahooks';
|
|
1
|
+
import React, { useEffect, useRef, useContext } from 'react';
|
|
2
|
+
import { View, getSystemInfoSync } from '@ray-js/ray';
|
|
3
|
+
import { useMemoizedFn } from 'ahooks';
|
|
6
4
|
import clsx from 'clsx';
|
|
7
|
-
import {
|
|
5
|
+
import { PlayerText as Text } from '../../renderer/text';
|
|
8
6
|
import Strings from '../../i18n';
|
|
9
7
|
import { PlayState } from '../../interface';
|
|
10
|
-
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
11
|
-
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
12
8
|
import { UIEventContext } from '../../ui/context';
|
|
13
9
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
14
10
|
import { useStore, getDefaultStore } from '../../ctx/store';
|
|
11
|
+
import RecordVideoTimer from './recordVideoTimer';
|
|
12
|
+
import CaptureToast from '../captureToast/captureToast';
|
|
15
13
|
import './recordVideo.less';
|
|
16
|
-
const CLOSE_TIME = 5000;
|
|
17
14
|
const RESET_TIMER = 3000;
|
|
18
15
|
const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
|
|
19
16
|
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
17
|
export function RecordVideo(props) {
|
|
79
18
|
const {
|
|
80
19
|
event
|
|
@@ -93,76 +32,32 @@ export function RecordVideo(props) {
|
|
|
93
32
|
const {
|
|
94
33
|
recording,
|
|
95
34
|
brandColor,
|
|
96
|
-
screenType,
|
|
97
35
|
recordingDisabled,
|
|
98
36
|
playState
|
|
99
37
|
} = useStore({
|
|
100
38
|
recording: recordingAtom,
|
|
101
39
|
brandColor: props.brandColor,
|
|
102
|
-
screenType: props.screenType,
|
|
103
40
|
recordingDisabled: props.recordingDisabled,
|
|
104
41
|
playState: props.playState
|
|
105
42
|
});
|
|
106
|
-
const
|
|
107
|
-
showShot: false,
|
|
108
|
-
shotUrl: '',
|
|
109
|
-
shotCount: 0
|
|
110
|
-
});
|
|
111
|
-
const recordResultRequestIdRef = useRef(0);
|
|
43
|
+
const removeRecordTimer = useMemoizedFn(() => deleteContent('absolute', RECORD_VIDEO_TIMER_ID));
|
|
112
44
|
useEffect(() => {
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
};
|
|
45
|
+
if (!recording) removeRecordTimer();
|
|
46
|
+
}, [recording, removeRecordTimer]);
|
|
134
47
|
|
|
135
48
|
/**
|
|
136
49
|
* 针对 playState为非连接中状态时,如果处于录制中, 结束录制
|
|
137
50
|
*/
|
|
138
51
|
useEffect(() => {
|
|
139
52
|
(async () => {
|
|
140
|
-
if (playState !== PlayState.PLAYING
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await showRecordResult(recordInfo);
|
|
144
|
-
} catch {
|
|
145
|
-
// setRecording reports the native failure through the configured toast.
|
|
53
|
+
if (playState !== PlayState.PLAYING) {
|
|
54
|
+
if (recording) {
|
|
55
|
+
await setRecording(false);
|
|
146
56
|
}
|
|
147
57
|
}
|
|
148
58
|
})();
|
|
149
59
|
}, [playState, recording]);
|
|
150
60
|
|
|
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
61
|
/** 设置3秒后还原禁止结束录像状态 */
|
|
167
62
|
const recordDisabledTimer = useRef();
|
|
168
63
|
const timeToResetRecordDisabled = () => {
|
|
@@ -172,56 +67,22 @@ export function RecordVideo(props) {
|
|
|
172
67
|
setRecordingDisabled(false);
|
|
173
68
|
}, RESET_TIMER);
|
|
174
69
|
};
|
|
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 = () => {
|
|
70
|
+
const showRecordToast = imageUrl => {
|
|
202
71
|
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
203
72
|
addContent('absolute', {
|
|
204
73
|
id: RECORD_VIDEO_SUCCESS_TOAST_ID,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return /*#__PURE__*/React.createElement(CaptureResultToast, {
|
|
216
|
-
brandColor: brandColor,
|
|
217
|
-
count: state.shotCount,
|
|
218
|
-
kind: "record",
|
|
219
|
-
onCheck: handCheck,
|
|
220
|
-
thumbnailPath: state.shotUrl
|
|
221
|
-
});
|
|
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
|
|
222
84
|
}
|
|
223
85
|
});
|
|
224
|
-
timeToCloseRecordToast();
|
|
225
86
|
};
|
|
226
87
|
const showRecordTimer = () => {
|
|
227
88
|
deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
|
|
@@ -229,22 +90,19 @@ export function RecordVideo(props) {
|
|
|
229
90
|
id: RECORD_VIDEO_TIMER_ID,
|
|
230
91
|
absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
|
|
231
92
|
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
|
-
})
|
|
93
|
+
className: "ipc-player-plugin-record-video-toast ipc-player-plugin-record-video-toast-show"
|
|
236
94
|
}, /*#__PURE__*/React.createElement(View, {
|
|
237
95
|
className: "ipc-player-plugin-record-video-toast-point",
|
|
238
96
|
style: {
|
|
239
97
|
backgroundColor: brandColor
|
|
240
98
|
}
|
|
241
|
-
}), /*#__PURE__*/React.createElement(
|
|
99
|
+
}), /*#__PURE__*/React.createElement(RecordVideoTimer, null))
|
|
242
100
|
});
|
|
243
101
|
};
|
|
244
102
|
const handRecordVideo = async () => {
|
|
245
|
-
var _props$event;
|
|
103
|
+
var _props$event, _props$event2;
|
|
246
104
|
const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
|
|
247
|
-
|
|
105
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
248
106
|
widgetId: widgetLabs.RECORD_VIDEO
|
|
249
107
|
});
|
|
250
108
|
event.emit(pauseTimeToHideAllComponent);
|
|
@@ -254,14 +112,7 @@ export function RecordVideo(props) {
|
|
|
254
112
|
if (recordingDisabled) {
|
|
255
113
|
return false;
|
|
256
114
|
}
|
|
257
|
-
|
|
258
|
-
if (state.showShot) {
|
|
259
|
-
setState({
|
|
260
|
-
showShot: false
|
|
261
|
-
});
|
|
262
|
-
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
263
|
-
clearTimeout(timer.current);
|
|
264
|
-
}
|
|
115
|
+
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
265
116
|
// 发送忽略进入后台停止预览的标记
|
|
266
117
|
const {
|
|
267
118
|
platform
|
|
@@ -277,11 +128,13 @@ export function RecordVideo(props) {
|
|
|
277
128
|
}
|
|
278
129
|
if (target) {
|
|
279
130
|
setRecordingDisabled(true);
|
|
131
|
+
showRecordTimer();
|
|
280
132
|
/** 录制开始后3秒后才可结束 */
|
|
281
133
|
timeToResetRecordDisabled();
|
|
282
134
|
} else {
|
|
283
135
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
|
|
284
|
-
|
|
136
|
+
removeRecordTimer();
|
|
137
|
+
showRecordToast(recordInfo.tempImagePath);
|
|
285
138
|
}
|
|
286
139
|
} catch (err) {
|
|
287
140
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
|
|
@@ -291,6 +144,7 @@ export function RecordVideo(props) {
|
|
|
291
144
|
toast({
|
|
292
145
|
title: errMsg
|
|
293
146
|
});
|
|
147
|
+
removeRecordTimer();
|
|
294
148
|
}
|
|
295
149
|
return true;
|
|
296
150
|
};
|
|
@@ -1,59 +1,116 @@
|
|
|
1
1
|
.ipc-player-plugin-record-video-icon {
|
|
2
|
-
color: var(--iconColor);
|
|
3
2
|
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
3
|
+
color: var(--iconColor);
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
.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;
|
|
11
10
|
transform: translateX(-50%);
|
|
12
11
|
}
|
|
13
12
|
|
|
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%);
|
|
25
26
|
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
27
|
padding: calc(12px * var(--ipc-player-size-scale, 1));
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
align-items: center;
|
|
29
|
+
background-color: var(--shot-card-bg-color);
|
|
30
30
|
border-radius: calc(8px * var(--ipc-player-size-scale, 1));
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
// background-color: #fff;
|
|
32
|
+
background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)), #000000;
|
|
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
|
-
|
|
39
38
|
.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));;
|
|
40
43
|
display: flex;
|
|
41
44
|
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
|
-
|
|
47
45
|
.ipc-player-plugin-record-video-toast-time-warp {
|
|
48
46
|
text-align: center;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
48
|
.ipc-player-plugin-record-video-toast-time-delimiter {
|
|
52
|
-
margin: 0 calc(2px * var(--ipc-player-size-scale, 1))
|
|
49
|
+
margin: 0 calc(2px * var(--ipc-player-size-scale, 1));;
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
|
|
54
|
+
/** 录制成功弹窗 */
|
|
57
55
|
.ipc-player-plugin-record-success-toast-wrap {
|
|
58
56
|
position: absolute;
|
|
59
57
|
}
|
|
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
|
+
}
|