@ray-js/ipc-player-integration 0.0.1-beta-52 → 0.0.1-beta-54

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/lib/ctx/ctx.js CHANGED
@@ -81,9 +81,7 @@ export const createUseCtx = _ref => {
81
81
  eventRef.current = getEventInstance();
82
82
  }
83
83
  useEffect(() => {
84
- console.log('========================+++++');
85
84
  if (devId && _playState === PlayState.PLAYING) {
86
- console.log('===================');
87
85
  // 获取缓存的值且同步
88
86
  getMemoryState(devId).then(res => {
89
87
  console.log('==== getMemoryState ====', res);
@@ -223,30 +221,52 @@ export const createUseCtx = _ref => {
223
221
  }
224
222
  });
225
223
  },
226
- fail: err => {
227
- showModal({
228
- title: '',
229
- content: Strings.getLang('ipc_player_no_record_permission'),
230
- cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
231
- confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
232
- isShowGlobal: true,
233
- success: res => {
234
- if (res.confirm) {
235
- const {
236
- platform
237
- } = getSystemInfoSync();
238
- console.log(platform, 'platform');
239
- openAppSystemSettingPage({
240
- // scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
241
- scope: 'App-Settings',
242
- success: () => {
243
- console.log('跳转成功');
224
+ fail: () => {
225
+ ty.authorize({
226
+ // 麦克风权限
227
+ scope: 'scope.record',
228
+ success: () => {
229
+ IPCPlayerInstance.current.startTalk({
230
+ success: () => {
231
+ updateAtom(intercom, true);
232
+ resolve(true);
233
+ },
234
+ fail: err => {
235
+ const errObj = err.innerError || err || {};
236
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
237
+ toast({
238
+ title: errMsg
239
+ });
240
+ reject(err);
241
+ }
242
+ });
243
+ },
244
+ fail: err => {
245
+ showModal({
246
+ title: '',
247
+ content: Strings.getLang('ipc_player_no_record_permission'),
248
+ cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
249
+ confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
250
+ isShowGlobal: true,
251
+ success: res => {
252
+ if (res.confirm) {
253
+ const {
254
+ platform
255
+ } = getSystemInfoSync();
256
+ console.log(platform, 'platform');
257
+ openAppSystemSettingPage({
258
+ // scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
259
+ scope: 'App-Settings',
260
+ success: () => {
261
+ console.log('跳转成功');
262
+ }
263
+ });
244
264
  }
245
- });
246
- }
265
+ }
266
+ });
267
+ reject(err);
247
268
  }
248
269
  });
249
- reject(err);
250
270
  }
251
271
  });
252
272
  } else {
@@ -278,7 +298,7 @@ export const createUseCtx = _ref => {
278
298
  }
279
299
  return new Promise((resolve, reject) => {
280
300
  if (target) {
281
- // 麦克风权限
301
+ // 写入相册
282
302
  ty.authorizeStatus({
283
303
  scope: 'scope.writePhotosAlbum',
284
304
  success: () => {
@@ -293,30 +313,46 @@ export const createUseCtx = _ref => {
293
313
  }
294
314
  });
295
315
  },
296
- fail: err => {
297
- showModal({
298
- title: '',
299
- content: Strings.getLang('ipc_player_no_album_permission'),
300
- cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
301
- confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
302
- isShowGlobal: true,
303
- success: res => {
304
- if (res.confirm) {
305
- const {
306
- platform
307
- } = getSystemInfoSync();
308
- console.log(platform, 'platform');
309
- openAppSystemSettingPage({
310
- // scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
311
- scope: 'App-Settings',
312
- success: () => {
313
- console.log('跳转成功');
316
+ fail: () => {
317
+ ty.authorize({
318
+ scope: 'scope.writePhotosAlbum',
319
+ success: () => {
320
+ IPCPlayerInstance.current.startRecord({
321
+ saveToAlbum,
322
+ success: () => {
323
+ updateAtom(recording, true);
324
+ resolve(true);
325
+ },
326
+ fail: err => {
327
+ reject(err);
328
+ }
329
+ });
330
+ },
331
+ fail: () => {
332
+ showModal({
333
+ title: '',
334
+ content: Strings.getLang('ipc_player_no_album_permission'),
335
+ cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
336
+ confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
337
+ isShowGlobal: true,
338
+ success: res => {
339
+ if (res.confirm) {
340
+ const {
341
+ platform
342
+ } = getSystemInfoSync();
343
+ console.log(platform, 'platform');
344
+ openAppSystemSettingPage({
345
+ // scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
346
+ scope: 'App-Settings',
347
+ success: () => {
348
+ console.log('跳转成功');
349
+ }
350
+ });
314
351
  }
315
- });
316
- }
352
+ }
353
+ });
317
354
  }
318
355
  });
319
- reject(err);
320
356
  }
321
357
  });
322
358
  } else {
@@ -18,6 +18,8 @@ declare const Strings: kit.I18N<{
18
18
  ipc_player_no_album_permission: string;
19
19
  ipc_player_authorize_cancel_text: string;
20
20
  ipc_player_authorize_confirm_text: string;
21
+ ipc_player_error_record_tip: string;
22
+ ipc_player_change_resolution_success: string;
21
23
  };
22
24
  zh: {
23
25
  ipc_player_resolution_HD: string;
@@ -37,6 +39,8 @@ declare const Strings: kit.I18N<{
37
39
  ipc_player_no_album_permission: string;
38
40
  ipc_player_authorize_cancel_text: string;
39
41
  ipc_player_authorize_confirm_text: string;
42
+ ipc_player_error_record_tip: string;
43
+ ipc_player_change_resolution_success: string;
40
44
  };
41
45
  }, {
42
46
  ipc_player_resolution_HD: string;
@@ -56,6 +60,8 @@ declare const Strings: kit.I18N<{
56
60
  ipc_player_no_album_permission: string;
57
61
  ipc_player_authorize_cancel_text: string;
58
62
  ipc_player_authorize_confirm_text: string;
63
+ ipc_player_error_record_tip: string;
64
+ ipc_player_change_resolution_success: string;
59
65
  } | {
60
66
  ipc_player_resolution_HD: string;
61
67
  ipc_player_resolution_SD: string;
@@ -74,5 +80,7 @@ declare const Strings: kit.I18N<{
74
80
  ipc_player_no_album_permission: string;
75
81
  ipc_player_authorize_cancel_text: string;
76
82
  ipc_player_authorize_confirm_text: string;
83
+ ipc_player_error_record_tip: string;
84
+ ipc_player_change_resolution_success: string;
77
85
  }>;
78
86
  export default Strings;
@@ -17,6 +17,8 @@ declare const _default: {
17
17
  ipc_player_no_album_permission: string;
18
18
  ipc_player_authorize_cancel_text: string;
19
19
  ipc_player_authorize_confirm_text: string;
20
+ ipc_player_error_record_tip: string;
21
+ ipc_player_change_resolution_success: string;
20
22
  };
21
23
  zh: {
22
24
  ipc_player_resolution_HD: string;
@@ -36,6 +38,8 @@ declare const _default: {
36
38
  ipc_player_no_album_permission: string;
37
39
  ipc_player_authorize_cancel_text: string;
38
40
  ipc_player_authorize_confirm_text: string;
41
+ ipc_player_error_record_tip: string;
42
+ ipc_player_change_resolution_success: string;
39
43
  };
40
44
  };
41
45
  export default _default;
@@ -16,7 +16,9 @@ export default {
16
16
  ipc_player_no_record_permission: 'The microphone permission is not enabled. Please go to the app settings to enable it first.',
17
17
  ipc_player_no_album_permission: 'You currently do not have access to the album or storage. Please enable this permission in the settings.',
18
18
  ipc_player_authorize_cancel_text: 'Cancel',
19
- ipc_player_authorize_confirm_text: 'Go to Settings'
19
+ ipc_player_authorize_confirm_text: 'Go to Settings',
20
+ ipc_player_error_record_tip: 'The recording has failed, please try again later.',
21
+ ipc_player_change_resolution_success: '切换成功'
20
22
  },
21
23
  zh: {
22
24
  ipc_player_resolution_HD: '高清',
@@ -35,6 +37,8 @@ export default {
35
37
  ipc_player_no_record_permission: '您当前没有 麦克风 的访问权限, 请在设置中打开此权限',
36
38
  ipc_player_no_album_permission: '您当前没有 相册/存储 的访问权限, 请在设置中打开此权限',
37
39
  ipc_player_authorize_cancel_text: '取消',
38
- ipc_player_authorize_confirm_text: '去设置'
40
+ ipc_player_authorize_confirm_text: '去设置',
41
+ ipc_player_error_record_tip: '录制出错了,请稍后再试',
42
+ ipc_player_change_resolution_success: '切换成功'
39
43
  }
40
44
  };
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext } from 'react';
3
- import { View, setPageOrientation, Text } from '@ray-js/ray';
3
+ import { View, setPageOrientation, Text, hideMenuButton, showMenuButton, showStatusBar, hideStatusBar, setNavigationBarBack } from '@ray-js/ray';
4
4
  import { useUpdateEffect } from 'ahooks';
5
5
  import clsx from 'clsx';
6
6
  import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
@@ -42,9 +42,9 @@ export function FullScreen(props) {
42
42
  */
43
43
  const handleFull = () => {
44
44
  hasDpCode(devId, DIRECTION_CONTROL_DP_CODE).then(hasDirectionControlDpCode => {
45
- ty.hideMenuButton();
46
- ty.hideStatusBar();
47
- ty.setNavigationBarBack({
45
+ hideMenuButton();
46
+ hideStatusBar();
47
+ setNavigationBarBack({
48
48
  type: 'custom'
49
49
  });
50
50
  batchedUpdates(() => {
@@ -95,11 +95,11 @@ export function FullScreen(props) {
95
95
  },
96
96
  vertical: () => {
97
97
  event.emit(pauseTimeToHideAllComponent);
98
- ty.setNavigationBarBack({
98
+ setNavigationBarBack({
99
99
  type: 'system'
100
100
  });
101
- ty.showMenuButton();
102
- ty.showStatusBar();
101
+ showMenuButton();
102
+ showStatusBar();
103
103
  deleteContent('topLeft', verticalScreenId);
104
104
  deleteContent('absolute', voiceIntercomId);
105
105
  deleteContent('absolute', ptzControlId);
@@ -111,13 +111,21 @@ export function FullScreen(props) {
111
111
  var _handlers$screenType;
112
112
  (_handlers$screenType = handlers[screenType]) === null || _handlers$screenType === void 0 || _handlers$screenType.call(handlers);
113
113
  }, [screenType]);
114
+
115
+ // 点击事件处理函数
114
116
  const handClick = target => {
117
+ // 根据target的值设置pageOrientation的值
115
118
  const pageOrientation = target === 'vertical' ? 'portrait' : 'landscape';
119
+ // 发射事件
116
120
  event.emit(pauseTimeToHideAllComponent);
121
+ // 设置screenType的值
122
+ setScreenType(target);
123
+ // 设置pageOrientation的值
117
124
  setPageOrientation({
118
125
  pageOrientation,
119
126
  success: () => {
120
- setScreenType(target);
127
+ // 忽略横屏
128
+ // setScreenType(target);
121
129
  }
122
130
  });
123
131
  };
@@ -12,7 +12,7 @@
12
12
  top: 50%;
13
13
  transform: translate(0, -50%);
14
14
  // transform: translate(180%, 0);
15
- right: calc(36px * var(--ipc-player-size-scale, 1));
15
+ right: calc(50px * var(--ipc-player-size-scale, 1));
16
16
  z-index: 340;
17
17
  }
18
18
 
@@ -82,7 +82,8 @@ export function RecordVideo(props) {
82
82
  setRecording,
83
83
  setRecordingDisabled,
84
84
  devId,
85
- className
85
+ className,
86
+ toast
86
87
  } = props;
87
88
  const {
88
89
  recording,
@@ -260,10 +261,15 @@ export function RecordVideo(props) {
260
261
  } catch (err) {
261
262
  console.log('录制失败', err);
262
263
  if ((err === null || err === void 0 ? void 0 : err.errorCode) === 7) {
263
- ty.showToast({
264
- icon: 'none',
264
+ toast({
265
265
  title: Strings.getLang('ipc_player_require_record_permission')
266
266
  });
267
+ } else {
268
+ const errObj = err.innerError || err || {};
269
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_record_tip');
270
+ toast({
271
+ title: errMsg
272
+ });
267
273
  }
268
274
  setState({
269
275
  showTimer: false
@@ -1,7 +1,7 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
3
  import React, { useCallback, useState, useContext, useEffect } from 'react';
4
- import { Text, View } from '@ray-js/ray';
4
+ import { Text, View, showToast } from '@ray-js/ray';
5
5
  import clsx from 'clsx';
6
6
  import Strings from '../../i18n';
7
7
  import { useMemoizedFn } from '../../hooks';
@@ -44,15 +44,19 @@ export const FullResolutionControl = props => {
44
44
  }, []);
45
45
  const changeResolution = useCallback(value => {
46
46
  if (value === resolution) {
47
- ty.showToast({
47
+ showToast({
48
48
  icon: 'none',
49
49
  title: Strings.getLang('ipc_player_current_resolution_is_equal')
50
50
  });
51
51
  } else {
52
52
  setResolution(value).then(() => {
53
+ showToast({
54
+ icon: 'none',
55
+ title: Strings.getLang('ipc_player_change_resolution_success')
56
+ });
53
57
  setHide(true);
54
58
  }).catch(() => {
55
- ty.showToast({
59
+ showToast({
56
60
  icon: 'error',
57
61
  title: Strings.getLang('ipc_player_resolution_change_error')
58
62
  });
@@ -131,25 +131,51 @@ export function Screenshot(props) {
131
131
  });
132
132
  },
133
133
  fail: () => {
134
- showModal({
135
- title: '',
136
- content: Strings.getLang('ipc_player_no_album_permission'),
137
- cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
138
- confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
139
- isShowGlobal: true,
140
- success: res => {
141
- if (res.confirm) {
142
- const {
143
- platform
144
- } = getSystemInfoSync();
145
- console.log(platform, 'platform');
146
- openAppSystemSettingPage({
147
- scope: 'App-Settings',
148
- success: () => {
149
- console.log('跳转成功');
134
+ ty.authorize({
135
+ scope: 'scope.writePhotosAlbum',
136
+ success: () => {
137
+ IPCPlayerContext.snapshot({
138
+ saveToAlbum,
139
+ // 保存到 IPC 相册
140
+ success: res => {
141
+ console.log(res, 'res');
142
+ setState({
143
+ showShot: true,
144
+ shotUrl: res.tempImagePath
145
+ });
146
+ },
147
+ fail: err => {
148
+ console.log(err, 'err');
149
+ const errObj = err.innerError || err || {};
150
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
151
+ toast({
152
+ title: errMsg
153
+ });
154
+ }
155
+ });
156
+ },
157
+ fail: () => {
158
+ showModal({
159
+ title: '',
160
+ content: Strings.getLang('ipc_player_no_album_permission'),
161
+ cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
162
+ confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
163
+ isShowGlobal: true,
164
+ success: res => {
165
+ if (res.confirm) {
166
+ const {
167
+ platform
168
+ } = getSystemInfoSync();
169
+ console.log(platform, 'platform');
170
+ openAppSystemSettingPage({
171
+ scope: 'App-Settings',
172
+ success: () => {
173
+ console.log('跳转成功');
174
+ }
175
+ });
150
176
  }
151
- });
152
- }
177
+ }
178
+ });
153
179
  }
154
180
  });
155
181
  }
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { CoverView, View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { useStore } from '../ctx/store';
5
- import { useComponentHideState } from './hooks';
6
5
  const TopLeftContent = _ref => {
7
6
  let {
8
7
  ctx,
@@ -14,7 +13,6 @@ const TopLeftContent = _ref => {
14
13
  screenType: ctx.screenType,
15
14
  playState: ctx.playState
16
15
  });
17
- const [shouldHide] = useComponentHideState();
18
16
  return /*#__PURE__*/React.createElement(CoverView, {
19
17
  className: clsx('ipc-player-top-left-content-wrap'),
20
18
  style: {
@@ -25,10 +23,7 @@ const TopLeftContent = _ref => {
25
23
  paddingTop: screenType === 'vertical' ? '12px' : '16px',
26
24
  paddingLeft: screenType === 'vertical' ? 0 : '25px'
27
25
  },
28
- className: clsx('ipc-player-top-left-content-container', {
29
- // 'ipc-player-top-left-content-hide': shouldHide,
30
- // 'ipc-player-top-left-content-show': !shouldHide,
31
- })
26
+ className: clsx('ipc-player-top-left-content-container')
32
27
  }, children));
33
28
  };
34
29
  export default /*#__PURE__*/React.memo(TopLeftContent);
package/lib/ui/ui.js CHANGED
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import "core-js/modules/esnext.iterator.constructor.js";
4
4
  import "core-js/modules/esnext.iterator.map.js";
5
- import React, { useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
5
+ import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
6
6
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
7
7
  import clsx from 'clsx';
8
8
  import IPCPlayer from '@ray-js/ray-ipc-player';
@@ -54,6 +54,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
54
54
  onPlayerTap,
55
55
  extend = {}
56
56
  } = props;
57
+ const {
58
+ event
59
+ } = useContext(UIEventContext);
57
60
  const instance = getCtxInstance(props.instance, devId);
58
61
  const {
59
62
  setPlayState,
@@ -70,6 +73,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
70
73
  这里用一个统一的状态标志期望控件是否展示
71
74
  */
72
75
  const [componentHideState, setComponentHideState] = useState(false);
76
+ const [showRightContent, setShowRightContent] = useState(true);
73
77
  prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
74
78
  const eventRef = useRef(instance.event);
75
79
  if (eventRef.current !== instance.event) {
@@ -81,6 +85,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
81
85
  setBrandColor(brandColor);
82
86
  setVerticalMic(verticalMic);
83
87
  }, []);
88
+ const refreshBottomLeft = value => {
89
+ console.log(value, '++++++++++++++----sadbjasbdjbsj');
90
+ event.current.emit(startTimeToHideAllComponent);
91
+ event.current.emit(showAllComponent);
92
+ event.current.emit(playerTap);
93
+ setShowRightContent(value);
94
+ };
84
95
 
85
96
  /**
86
97
  * 监听屏幕布局变化
@@ -241,15 +252,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
241
252
  eventRef.current.on(showAllComponent, listenShowEvent);
242
253
  eventRef.current.on(hideAllComponent, listenHideEvent);
243
254
  eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
255
+ eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
244
256
  return () => {
245
257
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
246
258
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
247
259
  eventRef.current.off(showAllComponent, listenShowEvent);
248
260
  eventRef.current.off(hideAllComponent, listenHideEvent);
249
261
  eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
262
+ eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
250
263
  };
251
264
  }, []);
252
- const playerReady = playState === PlayState.PLAYING;
265
+ playState === PlayState.PLAYING;
253
266
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
254
267
  value: {
255
268
  event: eventRef.current,
@@ -336,7 +349,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
336
349
  ctx: instance
337
350
  }, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
338
351
  ctx: instance
339
- }, renderBottomRightContent)), playerReady && (() => {
352
+ }, renderBottomRightContent)), (() => {
340
353
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
341
354
  return absoluteContent.map(item => {
342
355
  if (item.hidden) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-52",
3
+ "version": "0.0.1-beta-54",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
- "@ray-js/ray-ipc-player": "2.0.20-beta-10",
41
+ "@ray-js/ray-ipc-player": "2.0.20-beta-12",
42
42
  "@ray-js/ray-ipc-utils": "1.1.0-beta-15",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",