@ray-js/ipc-player-integration 0.0.18-beta-3 → 0.0.18-beta-5

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.
Files changed (2) hide show
  1. package/lib/ui/ui.js +47 -25
  2. package/package.json +1 -1
package/lib/ui/ui.js CHANGED
@@ -126,8 +126,29 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
126
126
  const {
127
127
  orientation
128
128
  } = ty.getOrientationSync();
129
+ console.log(`同步获取屏幕方向: ${orientation}`);
129
130
  ipcTTTOperatorLog(`同步获取屏幕方向: ${orientation}`);
130
- setScreenType(orientation === 'landscape' ? 'full' : 'vertical');
131
+ if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right', 'landscape'].includes(orientation)) {
132
+ const {
133
+ deviceType
134
+ } = systemInfo.current;
135
+ if (deviceType === 'pad') {
136
+ setScreenType('vertical');
137
+ return;
138
+ }
139
+ const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' || orientation === 'landscape' ? 'landscape' : 'portrait';
140
+ setScreenType(pageOrientation === 'landscape' ? 'full' : 'vertical');
141
+ // 强制更改页面转向
142
+ setPageOrientation({
143
+ pageOrientation,
144
+ success: () => {
145
+ console.log('success');
146
+ },
147
+ fail: err => {
148
+ console.log('err', err);
149
+ }
150
+ });
151
+ }
131
152
  }
132
153
  } catch (e) {
133
154
  console.log('获取屏幕方向失败');
@@ -166,14 +187,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
166
187
  * 监听播放器实例创建完成
167
188
  */
168
189
 
169
- const handleOrientationChange = data => {
190
+ const handleOrientationChange = useMemoizedFn(data => {
191
+ console.log(data, 'data=====');
170
192
  const {
171
193
  orientation
172
194
  } = data;
173
195
  if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right'].includes(orientation)) {
174
- // setScreenType(
175
- // orientation === 'landscape-left' || orientation === 'landscape-right' ? 'full' : 'vertical'
176
- // );
196
+ setScreenType(orientation === 'landscape-left' || orientation === 'landscape-right' ? 'full' : 'vertical');
177
197
  const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' ? 'landscape' : 'portrait';
178
198
  const {
179
199
  deviceType
@@ -181,6 +201,22 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
181
201
  // 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
182
202
  if (deviceType === 'pad') {
183
203
  setScreenType('vertical');
204
+ } else {
205
+ setScreenType(pageOrientation === 'landscape' ? 'full' : 'vertical');
206
+ triggerEvent(showAllComponent);
207
+ }
208
+ // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
209
+ if (pageOrientation === 'landscape' && landscapeMode === 'fill') {
210
+ console.log(scaleMultiple, '===========fill');
211
+ setScaleMultiple(-1);
212
+ } else if (pageOrientation === 'landscape' && landscapeMode === 'standard') {
213
+ console.log(scaleMultiple, '===========landscape');
214
+ setScaleMultiple(-2);
215
+ } else {
216
+ // 竖屏时 将屏幕播放比例设为按宽按高
217
+
218
+ console.log(scaleMultiple, '===========landscape');
219
+ setScaleMultiple(playerFit === 'contain' ? scaleMultiple === 1 ? -1 : 1 : -2);
184
220
  }
185
221
  // 强制更改页面转向
186
222
  setPageOrientation({
@@ -193,12 +229,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
193
229
  }
194
230
  });
195
231
  }
196
- };
232
+ });
197
233
 
198
234
  /**
199
235
  * 监听屏幕布局变化
200
236
  */
201
237
  usePageEvent('onResize', useMemoizedFn(sizeData => {
238
+ var _ty4;
239
+ if (typeof ((_ty4 = ty) === null || _ty4 === void 0 ? void 0 : _ty4.onOrientationChange) === 'function') {
240
+ return;
241
+ }
202
242
  try {
203
243
  const {
204
244
  type
@@ -216,34 +256,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
216
256
  }
217
257
  // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
218
258
  if (type === 'landscape' && landscapeMode === 'fill') {
219
- // instance.IPCPlayerInstance.setObjectFit({
220
- // objectFit: 'fillCrop',
221
- // });
222
259
  console.log(scaleMultiple, '===========fill');
223
260
  setScaleMultiple(-1);
224
261
  } else if (type === 'landscape' && landscapeMode === 'standard') {
225
- // instance.IPCPlayerInstance.setObjectFit({
226
- // objectFit: 'contain',
227
- // });
228
- // setTimeout(() => {
229
- // console.log('dsahdjsahjdhsajhdjh==');
230
- // instance.IPCPlayerInstance.setScaleMultiple({
231
- // scaleMultiple: -2,
232
- // });
233
- // }, 3000);
234
262
  console.log(scaleMultiple, '===========landscape');
235
263
  setScaleMultiple(-2);
236
264
  } else {
237
265
  // 竖屏时 将屏幕播放比例设为按宽按高
238
- // console.log(verticalZoomLevel, 'verticalZoomLevel======');
239
- // instance.IPCPlayerInstance.setScaleMultiple({
240
- // scaleMultiple: playerFit === 'contain' ? -1 : -2,
241
- // });
266
+
242
267
  console.log(scaleMultiple, '===========landscape');
243
268
  setScaleMultiple(playerFit === 'contain' ? scaleMultiple === 1 ? -1 : 1 : -2);
244
- // instance.IPCPlayerInstance.setObjectFit({
245
- // objectFit: playerFit === 'contain' ? 'fillCrop' : 'contain',
246
- // });
247
269
  }
248
270
  } catch (err) {
249
271
  console.log(err, 'err');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.18-beta-3",
3
+ "version": "0.0.18-beta-5",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [