@ray-js/ipc-player-integration 0.0.70-beta.0 → 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,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
3
|
import "core-js/modules/esnext.iterator.filter.js";
|
|
3
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
@@ -9,6 +10,7 @@ import { PlayState } from '../../interface';
|
|
|
9
10
|
import { RecordVideo } from './recordVideo';
|
|
10
11
|
jest.mock('@ray-js/ray', () => ({
|
|
11
12
|
View: 'div',
|
|
13
|
+
CoverView: 'div',
|
|
12
14
|
Text: 'span',
|
|
13
15
|
Image: 'img',
|
|
14
16
|
getSystemInfoSync: () => ({
|
|
@@ -72,9 +74,9 @@ describe('RecordVideo', () => {
|
|
|
72
74
|
setRecordingDisabled: value => store.set(recordingDisabled, value),
|
|
73
75
|
addContent: (_type, content) => setContents(items => [...items, content]),
|
|
74
76
|
deleteContent: (_type, id) => setContents(items => items.filter(item => item.id !== id))
|
|
75
|
-
}), contents.map(item => /*#__PURE__*/React.createElement(item.content, {
|
|
77
|
+
}), contents.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, item.initProps), {}, {
|
|
76
78
|
key: item.id
|
|
77
|
-
})));
|
|
79
|
+
}))));
|
|
78
80
|
}
|
|
79
81
|
const clickRecord = async () => {
|
|
80
82
|
await act(async () => {
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import { act, Simulate } from 'react-dom/test-utils';
|
|
8
|
+
import { renderHook } from '@testing-library/react-hooks/dom';
|
|
9
|
+
import { atom, getDefaultStore } from 'jotai';
|
|
3
10
|
import { RecordVideo } from './recordVideo';
|
|
4
11
|
import { PlayState } from '../../interface';
|
|
12
|
+
import { PlayerRenderModeContext } from '../../renderer/context';
|
|
5
13
|
jest.mock('@ray-js/ray', () => ({
|
|
6
14
|
View: 'div',
|
|
15
|
+
CoverView: 'div',
|
|
7
16
|
Text: 'span',
|
|
8
17
|
Image: 'img',
|
|
9
18
|
getSystemInfoSync: () => ({
|
|
@@ -56,4 +65,162 @@ it('keeps the record control idle when starting is declined', async () => {
|
|
|
56
65
|
expect(setRecordingDisabled).not.toHaveBeenCalled();
|
|
57
66
|
expect(toast).not.toHaveBeenCalled();
|
|
58
67
|
unmount();
|
|
68
|
+
});
|
|
69
|
+
describe('successful recording timer', () => {
|
|
70
|
+
let container;
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
jest.useFakeTimers();
|
|
73
|
+
jest.setSystemTime(10000);
|
|
74
|
+
container = document.createElement('div');
|
|
75
|
+
document.body.appendChild(container);
|
|
76
|
+
});
|
|
77
|
+
afterEach(() => {
|
|
78
|
+
act(() => {
|
|
79
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
80
|
+
});
|
|
81
|
+
container.remove();
|
|
82
|
+
jest.clearAllTimers();
|
|
83
|
+
jest.restoreAllMocks();
|
|
84
|
+
jest.useRealTimers();
|
|
85
|
+
});
|
|
86
|
+
function mountRecorder(mode) {
|
|
87
|
+
const store = getDefaultStore();
|
|
88
|
+
const recording = atom(false);
|
|
89
|
+
const recordingDisabled = atom(false);
|
|
90
|
+
const brandColor = atom('#000000');
|
|
91
|
+
let updateContents;
|
|
92
|
+
let recreateControl;
|
|
93
|
+
const props = {
|
|
94
|
+
recording,
|
|
95
|
+
recordingDisabled,
|
|
96
|
+
brandColor,
|
|
97
|
+
screenType: atom('vertical'),
|
|
98
|
+
playState: atom(PlayState.PLAYING),
|
|
99
|
+
setRecording: jest.fn(async value => {
|
|
100
|
+
store.set(recording, value);
|
|
101
|
+
return value ? true : {
|
|
102
|
+
tempImagePath: 'record.jpg'
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
105
|
+
setRecordingDisabled: value => store.set(recordingDisabled, value),
|
|
106
|
+
addContent: (_area, item) => updateContents(items => [...items, item]),
|
|
107
|
+
deleteContent: (_area, id) => updateContents(items => items.filter(item => item.id !== id)),
|
|
108
|
+
toast: jest.fn(),
|
|
109
|
+
devId: 'test-device',
|
|
110
|
+
event: {
|
|
111
|
+
emit: jest.fn()
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const Harness = () => {
|
|
115
|
+
const [contents, setContents] = React.useState([]);
|
|
116
|
+
const [generation, setGeneration] = React.useState(0);
|
|
117
|
+
recreateControl = () => setGeneration(value => value + 1);
|
|
118
|
+
updateContents = setContents;
|
|
119
|
+
return /*#__PURE__*/React.createElement(PlayerRenderModeContext.Provider, {
|
|
120
|
+
value: mode
|
|
121
|
+
}, /*#__PURE__*/React.createElement(RecordVideo, _extends({
|
|
122
|
+
key: generation
|
|
123
|
+
}, props)), contents.map(item => /*#__PURE__*/React.createElement(item.content, _extends({
|
|
124
|
+
key: item.id
|
|
125
|
+
}, item.initProps))));
|
|
126
|
+
};
|
|
127
|
+
act(() => {
|
|
128
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, null), container);
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
props,
|
|
132
|
+
store,
|
|
133
|
+
brandColor,
|
|
134
|
+
remountControl: () => {
|
|
135
|
+
act(() => {
|
|
136
|
+
recreateControl();
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
click: async () => {
|
|
140
|
+
await act(async () => {
|
|
141
|
+
Simulate.click(container.firstElementChild);
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
timer: () => container.querySelector('.ipc-player-plugin-record-video-toast-time')
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
it.each(['webview', 'lynx'])('ticks and cleans up in %s', async mode => {
|
|
148
|
+
const clear = jest.spyOn(global, 'clearInterval');
|
|
149
|
+
const start = jest.spyOn(global, 'setInterval');
|
|
150
|
+
const recorder = mountRecorder(mode);
|
|
151
|
+
await recorder.click();
|
|
152
|
+
expect(recorder.props.setRecording).toHaveBeenCalledWith(true);
|
|
153
|
+
expect(recorder.timer().textContent).toBe('00:00');
|
|
154
|
+
expect(start).toHaveBeenCalledTimes(1);
|
|
155
|
+
const interval = start.mock.results[0].value;
|
|
156
|
+
act(() => {
|
|
157
|
+
jest.advanceTimersByTime(1000);
|
|
158
|
+
});
|
|
159
|
+
expect(recorder.timer().textContent).toBe('00:01');
|
|
160
|
+
act(() => {
|
|
161
|
+
recorder.store.set(recorder.brandColor, '#ffffff');
|
|
162
|
+
});
|
|
163
|
+
expect(recorder.timer().textContent).toBe('00:01');
|
|
164
|
+
act(() => {
|
|
165
|
+
jest.advanceTimersByTime(59000);
|
|
166
|
+
});
|
|
167
|
+
expect(recorder.timer().textContent).toBe('01:00');
|
|
168
|
+
expect(start).toHaveBeenCalledTimes(1);
|
|
169
|
+
await recorder.click();
|
|
170
|
+
expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
|
|
171
|
+
expect(recorder.timer()).toBeNull();
|
|
172
|
+
expect(clear).toHaveBeenCalledWith(interval);
|
|
173
|
+
await recorder.click();
|
|
174
|
+
expect(recorder.timer().textContent).toBe('00:00');
|
|
175
|
+
const nextInterval = start.mock.results[1].value;
|
|
176
|
+
act(() => {
|
|
177
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
178
|
+
});
|
|
179
|
+
expect(clear).toHaveBeenCalledWith(nextInterval);
|
|
180
|
+
});
|
|
181
|
+
it('uses elapsed wall time after a delayed tick', async () => {
|
|
182
|
+
const recorder = mountRecorder('lynx');
|
|
183
|
+
await recorder.click();
|
|
184
|
+
act(() => {
|
|
185
|
+
jest.setSystemTime(74000);
|
|
186
|
+
jest.advanceTimersByTime(1000);
|
|
187
|
+
});
|
|
188
|
+
expect(recorder.timer().textContent).toBe('01:05');
|
|
189
|
+
});
|
|
190
|
+
it.each(['webview', 'lynx'])('stops the persistent timer after orientation remounts the %s toolbar', async mode => {
|
|
191
|
+
const clear = jest.spyOn(global, 'clearInterval');
|
|
192
|
+
const start = jest.spyOn(global, 'setInterval');
|
|
193
|
+
const recorder = mountRecorder(mode);
|
|
194
|
+
await recorder.click();
|
|
195
|
+
const interval = start.mock.results[0].value;
|
|
196
|
+
act(() => {
|
|
197
|
+
jest.advanceTimersByTime(4000);
|
|
198
|
+
});
|
|
199
|
+
act(() => {
|
|
200
|
+
recorder.store.set(recorder.props.screenType, 'full');
|
|
201
|
+
});
|
|
202
|
+
recorder.remountControl();
|
|
203
|
+
expect(recorder.timer().textContent).toBe('00:04');
|
|
204
|
+
act(() => {
|
|
205
|
+
jest.advanceTimersByTime(1000);
|
|
206
|
+
});
|
|
207
|
+
act(() => {
|
|
208
|
+
recorder.store.set(recorder.props.screenType, 'vertical');
|
|
209
|
+
});
|
|
210
|
+
recorder.remountControl();
|
|
211
|
+
expect(recorder.timer().textContent).toBe('00:05');
|
|
212
|
+
await recorder.click();
|
|
213
|
+
expect(recorder.props.setRecording).toHaveBeenLastCalledWith(false);
|
|
214
|
+
expect(recorder.timer()).toBeNull();
|
|
215
|
+
expect(clear).toHaveBeenCalledWith(interval);
|
|
216
|
+
});
|
|
217
|
+
it('removes the timer when recording stops outside the remounted control', async () => {
|
|
218
|
+
const recorder = mountRecorder('lynx');
|
|
219
|
+
await recorder.click();
|
|
220
|
+
recorder.remountControl();
|
|
221
|
+
act(() => {
|
|
222
|
+
recorder.store.set(recorder.props.recording, false);
|
|
223
|
+
});
|
|
224
|
+
expect(recorder.timer()).toBeNull();
|
|
225
|
+
});
|
|
59
226
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from '@ray-js/ray';
|
|
3
|
+
|
|
4
|
+
// Keep the timer state in this component, without a separate custom-hook binding.
|
|
5
|
+
const RecordVideoTimer = () => {
|
|
6
|
+
const [elapsedSeconds, setElapsedSeconds] = React.useState(0);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
const startedAt = Date.now();
|
|
9
|
+
const interval = setInterval(() => {
|
|
10
|
+
setElapsedSeconds(Math.max(0, Math.floor((Date.now() - startedAt) / 1000)));
|
|
11
|
+
}, 1000);
|
|
12
|
+
return () => clearInterval(interval);
|
|
13
|
+
}, []);
|
|
14
|
+
const minutes = String(Math.floor(elapsedSeconds / 60)).padStart(2, '0');
|
|
15
|
+
const seconds = String(elapsedSeconds % 60).padStart(2, '0');
|
|
16
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
17
|
+
className: "ipc-player-plugin-record-video-toast-time"
|
|
18
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
19
|
+
className: "ipc-player-plugin-record-video-toast-time-warp"
|
|
20
|
+
}, minutes), /*#__PURE__*/React.createElement(View, {
|
|
21
|
+
className: "ipc-player-plugin-record-video-toast-time-delimiter"
|
|
22
|
+
}, ":"), /*#__PURE__*/React.createElement(View, {
|
|
23
|
+
className: "ipc-player-plugin-record-video-toast-time-warp"
|
|
24
|
+
}, seconds));
|
|
25
|
+
};
|
|
26
|
+
export default RecordVideoTimer;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
3
3
|
import React, { useState, useContext, useEffect } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { View, showToast } from '@ray-js/ray';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
+
import { PlayerText as Text } from '../../renderer/text';
|
|
6
7
|
import Strings from '../../i18n';
|
|
7
8
|
import { useMemoizedFn } from '../../hooks';
|
|
8
9
|
import { useStore } from '../../ctx/store';
|
|
@@ -33,6 +34,10 @@ export const FullResolutionControl = props => {
|
|
|
33
34
|
const onPlayerTap = useMemoizedFn(() => {
|
|
34
35
|
setHide(true);
|
|
35
36
|
});
|
|
37
|
+
const normalizeResolution = value => {
|
|
38
|
+
const normalized = String(value || '').toUpperCase();
|
|
39
|
+
return normalized === 'HD' ? 'HD' : 'SD';
|
|
40
|
+
};
|
|
36
41
|
useEffect(() => {
|
|
37
42
|
event.on('showFullResolutionControl', onShowFullResolutionControl);
|
|
38
43
|
event.on(playerTap, onPlayerTap);
|
|
@@ -42,13 +47,14 @@ export const FullResolutionControl = props => {
|
|
|
42
47
|
};
|
|
43
48
|
}, []);
|
|
44
49
|
const changeResolution = useMemoizedFn(value => {
|
|
45
|
-
|
|
50
|
+
const targetResolution = normalizeResolution(value);
|
|
51
|
+
if (targetResolution === normalizeResolution(resolution)) {
|
|
46
52
|
showToast({
|
|
47
53
|
icon: 'none',
|
|
48
54
|
title: Strings.getLang('ipc_player_current_resolution_is_equal')
|
|
49
55
|
});
|
|
50
56
|
} else {
|
|
51
|
-
setResolution(
|
|
57
|
+
setResolution(targetResolution).then(() => {
|
|
52
58
|
showToast({
|
|
53
59
|
icon: 'none',
|
|
54
60
|
title: Strings.getLang('ipc_player_change_resolution_success')
|
|
@@ -68,20 +74,24 @@ export const FullResolutionControl = props => {
|
|
|
68
74
|
className: clsx('ipc-player-plugin-full-resolution-control', 'ipc-plugin-absolute-move-in-right', {
|
|
69
75
|
'ipc-plugin-absolute-move-in-right-hide': hide
|
|
70
76
|
})
|
|
71
|
-
}, resolutionList.map(item =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
}, resolutionList.map(item => {
|
|
78
|
+
const normalizedItem = normalizeResolution(item);
|
|
79
|
+
const selected = normalizedItem === normalizeResolution(resolution);
|
|
80
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
81
|
+
key: item,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
event.emit(widgetClick, {
|
|
84
|
+
widgetId: widgetLabs.FULL_RESOLUTION_CONTROL,
|
|
85
|
+
extra: {
|
|
86
|
+
resolution: normalizedItem
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
changeResolution(normalizedItem);
|
|
90
|
+
},
|
|
91
|
+
className: clsx('ipc-player-plugin-full-resolution-control-text'),
|
|
92
|
+
style: selected ? {
|
|
93
|
+
color: brandColor
|
|
94
|
+
} : undefined
|
|
95
|
+
}, Strings.getLang(`ipc_player_resolution_${normalizedItem}`));
|
|
96
|
+
}));
|
|
87
97
|
};
|
|
@@ -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, { useContext } from 'react';
|
|
5
5
|
import { useMemoizedFn } from 'ahooks';
|
|
6
|
+
import { PlayerText as Text } from '../../renderer/text';
|
|
6
7
|
import Strings from '../../i18n';
|
|
7
8
|
import { FullResolutionControl } from './fullResolutionControl';
|
|
8
9
|
import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick } from '../../ui/constant';
|
|
@@ -52,7 +53,7 @@ export const Resolution = props => {
|
|
|
52
53
|
}
|
|
53
54
|
if (verticalResolutionCustomClick) return false;
|
|
54
55
|
if (screenType === 'vertical') {
|
|
55
|
-
setResolution(resolution === 'HD' ? 'SD' : 'HD');
|
|
56
|
+
setResolution(String(resolution).toUpperCase() === 'HD' ? 'SD' : 'HD');
|
|
56
57
|
}
|
|
57
58
|
event.emit(pauseTimeToHideAllComponent);
|
|
58
59
|
return true;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
-
import React, { useContext,
|
|
4
|
-
import { View,
|
|
5
|
-
import {
|
|
3
|
+
import React, { useContext, useRef, useEffect } 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
|
-
import { useStore } from '../../ctx/store';
|
|
10
10
|
import { UIEventContext } from '../../ui/context';
|
|
11
11
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
12
|
-
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
13
12
|
import { ensureAlbumPermission } from '../../utils/authorize/album';
|
|
14
|
-
import
|
|
13
|
+
import CaptureToast from '../captureToast/captureToast';
|
|
15
14
|
import './screenshot.less';
|
|
16
|
-
const CLOSE_TIME = 5000;
|
|
17
15
|
export function Screenshot(props) {
|
|
18
16
|
const {
|
|
19
17
|
IPCPlayerContext,
|
|
@@ -25,97 +23,39 @@ export function Screenshot(props) {
|
|
|
25
23
|
className,
|
|
26
24
|
hideScreenShotMenu
|
|
27
25
|
} = props;
|
|
28
|
-
const {
|
|
29
|
-
screenType,
|
|
30
|
-
brandColor
|
|
31
|
-
} = useStore({
|
|
32
|
-
screenType: props.screenType,
|
|
33
|
-
brandColor: props.brandColor
|
|
34
|
-
});
|
|
35
26
|
const {
|
|
36
27
|
event
|
|
37
28
|
} = useContext(UIEventContext);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
showShot: false,
|
|
42
|
-
shotUrl: '',
|
|
43
|
-
shotCount: 0
|
|
44
|
-
});
|
|
45
|
-
const snapshotRequestIdRef = useRef(0);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
return () => {
|
|
48
|
-
snapshotRequestIdRef.current += 1;
|
|
49
|
-
};
|
|
29
|
+
const requestIdRef = useRef(0);
|
|
30
|
+
useEffect(() => () => {
|
|
31
|
+
requestIdRef.current += 1;
|
|
50
32
|
}, []);
|
|
51
|
-
|
|
52
|
-
if (state.showShot && screenType) {
|
|
53
|
-
showShotToast();
|
|
54
|
-
}
|
|
55
|
-
}, [state.showShot, screenType]);
|
|
56
|
-
const timer = useRef();
|
|
57
|
-
const timeToCloseToast = () => {
|
|
58
|
-
clearInterval(timer.current);
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
timer.current = setTimeout(() => {
|
|
61
|
-
setState({
|
|
62
|
-
showShot: false,
|
|
63
|
-
shotUrl: '',
|
|
64
|
-
shotCount: 0
|
|
65
|
-
});
|
|
66
|
-
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
67
|
-
}, CLOSE_TIME);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/** 跳转相册 */
|
|
71
|
-
const handCheck = () => {
|
|
72
|
-
setState({
|
|
73
|
-
showShot: false,
|
|
74
|
-
shotUrl: '',
|
|
75
|
-
shotCount: 0
|
|
76
|
-
});
|
|
77
|
-
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
78
|
-
clearInterval(timer.current);
|
|
79
|
-
goToIpcPageNativeRoute('ipc_album_panel', devId);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/** 添加截屏成功弹窗 */
|
|
83
|
-
const showShotToast = () => {
|
|
33
|
+
const showShotToast = (imageUrl, count) => {
|
|
84
34
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
85
35
|
addContent('absolute', {
|
|
86
36
|
id: 'plugin-screenshot-toast',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
brandColor: brandColor,
|
|
99
|
-
count: state.shotCount,
|
|
100
|
-
kind: "screenshot",
|
|
101
|
-
onCheck: handCheck,
|
|
102
|
-
thumbnailPath: state.shotUrl
|
|
103
|
-
});
|
|
37
|
+
absoluteNoCoverView: true,
|
|
38
|
+
content: CaptureToast,
|
|
39
|
+
initProps: {
|
|
40
|
+
kind: 'screenshot',
|
|
41
|
+
count,
|
|
42
|
+
imageUrl,
|
|
43
|
+
captureId: Date.now(),
|
|
44
|
+
screenType: props.screenType,
|
|
45
|
+
brandColor: props.brandColor,
|
|
46
|
+
devId,
|
|
47
|
+
deleteContent
|
|
104
48
|
}
|
|
105
49
|
});
|
|
106
|
-
timeToCloseToast();
|
|
107
50
|
};
|
|
108
51
|
const handClick = useMemoizedFn(async () => {
|
|
109
|
-
var _props$event;
|
|
110
|
-
(
|
|
52
|
+
var _props$event, _props$event2;
|
|
53
|
+
const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
|
|
54
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
111
55
|
widgetId: widgetLabs.SCREENSHOT
|
|
112
56
|
});
|
|
113
57
|
console.log('截屏!!!');
|
|
114
58
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
115
|
-
clearTimeout(timer.current);
|
|
116
|
-
setState({
|
|
117
|
-
showShot: false
|
|
118
|
-
});
|
|
119
59
|
const {
|
|
120
60
|
platform
|
|
121
61
|
} = getSystemInfoSync();
|
|
@@ -123,46 +63,32 @@ export function Screenshot(props) {
|
|
|
123
63
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
|
|
124
64
|
}
|
|
125
65
|
event.emit(pauseTimeToHideAllComponent);
|
|
126
|
-
const setIgnoreHideStopPreview = value => {
|
|
127
|
-
var _props$event2;
|
|
128
|
-
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(changeIgnoreHideStopPreview, value);
|
|
129
|
-
};
|
|
130
|
-
const handleSnapshotFail = err => {
|
|
131
|
-
setIgnoreHideStopPreview(false);
|
|
132
|
-
console.log(err, 'err');
|
|
133
|
-
const errObj = err.innerError || err || {};
|
|
134
|
-
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
135
|
-
toast({
|
|
136
|
-
title: errMsg
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
66
|
const granted = await ensureAlbumPermission();
|
|
140
|
-
|
|
67
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
141
68
|
if (!granted) return;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
})();
|
|
69
|
+
const requestId = ++requestIdRef.current;
|
|
70
|
+
IPCPlayerContext.snapshot({
|
|
71
|
+
saveToAlbum,
|
|
72
|
+
success: async res => {
|
|
73
|
+
var _props$multiCameraCtx;
|
|
74
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
75
|
+
const summary = await getCaptureResultSummary(res, {
|
|
76
|
+
multiLens: props.multiLens,
|
|
77
|
+
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),
|
|
78
|
+
devId
|
|
79
|
+
});
|
|
80
|
+
if (requestId !== requestIdRef.current || !summary) return;
|
|
81
|
+
showShotToast(summary.thumbnailPath, summary.isMultiLens ? summary.count : 0);
|
|
82
|
+
},
|
|
83
|
+
fail: err => {
|
|
84
|
+
ev.emit(changeIgnoreHideStopPreview, false);
|
|
85
|
+
const errObj = (err === null || err === void 0 ? void 0 : err.innerError) || err || {};
|
|
86
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
87
|
+
toast({
|
|
88
|
+
title: errMsg
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
166
92
|
});
|
|
167
93
|
if (hideScreenShotMenu) return null;
|
|
168
94
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|