@ray-js/ray-ipc-player 0.0.13-beta-1
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 +107 -0
- package/lib/constant.android.js +1 -0
- package/lib/constant.d.ts +23 -0
- package/lib/constant.ios.js +1 -0
- package/lib/constant.js +28 -0
- package/lib/constant.tuya.js +28 -0
- package/lib/constant.web.js +28 -0
- package/lib/constant.wechat.js +28 -0
- package/lib/i18n/index.android.js +1 -0
- package/lib/i18n/index.d.ts +3 -0
- package/lib/i18n/index.ios.js +1 -0
- package/lib/i18n/index.js +4 -0
- package/lib/i18n/index.tuya.js +4 -0
- package/lib/i18n/index.web.js +4 -0
- package/lib/i18n/index.wechat.js +4 -0
- package/lib/i18n/strings.android.js +1 -0
- package/lib/i18n/strings.d.ts +1521 -0
- package/lib/i18n/strings.ios.js +1 -0
- package/lib/i18n/strings.js +1520 -0
- package/lib/i18n/strings.json +1569 -0
- package/lib/i18n/strings.tuya.js +1520 -0
- package/lib/i18n/strings.web.js +1520 -0
- package/lib/i18n/strings.wechat.js +1520 -0
- package/lib/index.android.js +1 -0
- package/lib/index.config.android.js +1 -0
- package/lib/index.config.ios.js +1 -0
- package/lib/index.config.js +4 -0
- package/lib/index.config.tuya.js +4 -0
- package/lib/index.config.web.js +4 -0
- package/lib/index.config.wechat.js +4 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.ios.js +1 -0
- package/lib/index.js +497 -0
- package/lib/index.module.less +127 -0
- package/lib/index.tuya.js +497 -0
- package/lib/index.web.js +497 -0
- package/lib/index.wechat.js +497 -0
- package/lib/typings/index.d.ts +153 -0
- package/lib/utils.android.js +1 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.ios.js +1 -0
- package/lib/utils.js +19 -0
- package/lib/utils.tuya.js +19 -0
- package/lib/utils.web.js +19 -0
- package/lib/utils.wechat.js +19 -0
- package/package.json +87 -0
package/lib/index.web.js
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
|
4
|
+
import "core-js/modules/es.promise.js";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import React, { useEffect, useRef, useCallback } from 'react';
|
|
7
|
+
import { useImmer } from 'use-immer';
|
|
8
|
+
import { IpcPlayer, View, Text, CoverView } from '@ray-js/components';
|
|
9
|
+
import cx from 'classnames';
|
|
10
|
+
import { usePageEvent } from 'ray';
|
|
11
|
+
import locals from './i18n';
|
|
12
|
+
import Styles from './index.module.less';
|
|
13
|
+
import { IpcFailCode } from './constant';
|
|
14
|
+
import { putDpData } from './utils';
|
|
15
|
+
|
|
16
|
+
var Player = function (props) {
|
|
17
|
+
var _props$updateLayout = props.updateLayout,
|
|
18
|
+
updateLayout = _props$updateLayout === void 0 ? '' : _props$updateLayout,
|
|
19
|
+
_props$devId = props.devId,
|
|
20
|
+
devId = _props$devId === void 0 ? '' : _props$devId,
|
|
21
|
+
_props$devName = props.devName,
|
|
22
|
+
devName = _props$devName === void 0 ? '' : _props$devName,
|
|
23
|
+
onChangeStreamStatus = props.onChangeStreamStatus,
|
|
24
|
+
onPlayerTap = props.onPlayerTap,
|
|
25
|
+
onInitPreview = props.onInitPreview,
|
|
26
|
+
_props$defaultMute = props.defaultMute,
|
|
27
|
+
defaultMute = _props$defaultMute === void 0 ? true : _props$defaultMute,
|
|
28
|
+
_props$onlineStatus = props.onlineStatus,
|
|
29
|
+
onlineStatus = _props$onlineStatus === void 0 ? true : _props$onlineStatus,
|
|
30
|
+
_props$loadDes = props.loadDes,
|
|
31
|
+
loadDes = _props$loadDes === void 0 ? '' : _props$loadDes,
|
|
32
|
+
_props$rotateZ = props.rotateZ,
|
|
33
|
+
rotateZ = _props$rotateZ === void 0 ? 0 : _props$rotateZ,
|
|
34
|
+
_props$scalable = props.scalable,
|
|
35
|
+
scalable = _props$scalable === void 0 ? true : _props$scalable,
|
|
36
|
+
_props$scaleMultiple = props.scaleMultiple,
|
|
37
|
+
scaleMultiple = _props$scaleMultiple === void 0 ? 0 : _props$scaleMultiple,
|
|
38
|
+
_props$ptzControllabl = props.ptzControllable,
|
|
39
|
+
ptzControllable = _props$ptzControllabl === void 0 ? true : _props$ptzControllabl,
|
|
40
|
+
_props$isOnPlayerPage = props.isOnPlayerPage,
|
|
41
|
+
isOnPlayerPage = _props$isOnPlayerPage === void 0 ? true : _props$isOnPlayerPage,
|
|
42
|
+
_props$clarity = props.clarity,
|
|
43
|
+
clarity = _props$clarity === void 0 ? 'normal' : _props$clarity,
|
|
44
|
+
_props$soundMode = props.soundMode,
|
|
45
|
+
soundMode = _props$soundMode === void 0 ? 'speaker' : _props$soundMode,
|
|
46
|
+
_props$orientation = props.orientation,
|
|
47
|
+
orientation = _props$orientation === void 0 ? 'vertical' : _props$orientation,
|
|
48
|
+
onCtx = props.onCtx,
|
|
49
|
+
_props$borderRadius = props.borderRadius,
|
|
50
|
+
borderRadius = _props$borderRadius === void 0 ? 0 : _props$borderRadius,
|
|
51
|
+
_props$bgColor = props.bgColor,
|
|
52
|
+
bgColor = _props$bgColor === void 0 ? '#000000' : _props$bgColor,
|
|
53
|
+
_props$borderStyle = props.borderStyle,
|
|
54
|
+
borderStyle = _props$borderStyle === void 0 ? 'solid' : _props$borderStyle,
|
|
55
|
+
_props$borderColor = props.borderColor,
|
|
56
|
+
borderColor = _props$borderColor === void 0 ? '' : _props$borderColor,
|
|
57
|
+
_props$borderWidth = props.borderWidth,
|
|
58
|
+
borderWidth = _props$borderWidth === void 0 ? 0 : _props$borderWidth,
|
|
59
|
+
_props$privateState = props.privateState,
|
|
60
|
+
privateState = _props$privateState === void 0 ? false : _props$privateState;
|
|
61
|
+
|
|
62
|
+
var _useImmer = useImmer({
|
|
63
|
+
connectState: false,
|
|
64
|
+
// 连接状态
|
|
65
|
+
loadingState: false,
|
|
66
|
+
// 加载状态
|
|
67
|
+
errorState: false,
|
|
68
|
+
// 异常状态
|
|
69
|
+
errorMsg: '',
|
|
70
|
+
// 异常信息
|
|
71
|
+
updateLy: '',
|
|
72
|
+
devlineState: true,
|
|
73
|
+
initLy: false
|
|
74
|
+
}),
|
|
75
|
+
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
76
|
+
playState = _useImmer2[0],
|
|
77
|
+
setPlayState = _useImmer2[1];
|
|
78
|
+
|
|
79
|
+
var ipcCtx = useRef(null); // ipc实例
|
|
80
|
+
|
|
81
|
+
var retryCount = useRef(0); // 重试次数
|
|
82
|
+
|
|
83
|
+
var muteRef = useRef(defaultMute); // 静音
|
|
84
|
+
|
|
85
|
+
usePageEvent('onShow', useCallback(function () {
|
|
86
|
+
// console.log('show');
|
|
87
|
+
if (ipcCtx.current && playState.connectState) {
|
|
88
|
+
startPreview('');
|
|
89
|
+
}
|
|
90
|
+
}, [playState.connectState]));
|
|
91
|
+
usePageEvent('onHide', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
92
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
93
|
+
while (1) {
|
|
94
|
+
switch (_context.prev = _context.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
// console.log('hide');
|
|
97
|
+
setPlayState(function (d) {
|
|
98
|
+
d.loadingState = true;
|
|
99
|
+
});
|
|
100
|
+
_context.next = 3;
|
|
101
|
+
return getCurMute();
|
|
102
|
+
|
|
103
|
+
case 3:
|
|
104
|
+
stopPreview();
|
|
105
|
+
|
|
106
|
+
case 4:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context.stop();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
}))); // 隐私模式
|
|
113
|
+
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
setPlayState(function (d) {
|
|
116
|
+
d.errorState = privateState;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (!privateState) {
|
|
120
|
+
retry();
|
|
121
|
+
}
|
|
122
|
+
}, [privateState]);
|
|
123
|
+
useEffect(function () {
|
|
124
|
+
muteRef.current = defaultMute;
|
|
125
|
+
}, [defaultMute]);
|
|
126
|
+
useEffect(function () {
|
|
127
|
+
setPlayState(function (d) {
|
|
128
|
+
d.updateLy = updateLayout;
|
|
129
|
+
});
|
|
130
|
+
}, [updateLayout]); // 设备离线
|
|
131
|
+
|
|
132
|
+
useEffect(function () {
|
|
133
|
+
setPlayState(function (d) {
|
|
134
|
+
d.devlineState = onlineStatus;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (!onlineStatus) {
|
|
138
|
+
setPlayState(function (d) {
|
|
139
|
+
d.errorState = true;
|
|
140
|
+
d.errorMsg = locals.getLang('ipc_player_no_line');
|
|
141
|
+
});
|
|
142
|
+
} else if (playState.initLy) {
|
|
143
|
+
retry();
|
|
144
|
+
}
|
|
145
|
+
}, [onlineStatus, playState.initLy]);
|
|
146
|
+
useEffect(function () {
|
|
147
|
+
if (!isOnPlayerPage) {
|
|
148
|
+
disconnect();
|
|
149
|
+
}
|
|
150
|
+
}, [isOnPlayerPage]); // 重试
|
|
151
|
+
|
|
152
|
+
var _retry = /*#__PURE__*/function () {
|
|
153
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
154
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
155
|
+
while (1) {
|
|
156
|
+
switch (_context2.prev = _context2.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
setPlayState(function (d) {
|
|
159
|
+
d.connectState = false;
|
|
160
|
+
d.errorMsg = '';
|
|
161
|
+
d.errorState = false;
|
|
162
|
+
});
|
|
163
|
+
_context2.t0 = playState.connectState;
|
|
164
|
+
|
|
165
|
+
if (!_context2.t0) {
|
|
166
|
+
_context2.next = 5;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_context2.next = 5;
|
|
171
|
+
return disconnect();
|
|
172
|
+
|
|
173
|
+
case 5:
|
|
174
|
+
createConnect();
|
|
175
|
+
|
|
176
|
+
case 6:
|
|
177
|
+
case "end":
|
|
178
|
+
return _context2.stop();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, _callee2);
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
return function () {
|
|
185
|
+
return _ref2.apply(this, arguments);
|
|
186
|
+
};
|
|
187
|
+
}();
|
|
188
|
+
|
|
189
|
+
var retry = useCallback(function () {
|
|
190
|
+
// console.log('retry:', muteRef.current);
|
|
191
|
+
!privateState && _retry();
|
|
192
|
+
}, [playState.connectState, privateState]); // 创建ipc实例
|
|
193
|
+
|
|
194
|
+
var createIpcCtx = function (id) {
|
|
195
|
+
var _ty;
|
|
196
|
+
|
|
197
|
+
// @ts-ignore
|
|
198
|
+
ipcCtx.current = (_ty = ty) === null || _ty === void 0 ? void 0 : _ty.createIpcPlayerContext(id); // console.log('创建实例:', devId);
|
|
199
|
+
|
|
200
|
+
onCtx && onCtx({
|
|
201
|
+
ctx: ipcCtx.current,
|
|
202
|
+
retry: retry
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
useEffect(function () {
|
|
207
|
+
onlineStatus && createIpcCtx(devId);
|
|
208
|
+
return function () {
|
|
209
|
+
disconnect();
|
|
210
|
+
ipcCtx.current = null;
|
|
211
|
+
};
|
|
212
|
+
}, [devId, onlineStatus]); // 建立连接
|
|
213
|
+
|
|
214
|
+
var createConnect = function (params) {
|
|
215
|
+
var _ipcCtx$current;
|
|
216
|
+
|
|
217
|
+
// console.log('建立连接:', devId);
|
|
218
|
+
setPlayState(function (d) {
|
|
219
|
+
d.loadingState = true;
|
|
220
|
+
});
|
|
221
|
+
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 ? void 0 : _ipcCtx$current.connect({
|
|
222
|
+
success: function success() {
|
|
223
|
+
// console.log('建立连接成功:', devId);
|
|
224
|
+
setPlayState(function (d) {
|
|
225
|
+
d.connectState = true;
|
|
226
|
+
d.errorState = false;
|
|
227
|
+
d.errorMsg = '';
|
|
228
|
+
});
|
|
229
|
+
onChangeStreamStatus && onChangeStreamStatus(1001);
|
|
230
|
+
startPreview(params);
|
|
231
|
+
},
|
|
232
|
+
fail: function fail() {
|
|
233
|
+
// console.log('建立连接失败:', devId);
|
|
234
|
+
setPlayState(function (d) {
|
|
235
|
+
d.connectState = false;
|
|
236
|
+
d.errorState = true;
|
|
237
|
+
d.errorMsg = locals.getLang('ipc_player_connect_fail');
|
|
238
|
+
d.loadingState = false;
|
|
239
|
+
});
|
|
240
|
+
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}; // 视图层准备就绪,开始建立连接
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
// 开启预览
|
|
247
|
+
var startPreview = function (params) {
|
|
248
|
+
var _ipcCtx$current2;
|
|
249
|
+
|
|
250
|
+
(_ipcCtx$current2 = ipcCtx.current) === null || _ipcCtx$current2 === void 0 ? void 0 : _ipcCtx$current2.startPreview({
|
|
251
|
+
success: function success() {
|
|
252
|
+
// console.log('开启预览:', devId);
|
|
253
|
+
setPlayState(function (d) {
|
|
254
|
+
d.loadingState = false;
|
|
255
|
+
d.errorState = false;
|
|
256
|
+
d.errorMsg = '';
|
|
257
|
+
});
|
|
258
|
+
params && onInitPreview && onInitPreview(devId);
|
|
259
|
+
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
260
|
+
},
|
|
261
|
+
fail: function fail() {
|
|
262
|
+
// console.log('开启失败:', devId);
|
|
263
|
+
setPlayState(function (d) {
|
|
264
|
+
d.errorState = true;
|
|
265
|
+
d.loadingState = false;
|
|
266
|
+
d.errorMsg = locals.getLang('ipc_player_preview_fail');
|
|
267
|
+
});
|
|
268
|
+
onChangeStreamStatus && onChangeStreamStatus(-1002);
|
|
269
|
+
},
|
|
270
|
+
complete: function complete() {
|
|
271
|
+
// console.log('startPreview:', muteRef.current);
|
|
272
|
+
setMuted(muteRef.current);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}; // 暂停预览
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
var stopPreview = function () {
|
|
279
|
+
var _ipcCtx$current3;
|
|
280
|
+
|
|
281
|
+
(_ipcCtx$current3 = ipcCtx.current) === null || _ipcCtx$current3 === void 0 ? void 0 : _ipcCtx$current3.stopPreview({
|
|
282
|
+
success: function success() {
|
|
283
|
+
return null;
|
|
284
|
+
},
|
|
285
|
+
fail: function fail() {
|
|
286
|
+
return null;
|
|
287
|
+
},
|
|
288
|
+
complete: function complete() {
|
|
289
|
+
return setMuted(true);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}; // 设置静音
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
var setMuted = function (val) {
|
|
296
|
+
var _ipcCtx$current4;
|
|
297
|
+
|
|
298
|
+
(_ipcCtx$current4 = ipcCtx.current) === null || _ipcCtx$current4 === void 0 ? void 0 : _ipcCtx$current4.setMuted({
|
|
299
|
+
mute: val,
|
|
300
|
+
success: function success() {// console.log('设置声音成功', val);
|
|
301
|
+
},
|
|
302
|
+
fail: function fail() {// console.log('设置声音失败');
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}; // 获取当前是否静音
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
var getCurMute = function () {
|
|
309
|
+
return new Promise(function (resolve, reject) {
|
|
310
|
+
var _ipcCtx$current5;
|
|
311
|
+
|
|
312
|
+
(_ipcCtx$current5 = ipcCtx.current) === null || _ipcCtx$current5 === void 0 ? void 0 : _ipcCtx$current5.isMuted({
|
|
313
|
+
success: function success(res) {
|
|
314
|
+
muteRef.current = res;
|
|
315
|
+
},
|
|
316
|
+
fail: function fail(e) {
|
|
317
|
+
reject(e); // console.log(e);
|
|
318
|
+
},
|
|
319
|
+
complete: function complete(d) {
|
|
320
|
+
resolve(d);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
}; // 异常事件
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
var onError = useCallback(function (e) {
|
|
328
|
+
var _e$detail;
|
|
329
|
+
|
|
330
|
+
if (playState.errorState) {
|
|
331
|
+
return;
|
|
332
|
+
} // console.error('发生错误:', e);
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
var type = e === null || e === void 0 ? void 0 : (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.errCode;
|
|
336
|
+
|
|
337
|
+
if (IpcFailCode[type]) {
|
|
338
|
+
onChangeStreamStatus && onChangeStreamStatus(type);
|
|
339
|
+
setPlayState(function (d) {
|
|
340
|
+
d.loadingState = false;
|
|
341
|
+
d.errorState = true;
|
|
342
|
+
d.errorMsg = locals.getLang(IpcFailCode[type]);
|
|
343
|
+
d.connectState = false;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}, [playState.errorState]); // 连接状态发生变化
|
|
347
|
+
|
|
348
|
+
// 断开连接
|
|
349
|
+
var disconnect = function () {
|
|
350
|
+
return new Promise(function (resolve, reject) {
|
|
351
|
+
var _ipcCtx$current6;
|
|
352
|
+
|
|
353
|
+
(_ipcCtx$current6 = ipcCtx.current) === null || _ipcCtx$current6 === void 0 ? void 0 : _ipcCtx$current6.disconnect({
|
|
354
|
+
success: function success(res) {
|
|
355
|
+
// console.log('断开连接成功:', devId);
|
|
356
|
+
resolve(res);
|
|
357
|
+
setPlayState(function (d) {
|
|
358
|
+
d.connectState = false;
|
|
359
|
+
});
|
|
360
|
+
onChangeStreamStatus && onChangeStreamStatus(1009);
|
|
361
|
+
},
|
|
362
|
+
fail: function fail(e) {
|
|
363
|
+
// console.log('断开连接失败:', devId);
|
|
364
|
+
reject(e);
|
|
365
|
+
onChangeStreamStatus && onChangeStreamStatus(-1009);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// 关闭隐私模式,重新拉流
|
|
372
|
+
var handleReWakeCamera = /*#__PURE__*/function () {
|
|
373
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
374
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
375
|
+
while (1) {
|
|
376
|
+
switch (_context3.prev = _context3.next) {
|
|
377
|
+
case 0:
|
|
378
|
+
_context3.next = 2;
|
|
379
|
+
return putDpData({
|
|
380
|
+
105: false
|
|
381
|
+
}, devId);
|
|
382
|
+
|
|
383
|
+
case 2:
|
|
384
|
+
case "end":
|
|
385
|
+
return _context3.stop();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}, _callee3);
|
|
389
|
+
}));
|
|
390
|
+
|
|
391
|
+
return function () {
|
|
392
|
+
return _ref3.apply(this, arguments);
|
|
393
|
+
};
|
|
394
|
+
}();
|
|
395
|
+
|
|
396
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
397
|
+
className: Styles.ipc_player
|
|
398
|
+
}, isOnPlayerPage && /*#__PURE__*/React.createElement(IpcPlayer, {
|
|
399
|
+
className: Styles.player,
|
|
400
|
+
onVideotap: function handlePlayerClick() {
|
|
401
|
+
// console.log("videoTap:", devId);
|
|
402
|
+
onPlayerTap && onPlayerTap(devId);
|
|
403
|
+
},
|
|
404
|
+
onInitdone: function initdone() {
|
|
405
|
+
// console.log('视图层准备就绪:', devId);
|
|
406
|
+
setPlayState(function (d) {
|
|
407
|
+
d.updateLy = Math.random();
|
|
408
|
+
d.initLy = true;
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
onError: onError,
|
|
412
|
+
onConnectchange: function connectchange(e) {
|
|
413
|
+
var _e$detail2;
|
|
414
|
+
|
|
415
|
+
// console.log('连接状态发生变化', e);
|
|
416
|
+
var code = e === null || e === void 0 ? void 0 : (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.state;
|
|
417
|
+
onChangeStreamStatus && onChangeStreamStatus(code === 0 ? 1001 : -1001);
|
|
418
|
+
|
|
419
|
+
if (code === 0) {
|
|
420
|
+
setPlayState(function (d) {
|
|
421
|
+
d.connectState = true;
|
|
422
|
+
});
|
|
423
|
+
} else if ((code === -3 || code === -105) && retryCount.current < 1) {
|
|
424
|
+
// 连接超时或鉴权失败重试一次
|
|
425
|
+
retryCount.current++;
|
|
426
|
+
retry();
|
|
427
|
+
} else {
|
|
428
|
+
setPlayState(function (d) {
|
|
429
|
+
d.connectState = false;
|
|
430
|
+
d.loadingState = false;
|
|
431
|
+
d.errorState = true;
|
|
432
|
+
d.errorMsg = locals.getLang(IpcFailCode[-1001]);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
deviceId: devId,
|
|
437
|
+
autoPauseIfNavigate: false,
|
|
438
|
+
autoPauseIfOpenNative: false,
|
|
439
|
+
muted: defaultMute,
|
|
440
|
+
objectFit: "fillCrop",
|
|
441
|
+
clarity: clarity,
|
|
442
|
+
soundMode: soundMode,
|
|
443
|
+
orientation: orientation,
|
|
444
|
+
rotateZ: rotateZ,
|
|
445
|
+
scalable: scalable,
|
|
446
|
+
scaleMultiple: scaleMultiple,
|
|
447
|
+
ptzControllable: ptzControllable,
|
|
448
|
+
borderRadius: borderRadius,
|
|
449
|
+
borderStyle: borderStyle,
|
|
450
|
+
borderColor: borderColor,
|
|
451
|
+
borderWidth: borderWidth,
|
|
452
|
+
updateLayout: playState.updateLy,
|
|
453
|
+
backgroundColor: bgColor
|
|
454
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
455
|
+
style: {
|
|
456
|
+
borderRadius: "".concat(borderRadius)
|
|
457
|
+
},
|
|
458
|
+
className: cx(Styles.load_box, Styles.bg_center, !playState.loadingState && Styles.hide)
|
|
459
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
460
|
+
className: Styles.load_icon
|
|
461
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
462
|
+
className: Styles.load_des
|
|
463
|
+
}, loadDes || locals.getLang('get_video_stream'))), /*#__PURE__*/React.createElement(CoverView, {
|
|
464
|
+
style: {
|
|
465
|
+
borderRadius: "".concat(borderRadius)
|
|
466
|
+
},
|
|
467
|
+
className: cx(Styles.bg_center, Styles.state_label, !playState.errorState && Styles.hide)
|
|
468
|
+
}, privateState ? /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
469
|
+
className: Styles.device_sleep
|
|
470
|
+
}, locals.getLang('device_sleep')), /*#__PURE__*/React.createElement(View, {
|
|
471
|
+
className: Styles.re_wake_camera // @ts-ignore
|
|
472
|
+
,
|
|
473
|
+
onClick: handleReWakeCamera
|
|
474
|
+
}, locals.getLang('re_wake_camera'))) : /*#__PURE__*/React.createElement(View, {
|
|
475
|
+
style: {
|
|
476
|
+
width: '95%',
|
|
477
|
+
textAlign: 'center'
|
|
478
|
+
}
|
|
479
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
480
|
+
className: cx(Styles.iconfont, Styles.icon_tishi, !playState.devlineState && Styles.hide)
|
|
481
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
482
|
+
className: Styles.err_msg
|
|
483
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
484
|
+
className: cx(Styles.msg, Styles.ellipsis)
|
|
485
|
+
}, playState.errorMsg), /*#__PURE__*/React.createElement(Text, {
|
|
486
|
+
style: {
|
|
487
|
+
color: '#fff'
|
|
488
|
+
},
|
|
489
|
+
className: !playState.devlineState && Styles.hide
|
|
490
|
+
}, "\uFF0C"), /*#__PURE__*/React.createElement(View // @ts-ignore
|
|
491
|
+
, {
|
|
492
|
+
onClick: retry,
|
|
493
|
+
className: cx(Styles.retry, !playState.devlineState && Styles.hide)
|
|
494
|
+
}, locals.getLang('ipc_player_retry'))))));
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
export default Player;
|