@ray-js/ipc-player-integration 0.0.18-beta-8 → 0.0.20-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/lib/ui/ui.d.ts CHANGED
@@ -26,6 +26,7 @@ type Props = {
26
26
  CSSVariable?: Partial<CSSVariable>;
27
27
  brandColor?: string;
28
28
  verticalMic?: boolean;
29
+ playerRoute?: string;
29
30
  landscapeMode?: 'fill' | 'standard';
30
31
  playerFit: 'contain' | 'cover';
31
32
  awakeStatus?: boolean | undefined;
package/lib/ui/ui.js CHANGED
@@ -58,6 +58,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
58
58
  playerFit = 'contain',
59
59
  awakeStatus = undefined,
60
60
  onPlayerTap,
61
+ playerRoute = 'pages/home/index',
61
62
  extend = {}
62
63
  } = props;
63
64
  const {
@@ -97,6 +98,82 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
97
98
  // const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
98
99
  // const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
99
100
 
101
+ const handleOrientationChange = useMemoizedFn(data => {
102
+ console.log(data, 'data=============');
103
+ const {
104
+ orientation
105
+ } = data;
106
+ console.log(orientation, 'orientation=-====');
107
+ if (['portrait', 'landscape-left', 'landscape-right'].includes(orientation)) {
108
+ var _ty;
109
+ if (typeof ((_ty = ty) === null || _ty === void 0 ? void 0 : _ty.getDeviceOrientationSync) !== 'function') return;
110
+ if (getPlayerRoute() !== playerRoute) {
111
+ // 不是Player首页的话,禁止以下行为
112
+ return;
113
+ }
114
+ console.log('屏幕方向变化调用吗');
115
+ setPageOrientation({
116
+ pageOrientation: orientation === 'landscape-left' || orientation === 'landscape-right' ? 'landscape' : 'portrait',
117
+ reverse: orientation === 'landscape-left',
118
+ success: () => {
119
+ console.log('set page orientation success');
120
+ },
121
+ fail: err => {
122
+ console.log('set page orientation fail', err);
123
+ }
124
+ });
125
+ }
126
+ });
127
+ useEffect(() => {
128
+ var _ty2;
129
+ console.log('getDeviceOrientationSync =======');
130
+ if (typeof ((_ty2 = ty) === null || _ty2 === void 0 ? void 0 : _ty2.getDeviceOrientationSync) !== 'function') return undefined;
131
+ try {
132
+ ty.onOrientationChange(handleOrientationChange);
133
+ const {
134
+ orientation
135
+ } = ty.getDeviceOrientationSync();
136
+ console.log(orientation, 'initial orientation');
137
+ if (orientation === 'landscape-left' || orientation === 'landscape-right') {
138
+ setScreenType('full');
139
+ }
140
+ if (orientation === 'unknown' || orientation === undefined) {
141
+ // 1秒后重试一次
142
+ const retryGetOrientation = () => {
143
+ const {
144
+ orientation
145
+ } = ty.getDeviceOrientationSync();
146
+ console.log(orientation, 'retry orientation');
147
+ if (orientation !== 'unknown' && orientation !== undefined) {
148
+ // 获取到有效方向,清除定时器并处理
149
+ if (reGetOrientationTimer.current) {
150
+ clearTimeout(reGetOrientationTimer.current);
151
+ reGetOrientationTimer.current = null;
152
+ }
153
+ if (orientation === 'landscape-left' || orientation === 'landscape-right') {
154
+ setScreenType('full');
155
+ }
156
+ handleOrientationChange({
157
+ orientation
158
+ });
159
+ } else {
160
+ // 仍然无效,继续重试
161
+ reGetOrientationTimer.current = setTimeout(retryGetOrientation, 1000);
162
+ }
163
+ };
164
+ reGetOrientationTimer.current = setTimeout(retryGetOrientation, 1000);
165
+ }
166
+ handleOrientationChange(orientation);
167
+ } catch (e) {
168
+ console.log('获取屏幕方向失败', e);
169
+ }
170
+ return () => {
171
+ var _ty3;
172
+ if (typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.offOrientationChange) === 'function') {
173
+ ty.offOrientationChange(handleOrientationChange);
174
+ }
175
+ };
176
+ }, []);
100
177
  const getPlayerRoute = () => {
101
178
  const pages = getCurrentPages(); // 获取当前页面栈
102
179
  const currentPage = pages[pages.length - 1]; // 获取当前页面实例
@@ -123,72 +200,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
123
200
  resolution: instance.resolution,
124
201
  mute: instance.mute
125
202
  });
126
- const getAndSetOrientation = () => {
127
- try {
128
- var _ty;
129
- if (typeof ((_ty = ty) === null || _ty === void 0 ? void 0 : _ty.getOrientationSync) === 'function') {
130
- const {
131
- orientation
132
- } = ty.getOrientationSync();
133
- console.log(`同步获取屏幕方向: ${orientation}`);
134
- ipcTTTOperatorLog(`同步获取屏幕方向: ${orientation}`);
135
- if (orientation === 'unknown') {
136
- // 1秒后重试一次
137
- reGetOrientationTimer.current = setTimeout(getAndSetOrientation, 500);
138
- return;
139
- }
140
- if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right', 'landscape'].includes(orientation)) {
141
- const {
142
- deviceType
143
- } = systemInfo.current;
144
- if (deviceType === 'pad') {
145
- setScreenType('vertical');
146
- return;
147
- }
148
- const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' || orientation === 'landscape' ? 'landscape' : 'portrait';
149
- if (pageOrientation === 'landscape') {
150
- // 如果为横屏的情况下,直接设置为全屏
151
- setScreenType(pageOrientation === 'landscape' ? 'full' : 'vertical');
152
- }
153
-
154
- // setPageOrientation({
155
- // pageOrientation,
156
- // success: () => {
157
- // console.log('success');
158
- // },
159
- // fail: err => {
160
- // console.log('err', err);
161
- // },
162
- // });
163
- }
164
- }
165
- } catch (e) {
166
- console.log('获取屏幕方向失败');
167
- }
168
- };
169
- useEffect(() => {
170
- // 首次进来强制为竖屏
171
- if (createCtx) {
172
- getAndSetOrientation();
173
- }
174
- return () => {
175
- if (reGetOrientationTimer.current) {
176
- clearTimeout(reGetOrientationTimer.current);
177
- }
178
- };
179
- }, [createCtx]);
180
- useEffect(() => {
181
- var _ty2;
182
- if (typeof ((_ty2 = ty) === null || _ty2 === void 0 ? void 0 : _ty2.onOrientationChange) === 'function') {
183
- ty.onOrientationChange(handleOrientationChange);
184
- }
185
- return () => {
186
- var _ty3;
187
- if (typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.offOrientationChange) === 'function') {
188
- ty.offOrientationChange(handleOrientationChange);
189
- }
190
- };
191
- }, []);
192
203
  useEffect(() => {
193
204
  if (createCtx) {
194
205
  setScaleMultiple(playerFit === 'contain' ? 1 : -2);
@@ -209,65 +220,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
209
220
  * 监听播放器实例创建完成
210
221
  */
211
222
 
212
- const handleOrientationChange = useMemoizedFn(data => {
213
- console.log(data, 'data=====');
214
- console.log(getPlayerRoute(), 'getPlayerRoute()');
215
- if (getPlayerRoute() !== 'pages/home/index') {
216
- // 不是首页的话,禁止以下行为
217
- return;
218
- }
219
- const {
220
- orientation
221
- } = data;
222
- if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right'].includes(orientation)) {
223
- // setScreenType(
224
- // orientation === 'landscape-left' || orientation === 'landscape-right' ? 'full' : 'vertical'
225
- // );
226
- const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' ? 'landscape' : 'portrait';
227
-
228
- // const { deviceType } = systemInfo.current;
229
- // // 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
230
- // if (deviceType === 'pad') {
231
- // setScreenType('vertical');
232
- // } else {
233
- // setScreenType(pageOrientation === 'landscape' ? 'full' : 'vertical');
234
- // triggerEvent(showAllComponent);
235
- // }
236
- // // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
237
- // if (pageOrientation === 'landscape' && landscapeMode === 'fill') {
238
- // console.log(scaleMultiple, '===========fill');
239
- // setScaleMultiple(-1);
240
- // } else if (pageOrientation === 'landscape' && landscapeMode === 'standard') {
241
- // console.log(scaleMultiple, '===========landscape');
242
- // setScaleMultiple(-2);
243
- // } else {
244
- // // 竖屏时 将屏幕播放比例设为按宽按高
245
-
246
- // console.log(scaleMultiple, '===========landscape');
247
- // setScaleMultiple(playerFit === 'contain' ? (scaleMultiple === 1 ? -1 : 1) : -2);
248
- // }
249
- // 强制更改页面转向
250
- setPageOrientation({
251
- pageOrientation,
252
- success: () => {
253
- console.log('success');
254
- },
255
- fail: err => {
256
- console.log('err', err);
257
- }
258
- });
259
- }
260
- });
261
-
262
223
  /**
263
224
  * 监听屏幕布局变化
264
225
  */
265
226
  usePageEvent('onResize', useMemoizedFn(sizeData => {
266
- // if (typeof ty?.onOrientationChange === 'function') {
267
- // return;
268
- // }
269
227
  console.log(getPlayerRoute(), 'getPlayerRoute()');
270
- if (getPlayerRoute() !== 'pages/home/index') {
228
+ if (getPlayerRoute() !== playerRoute) {
271
229
  // 不是Player首页的话,禁止以下行为
272
230
  return;
273
231
  }
@@ -522,6 +480,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
522
480
  eventRef.current.off(hideAllComponent, listenHideEvent);
523
481
  eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
524
482
  eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
483
+ if (reGetOrientationTimer.current) {
484
+ clearTimeout(reGetOrientationTimer.current);
485
+ reGetOrientationTimer.current = null;
486
+ }
525
487
  };
526
488
  }, []);
527
489
  playState === PlayState.PLAYING;
@@ -552,7 +514,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
552
514
  if (scaleMode === -2 && playerFit === 'cover' && screenType === 'vertical' && landscapeMode === 'standard') {
553
515
  console.log('dsadsadsad----', zoomLevel);
554
516
  setScaleMultiple(zoomLevel);
555
- // setVerticalCoverZoom(zoomLevel);
556
517
  }
557
518
  /**
558
519
  * 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
@@ -571,14 +532,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
571
532
  setVerticalCoverZoom(zoomLevel);
572
533
  setScaleMultiple(zoomLevel);
573
534
  }
574
-
575
- // if (screenType === 'vertical' && scaleMode === -1) {
576
- // console.log('dsadsadsad----');
577
- // // setVerticalCoverZoom(zoomLevel);
578
- // setScaleMultiple(zoomLevel);
579
- // }
580
- console.log(data === null || data === void 0 ? void 0 : data.detail, 'data?.detail');
581
- console.log(zoomLevel, 'zoomLevel======');
582
535
  setCurrentZoomLevel(zoomLevel);
583
536
  return false;
584
537
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.18-beta-8",
3
+ "version": "0.0.20-beta-1",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,7 +38,7 @@
38
38
  "@ray-js/ipc-ptz-zoom": "^0.0.2",
39
39
  "@ray-js/panel-sdk": "^1.13.1",
40
40
  "@ray-js/direction-control": "^0.0.8",
41
- "@ray-js/ray-ipc-player": "2.0.26-beta-1",
41
+ "@ray-js/ray-ipc-player": "2.0.26",
42
42
  "@ray-js/ray-ipc-utils": "^1.1.10",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",
@@ -48,7 +48,6 @@
48
48
  "@commitlint/cli": "^7.2.1",
49
49
  "@commitlint/config-conventional": "^9.0.1",
50
50
  "@ray-js/cli": "^1.7.14",
51
- "@ray-js/direction-control": "^0.0.7",
52
51
  "@ray-js/ray": "^1.7.14",
53
52
  "@testing-library/react-hooks": "^8.0.1",
54
53
  "@types/jest": "^29.5.14",