@ray-js/ipc-player-integration 0.0.18-beta-1 → 0.0.18-beta-3
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.js +61 -43
- package/package.json +1 -1
package/lib/ui/ui.js
CHANGED
|
@@ -95,7 +95,29 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
95
95
|
// const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
|
|
96
96
|
// const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
|
|
97
97
|
|
|
98
|
+
const {
|
|
99
|
+
topLeftContent,
|
|
100
|
+
topRightContent,
|
|
101
|
+
bottomLeftContent,
|
|
102
|
+
bottomRightContent,
|
|
103
|
+
absoluteContent,
|
|
104
|
+
screenType,
|
|
105
|
+
playState,
|
|
106
|
+
resolution,
|
|
107
|
+
mute
|
|
108
|
+
} = useStore({
|
|
109
|
+
topLeftContent: instance.topLeftContent,
|
|
110
|
+
topRightContent: instance.topRightContent,
|
|
111
|
+
bottomLeftContent: instance.bottomLeftContent,
|
|
112
|
+
bottomRightContent: instance.bottomRightContent,
|
|
113
|
+
absoluteContent: instance.absoluteContent,
|
|
114
|
+
screenType: instance.screenType,
|
|
115
|
+
playState: instance.playState,
|
|
116
|
+
resolution: instance.resolution,
|
|
117
|
+
mute: instance.mute
|
|
118
|
+
});
|
|
98
119
|
useEffect(() => {
|
|
120
|
+
// 首次进来强制为竖屏
|
|
99
121
|
if (createCtx) {
|
|
100
122
|
// 获取屏幕方向比例
|
|
101
123
|
try {
|
|
@@ -112,24 +134,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
112
134
|
}
|
|
113
135
|
}
|
|
114
136
|
}, [createCtx]);
|
|
115
|
-
const handleOrientationChange = data => {
|
|
116
|
-
const {
|
|
117
|
-
orientation
|
|
118
|
-
} = data;
|
|
119
|
-
if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right'].includes(orientation)) {
|
|
120
|
-
setScreenType(orientation === 'landscape-left' || orientation === 'landscape-right' ? 'full' : 'vertical');
|
|
121
|
-
const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' ? 'landscape' : 'portrait';
|
|
122
|
-
setPageOrientation({
|
|
123
|
-
pageOrientation,
|
|
124
|
-
success: () => {
|
|
125
|
-
console.log('success');
|
|
126
|
-
},
|
|
127
|
-
fail: err => {
|
|
128
|
-
console.log('err', err);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
137
|
useEffect(() => {
|
|
134
138
|
var _ty2;
|
|
135
139
|
if (typeof ((_ty2 = ty) === null || _ty2 === void 0 ? void 0 : _ty2.onOrientationChange) === 'function') {
|
|
@@ -162,6 +166,35 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
162
166
|
* 监听播放器实例创建完成
|
|
163
167
|
*/
|
|
164
168
|
|
|
169
|
+
const handleOrientationChange = data => {
|
|
170
|
+
const {
|
|
171
|
+
orientation
|
|
172
|
+
} = data;
|
|
173
|
+
if (['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right'].includes(orientation)) {
|
|
174
|
+
// setScreenType(
|
|
175
|
+
// orientation === 'landscape-left' || orientation === 'landscape-right' ? 'full' : 'vertical'
|
|
176
|
+
// );
|
|
177
|
+
const pageOrientation = orientation === 'landscape-left' || orientation === 'landscape-right' ? 'landscape' : 'portrait';
|
|
178
|
+
const {
|
|
179
|
+
deviceType
|
|
180
|
+
} = systemInfo.current;
|
|
181
|
+
// 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
|
|
182
|
+
if (deviceType === 'pad') {
|
|
183
|
+
setScreenType('vertical');
|
|
184
|
+
}
|
|
185
|
+
// 强制更改页面转向
|
|
186
|
+
setPageOrientation({
|
|
187
|
+
pageOrientation,
|
|
188
|
+
success: () => {
|
|
189
|
+
console.log('success');
|
|
190
|
+
},
|
|
191
|
+
fail: err => {
|
|
192
|
+
console.log('err', err);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
165
198
|
/**
|
|
166
199
|
* 监听屏幕布局变化
|
|
167
200
|
*/
|
|
@@ -170,10 +203,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
170
203
|
const {
|
|
171
204
|
type
|
|
172
205
|
} = sizeData;
|
|
173
|
-
console.log(type, 'type');
|
|
174
206
|
console.log('监听到屏幕布局变化', type);
|
|
175
207
|
const {
|
|
176
|
-
platform,
|
|
177
208
|
deviceType
|
|
178
209
|
} = systemInfo.current;
|
|
179
210
|
// 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
|
|
@@ -249,27 +280,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
249
280
|
if (!systemInfo.current) {
|
|
250
281
|
systemInfo.current = getSystemInfoSync();
|
|
251
282
|
}
|
|
252
|
-
const {
|
|
253
|
-
topLeftContent,
|
|
254
|
-
topRightContent,
|
|
255
|
-
bottomLeftContent,
|
|
256
|
-
bottomRightContent,
|
|
257
|
-
absoluteContent,
|
|
258
|
-
screenType,
|
|
259
|
-
playState,
|
|
260
|
-
resolution,
|
|
261
|
-
mute
|
|
262
|
-
} = useStore({
|
|
263
|
-
topLeftContent: instance.topLeftContent,
|
|
264
|
-
topRightContent: instance.topRightContent,
|
|
265
|
-
bottomLeftContent: instance.bottomLeftContent,
|
|
266
|
-
bottomRightContent: instance.bottomRightContent,
|
|
267
|
-
absoluteContent: instance.absoluteContent,
|
|
268
|
-
screenType: instance.screenType,
|
|
269
|
-
playState: instance.playState,
|
|
270
|
-
resolution: instance.resolution,
|
|
271
|
-
mute: instance.mute
|
|
272
|
-
});
|
|
273
283
|
|
|
274
284
|
// 监听物理返回按键
|
|
275
285
|
const hackHandle = () => {
|
|
@@ -385,11 +395,19 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
385
395
|
if (playState !== PlayState.PLAYING) {
|
|
386
396
|
console.log('非播放状态=======');
|
|
387
397
|
console.log(currentZoomLevel, 'currentZoomLevel');
|
|
398
|
+
console.log(scaleMultiple, 'scaleMultiple');
|
|
399
|
+
console.log(hasPlayedRef.current, 'hasPlayedRef.current');
|
|
388
400
|
if (hasPlayedRef.current) {
|
|
389
401
|
setScaleMultiple(currentZoomLevel);
|
|
390
402
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
403
|
+
}
|
|
404
|
+
if (playState === PlayState.PLAYING) {
|
|
405
|
+
// 仅在第一次播放成功时,针对竖屏并且为cover模式时,设置为-2
|
|
406
|
+
console.log('Playing状态');
|
|
407
|
+
if (screenType === 'vertical' && playerFit === 'cover' && !hasPlayedRef.current) {
|
|
408
|
+
setScaleMultiple(-2);
|
|
409
|
+
hasPlayedRef.current = true;
|
|
410
|
+
}
|
|
393
411
|
}
|
|
394
412
|
setPlayState(playState);
|
|
395
413
|
(_props$onPlayStatus = props.onPlayStatus) === null || _props$onPlayStatus === void 0 || _props$onPlayStatus.call(props, {
|