@ray-js/ipc-player-integration 0.0.54 → 0.0.55-beta.0

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 (31) hide show
  1. package/lib/ctx/ctx.js +20 -144
  2. package/lib/i18n/index.d.ts +0 -20
  3. package/lib/i18n/strings.d.ts +0 -10
  4. package/lib/i18n/strings.js +0 -10
  5. package/lib/interface.d.ts +1 -3
  6. package/lib/ui/ui.js +2 -43
  7. package/lib/utils/authorize/album.d.ts +1 -0
  8. package/lib/utils/authorize/album.js +39 -0
  9. package/lib/utils/authorize/album.test.js +82 -0
  10. package/lib/utils/ttt.d.ts +0 -26
  11. package/lib/utils/ttt.js +2 -112
  12. package/lib/widgets/recordVideo/recordVideo.js +5 -1
  13. package/lib/widgets/recordVideo/recordVideo.test.js +58 -0
  14. package/lib/widgets/resolution/resolution.js +1 -0
  15. package/lib/widgets/screenshot/screenshot.js +20 -71
  16. package/lib/widgets/videoBitKBP/videoBitKBP.js +12 -42
  17. package/lib/widgets/videoBitKBP/videoBitKBP.less +8 -17
  18. package/lib/widgets/zoomTurntable/lensSkill.js +4 -1
  19. package/package.json +2 -2
  20. package/lib/ctx/ctx.autoClarity.test.js +0 -150
  21. package/lib/ui/useOfflineShownNotification.d.ts +0 -1
  22. package/lib/ui/useOfflineShownNotification.js +0 -32
  23. package/lib/ui/useOfflineShownNotification.test.js +0 -98
  24. package/lib/utils/ttt.autoClarity.test.d.ts +0 -1
  25. package/lib/utils/ttt.autoClarity.test.js +0 -75
  26. package/lib/utils/ttt.notifyOfflineShown.test.d.ts +0 -1
  27. package/lib/utils/ttt.notifyOfflineShown.test.js +0 -30
  28. package/lib/widgets/videoBitKBP/videoBitKBP.test.d.ts +0 -1
  29. package/lib/widgets/videoBitKBP/videoBitKBP.test.js +0 -156
  30. /package/lib/{ctx/ctx.autoClarity.test.d.ts → utils/authorize/album.test.d.ts} +0 -0
  31. /package/lib/{ui/useOfflineShownNotification.test.d.ts → widgets/recordVideo/recordVideo.test.d.ts} +0 -0
package/lib/ctx/ctx.js CHANGED
@@ -6,13 +6,13 @@ import "core-js/modules/esnext.iterator.map.js";
6
6
  import { useRef, useCallback, useEffect } from 'react';
7
7
  import { getSystemInfoSync, showModal, openAppSystemSettingPage } from '@ray-js/ray';
8
8
  import Strings from '../i18n';
9
+ import { ensureAlbumPermission } from '../utils/authorize/album';
9
10
  import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
10
11
  import { PlayState, IntercomMode } from '../interface';
11
12
  import { changeIgnoreHideStopPreview } from '../ui/constant';
12
13
  import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
13
14
  import { getEventInstance } from './event';
14
15
  import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
15
- import { getCachedAutoClarity, isClarityChangedSupported, setCachedAutoClarity, subscribeClarityChanged } from '../utils/ttt';
16
16
  const SAVE_TO_ALBUM = 1;
17
17
  export const createUseCtx = _ref => {
18
18
  let {
@@ -73,8 +73,6 @@ export const createUseCtx = _ref => {
73
73
  const [resolution] = useAtom('HD');
74
74
  // resolution 清晰度列表
75
75
  const [resolutionList, setResolutionList] = useAtom([]);
76
- // 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
77
- const [autoClarity] = useAtom(null);
78
76
 
79
77
  // 单向对讲还是双向对讲
80
78
  const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
@@ -102,67 +100,14 @@ export const createUseCtx = _ref => {
102
100
  const [bottomRightContent] = useAtom(initBottomRightContent || defaultBottomRightContent || []);
103
101
  const [absoluteContent] = useAtom(initAbsoluteContent || defaultAbsoluteContent || []);
104
102
  const {
105
- _playState,
106
- currentResolution
103
+ _playState
107
104
  } = useStore({
108
- _playState: playState,
109
- currentResolution: resolution
105
+ _playState: playState
110
106
  });
111
- const restoredAutoRef = useRef(false);
112
- const refreshedAutoRef = useRef(false);
113
- const freshAutoClarityRef = useRef(false);
114
- const pendingAutoSelectionRef = useRef(false);
115
- const userSelectedResolutionRef = useRef(false);
116
- useEffect(() => {
117
- updateAtom(autoClarity, null);
118
- restoredAutoRef.current = false;
119
- refreshedAutoRef.current = false;
120
- freshAutoClarityRef.current = false;
121
- userSelectedResolutionRef.current = false;
122
- if (!devId) return undefined;
123
- return subscribeClarityChanged(devId, res => {
124
- if (getDefaultStore().get(resolution) !== ClarityType.AUTO && !pendingAutoSelectionRef.current) {
125
- return;
126
- }
127
- freshAutoClarityRef.current = true;
128
- updateAtom(autoClarity, res.clarity);
129
- setCachedAutoClarity(devId, res.clarity);
130
- });
131
- }, [autoClarity, devId, resolution]);
132
107
  const eventRef = useRef();
133
108
  if (!eventRef.current) {
134
109
  eventRef.current = getEventInstance();
135
110
  }
136
-
137
- /**
138
- * 只有宿主支持自动清晰度事件,且接口返回的清晰度档位数量不少于 2 个时,才展示 AUTO:
139
- * 竖屏宿主弹框(由 resolutionList 构建 actionData)与横屏 FullResolutionControl 共用。
140
- */
141
- const canShowAutoClarity = function () {
142
- let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
143
- return isClarityChangedSupported() && list.length >= 2;
144
- };
145
- const withAutoClarity = function () {
146
- let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
147
- const withoutAuto = list.filter(clarity => clarity !== ClarityType.AUTO);
148
- return canShowAutoClarity(list) ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
149
- };
150
- const normalizeResolution = (resolution, list) => {
151
- if (resolution !== ClarityType.AUTO || canShowAutoClarity(list)) return resolution;
152
- return list.find(clarity => clarity !== ClarityType.AUTO) || ClarityType.HD;
153
- };
154
- const restoreResolution = (cachedResolution, list) => {
155
- if (userSelectedResolutionRef.current) return;
156
- const target = normalizeResolution(cachedResolution, list);
157
- if (target === ClarityType.AUTO) {
158
- restoredAutoRef.current = true;
159
- const cachedClarity = getCachedAutoClarity(devId);
160
- if (cachedClarity && list.includes(cachedClarity) && !getDefaultStore().get(autoClarity)) {
161
- updateAtom(autoClarity, cachedClarity);
162
- }
163
- }
164
- _setResolution(target, true);
165
- };
166
111
  useEffect(() => {
167
112
  // 初始化获取缓存值
168
113
 
@@ -171,8 +116,8 @@ export const createUseCtx = _ref => {
171
116
  try {
172
117
  var _res$maxZoomSettings;
173
118
  const res = await getMemoryState(devId);
174
- setResolutionList(withAutoClarity(res.resolutionList));
175
- restoreResolution(res.resolution, res.resolutionList);
119
+ setResolutionList(res.resolutionList);
120
+ _setResolution(res.resolution, true);
176
121
  _setMute(res.mute, true);
177
122
  setIntercomMode(res.intercomMode);
178
123
  setIntercomSupported(res.isIntercomSupported);
@@ -187,9 +132,9 @@ export const createUseCtx = _ref => {
187
132
  // 获取缓存的值且同步
188
133
  getMemoryState(devId).then(res => {
189
134
  var _res$maxZoomSettings2;
190
- setResolutionList(withAutoClarity(res.resolutionList));
135
+ setResolutionList(res.resolutionList);
191
136
  // 传true表示值即可,会取播放器的值
192
- restoreResolution(res.resolution, res.resolutionList);
137
+ _setResolution(res.resolution, true);
193
138
  _setMute(res.mute, true);
194
139
  setIntercomMode(res.intercomMode);
195
140
  setIntercomSupported(res.isIntercomSupported);
@@ -197,18 +142,6 @@ export const createUseCtx = _ref => {
197
142
  });
198
143
  }
199
144
  }, [devId, _playState]);
200
- useEffect(() => {
201
- var _IPCPlayerInstance$cu;
202
- if (!devId || _playState !== PlayState.PLAYING || currentResolution !== ClarityType.AUTO || !restoredAutoRef.current || freshAutoClarityRef.current || refreshedAutoRef.current) {
203
- return;
204
- }
205
- refreshedAutoRef.current = true;
206
- // 缓存只保证首屏有上次档位;出流后重申自动,让宿主回报本次实际档位。
207
- (_IPCPlayerInstance$cu = IPCPlayerInstance.current) === null || _IPCPlayerInstance$cu === void 0 || _IPCPlayerInstance$cu.setClarity({
208
- clarity: 'auto',
209
- fail: error => console.warn('res===restore auto clarity fail', error)
210
- });
211
- }, [devId, _playState, currentResolution]);
212
145
  // 获取content数据
213
146
  const getContent = () => {
214
147
  const store = getDefaultStore();
@@ -303,33 +236,15 @@ export const createUseCtx = _ref => {
303
236
  updateAtom(resolution, target);
304
237
  return false;
305
238
  }
306
- userSelectedResolutionRef.current = true;
307
- // 清晰度事件可能在 setClarity 的 success 回调前到达,进入自动前先清掉上次的值。
308
- restoredAutoRef.current = false;
309
- if (target === ClarityType.AUTO) {
310
- pendingAutoSelectionRef.current = true;
311
- updateAtom(autoClarity, null);
312
- }
313
239
  return new Promise((resolve, reject) => {
314
- const clarityMap = {
315
- [ClarityType.SS]: 'ss',
316
- [ClarityType.SD]: 'normal',
317
- [ClarityType.HD]: 'hd',
318
- [ClarityType.UD]: 'ud',
319
- [ClarityType.SSP]: 'ssp',
320
- [ClarityType.AUTO]: 'auto',
321
- [ClarityType.AUDIO]: 'audio'
322
- };
323
240
  IPCPlayerInstance.current.setClarity({
324
- clarity: clarityMap[target] || 'normal',
241
+ clarity: target === ClarityType.HD ? 'hd' : 'normal',
325
242
  success: () => {
326
- pendingAutoSelectionRef.current = false;
327
243
  setResolutionMemoryState(devId, target);
328
244
  updateAtom(resolution, target);
329
245
  resolve(true);
330
246
  },
331
247
  fail: err => {
332
- pendingAutoSelectionRef.current = false;
333
248
  console.log(err, 'setClarity err');
334
249
  // updateAtom(mute, !target);
335
250
  reject(err);
@@ -356,7 +271,6 @@ export const createUseCtx = _ref => {
356
271
  mute,
357
272
  resolution,
358
273
  resolutionList,
359
- autoClarity,
360
274
  intercom,
361
275
  intercomMode,
362
276
  intercomSupported,
@@ -491,60 +405,22 @@ export const createUseCtx = _ref => {
491
405
  eventRef.current.emit(changeIgnoreHideStopPreview, false);
492
406
  return false;
493
407
  }
408
+ if (target) {
409
+ const granted = await ensureAlbumPermission();
410
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
411
+ if (!granted) return false;
412
+ }
494
413
  return new Promise((resolve, reject) => {
495
414
  if (target) {
496
- // 写入相册
497
- ty.authorizeStatus({
498
- scope: 'scope.writePhotosAlbum',
415
+ IPCPlayerInstance.current.startRecord({
416
+ saveToAlbum,
499
417
  success: () => {
500
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
501
- IPCPlayerInstance.current.startRecord({
502
- saveToAlbum,
503
- success: () => {
504
- updateAtom(recording, true);
505
- resolve(true);
506
- },
507
- fail: err => {
508
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
509
- reject(err);
510
- }
511
- });
418
+ updateAtom(recording, true);
419
+ resolve(true);
512
420
  },
513
- fail: () => {
514
- ty.authorize({
515
- scope: 'scope.writePhotosAlbum',
516
- success: () => {
517
- IPCPlayerInstance.current.startRecord({
518
- saveToAlbum,
519
- success: () => {
520
- updateAtom(recording, true);
521
- resolve(true);
522
- },
523
- fail: err => {
524
- reject(err);
525
- }
526
- });
527
- },
528
- fail: () => {
529
- showModal({
530
- title: '',
531
- content: Strings.getLang('ipc_player_no_album_permission'),
532
- cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
533
- confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
534
- isShowGlobal: true,
535
- success: res => {
536
- if (res.confirm) {
537
- openAppSystemSettingPage({
538
- scope: 'App-Settings',
539
- success: () => {
540
- console.log('跳转成功');
541
- }
542
- });
543
- }
544
- }
545
- });
546
- }
547
- });
421
+ fail: err => {
422
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
423
+ reject(err);
548
424
  }
549
425
  });
550
426
  } else {
@@ -1,13 +1,8 @@
1
1
  import { kit } from '@ray-js/panel-sdk';
2
2
  declare const Strings: kit.I18N<{
3
3
  en: {
4
- ipc_player_resolution_SS: string;
5
4
  ipc_player_resolution_HD: string;
6
5
  ipc_player_resolution_SD: string;
7
- ipc_player_resolution_UD: string;
8
- ipc_player_resolution_SSP: string;
9
- ipc_player_resolution_AUTO: string;
10
- ipc_player_resolution_AUDIO: string;
11
6
  ipc_player_current_resolution_is_equal: string;
12
7
  ipc_player_screenshot_success_tip: string;
13
8
  ipc_player_error_screenshot_error_tip: string;
@@ -43,13 +38,8 @@ declare const Strings: kit.I18N<{
43
38
  ipc_player_low_phone_not_support: string;
44
39
  };
45
40
  zh: {
46
- ipc_player_resolution_SS: string;
47
41
  ipc_player_resolution_HD: string;
48
42
  ipc_player_resolution_SD: string;
49
- ipc_player_resolution_UD: string;
50
- ipc_player_resolution_SSP: string;
51
- ipc_player_resolution_AUTO: string;
52
- ipc_player_resolution_AUDIO: string;
53
43
  ipc_player_current_resolution_is_equal: string;
54
44
  ipc_player_screenshot_success_tip: string;
55
45
  ipc_player_error_screenshot_error_tip: string;
@@ -85,13 +75,8 @@ declare const Strings: kit.I18N<{
85
75
  ipc_player_low_phone_not_support: string;
86
76
  };
87
77
  }, {
88
- ipc_player_resolution_SS: string;
89
78
  ipc_player_resolution_HD: string;
90
79
  ipc_player_resolution_SD: string;
91
- ipc_player_resolution_UD: string;
92
- ipc_player_resolution_SSP: string;
93
- ipc_player_resolution_AUTO: string;
94
- ipc_player_resolution_AUDIO: string;
95
80
  ipc_player_current_resolution_is_equal: string;
96
81
  ipc_player_screenshot_success_tip: string;
97
82
  ipc_player_error_screenshot_error_tip: string;
@@ -126,13 +111,8 @@ declare const Strings: kit.I18N<{
126
111
  ipc_player_fetch_error: string;
127
112
  ipc_player_low_phone_not_support: string;
128
113
  } | {
129
- ipc_player_resolution_SS: string;
130
114
  ipc_player_resolution_HD: string;
131
115
  ipc_player_resolution_SD: string;
132
- ipc_player_resolution_UD: string;
133
- ipc_player_resolution_SSP: string;
134
- ipc_player_resolution_AUTO: string;
135
- ipc_player_resolution_AUDIO: string;
136
116
  ipc_player_current_resolution_is_equal: string;
137
117
  ipc_player_screenshot_success_tip: string;
138
118
  ipc_player_error_screenshot_error_tip: string;
@@ -1,12 +1,7 @@
1
1
  declare const _default: {
2
2
  en: {
3
- ipc_player_resolution_SS: string;
4
3
  ipc_player_resolution_HD: string;
5
4
  ipc_player_resolution_SD: string;
6
- ipc_player_resolution_UD: string;
7
- ipc_player_resolution_SSP: string;
8
- ipc_player_resolution_AUTO: string;
9
- ipc_player_resolution_AUDIO: string;
10
5
  ipc_player_current_resolution_is_equal: string;
11
6
  ipc_player_screenshot_success_tip: string;
12
7
  ipc_player_error_screenshot_error_tip: string;
@@ -42,13 +37,8 @@ declare const _default: {
42
37
  ipc_player_low_phone_not_support: string;
43
38
  };
44
39
  zh: {
45
- ipc_player_resolution_SS: string;
46
40
  ipc_player_resolution_HD: string;
47
41
  ipc_player_resolution_SD: string;
48
- ipc_player_resolution_UD: string;
49
- ipc_player_resolution_SSP: string;
50
- ipc_player_resolution_AUTO: string;
51
- ipc_player_resolution_AUDIO: string;
52
42
  ipc_player_current_resolution_is_equal: string;
53
43
  ipc_player_screenshot_success_tip: string;
54
44
  ipc_player_error_screenshot_error_tip: string;
@@ -1,12 +1,7 @@
1
1
  export default {
2
2
  en: {
3
- ipc_player_resolution_SS: 'Data Saver',
4
3
  ipc_player_resolution_HD: 'HD',
5
4
  ipc_player_resolution_SD: 'SD',
6
- ipc_player_resolution_UD: 'Ultra HD',
7
- ipc_player_resolution_SSP: 'Super Ultra HD',
8
- ipc_player_resolution_AUTO: 'Auto',
9
- ipc_player_resolution_AUDIO: 'Audio Mode',
10
5
  ipc_player_current_resolution_is_equal: 'Already at current clarity',
11
6
  ipc_player_screenshot_success_tip: 'Screenshot saved to album',
12
7
  ipc_player_error_screenshot_error_tip: 'Screenshot failed. Please try again later.',
@@ -42,13 +37,8 @@ export default {
42
37
  ipc_player_low_phone_not_support: 'This feature is not supported on this device'
43
38
  },
44
39
  zh: {
45
- ipc_player_resolution_SS: '省流量',
46
40
  ipc_player_resolution_HD: '高清',
47
41
  ipc_player_resolution_SD: '标清',
48
- ipc_player_resolution_UD: '超清',
49
- ipc_player_resolution_SSP: '超超清',
50
- ipc_player_resolution_AUTO: '自动',
51
- ipc_player_resolution_AUDIO: '音频模式',
52
42
  ipc_player_current_resolution_is_equal: '已是当前清晰度',
53
43
  ipc_player_screenshot_success_tip: '截图已保存在APP相册',
54
44
  ipc_player_error_screenshot_error_tip: '截图失败了,请稍后再试',
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { PrimitiveAtom } from 'jotai';
3
- import type { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
4
3
  import type { Toast, IntercomMode } from './ports.output';
5
4
  import { useMultiCameraCtx } from './ctx/multiCameraCtx';
6
5
  import type { ZoomSkill } from './widgets/zoomTurntable/lensSkill';
@@ -73,7 +72,6 @@ export type UseCtx = (options: {
73
72
  setZoomLensIndex: (value: number) => void;
74
73
  resolution: RetAtom<string>;
75
74
  resolutionList: RetAtom<string[]>;
76
- autoClarity: RetAtom<ClarityType | null>;
77
75
  playState: RetAtom<PlayState>;
78
76
  IPCPlayerInstance: IpcContext;
79
77
  topLeftContent: RetAtom<ComponentConfig[]>;
@@ -87,7 +85,7 @@ export type UseCtx = (options: {
87
85
  setVerticalMic: (value: boolean) => void;
88
86
  setScreenType: (type: ScreenType) => void;
89
87
  setRecordingDisabled: (type: boolean) => void;
90
- setResolution: (type: string) => Promise<boolean>;
88
+ setResolution: (type: string) => void;
91
89
  setResolutionList: (type: string[]) => void;
92
90
  setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<RecordInfoData>;
93
91
  setIntercom: (value: boolean, onlyUpdateAtom?: boolean) => Promise<boolean>;
package/lib/ui/ui.js CHANGED
@@ -1,17 +1,14 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
2
  import "core-js/modules/esnext.iterator.constructor.js";
4
3
  import "core-js/modules/esnext.iterator.filter.js";
5
4
  import "core-js/modules/esnext.iterator.find.js";
6
5
  import "core-js/modules/esnext.iterator.map.js";
7
- import "core-js/modules/esnext.iterator.some.js";
8
6
  import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
9
7
  import { View, CoverView, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation, getCurrentPages } from '@ray-js/ray';
10
8
  import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
11
9
  import clsx from 'clsx';
12
10
  import IPCPlayer from '@ray-js/ray-ipc-player';
13
11
  import { ipcTTTOperatorLog } from '@ray-js/ray-ipc-utils';
14
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
15
12
  import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interface';
16
13
  import { useCtx } from '../ctx/ctx.composition';
17
14
  import { useStore, updateAtom, getDefaultStore } from '../ctx/store';
@@ -21,44 +18,13 @@ import BottomLeftContent from './bottomLeftContent';
21
18
  import BottomRightContent from './bottomRightContent';
22
19
  import TopLeftContent from './topLeftContent';
23
20
  import TopRightContent from './topRightContent';
24
- import { useOfflineShownNotification } from './useOfflineShownNotification';
25
- import { FlowLowTip, VideoBitKBP } from '../widgets';
21
+ import { FlowLowTip } from '../widgets';
26
22
  import { useMemoizedFn } from '../hooks';
27
23
  import { Storage } from '../utils/storage';
28
24
  import './ui.less';
29
25
  import { updatePlayerWidgetProps } from '../features';
30
26
  import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
31
27
  import { lensCount } from '../widgets/zoomTurntable/lensSkill';
32
- const AutoClarityOnly = _ref => {
33
- let {
34
- instance
35
- } = _ref;
36
- return /*#__PURE__*/React.createElement(VideoBitKBP, _extends({}, instance, {
37
- IPCPlayerContext: instance.IPCPlayerInstance,
38
- className: "top-right-item-container",
39
- hideKbsMenu: true,
40
- hideSignalMenu: true
41
- }));
42
- };
43
- const StandaloneAutoClarity = _ref2 => {
44
- let {
45
- instance,
46
- show
47
- } = _ref2;
48
- const {
49
- resolution,
50
- autoClarity
51
- } = useStore({
52
- resolution: instance.resolution,
53
- autoClarity: instance.autoClarity
54
- });
55
- if (!show || resolution !== ClarityType.AUTO || !autoClarity) return null;
56
- return /*#__PURE__*/React.createElement(TopRightContent, {
57
- ctx: instance
58
- }, /*#__PURE__*/React.createElement(AutoClarityOnly, {
59
- instance: instance
60
- }));
61
- };
62
28
  function getCtxInstance(instance, devId) {
63
29
  if (instance) return instance;
64
30
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -184,7 +150,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
184
150
  isLowPhoneRef.current = !!res;
185
151
  });
186
152
  }, []);
187
- useOfflineShownNotification(devId, deviceOnline);
188
153
 
189
154
  // 展示顶部内容
190
155
  const [showTopContent, setShowTopContent] = useState(true);
@@ -1037,7 +1002,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1037
1002
  };
1038
1003
  }, []);
1039
1004
  const playerReady = playState === PlayState.PLAYING;
1040
- const hasVisibleBitrateWidget = topRightContent === null || topRightContent === void 0 ? void 0 : topRightContent.some(item => item.id === 'VideoBitKBP' && !item.hidden);
1041
1005
  /**
1042
1006
  * 监听当前的zoom比例状态
1043
1007
  */
@@ -1231,12 +1195,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1231
1195
  ctx: instance
1232
1196
  }, renderTopLeftContent), /*#__PURE__*/React.createElement(TopRightContent, {
1233
1197
  ctx: instance
1234
- }, renderTopRightContent, !hasVisibleBitrateWidget && /*#__PURE__*/React.createElement(AutoClarityOnly, {
1235
- instance: instance
1236
- })))), /*#__PURE__*/React.createElement(StandaloneAutoClarity, {
1237
- instance: instance,
1238
- show: !showTopContent || componentHideState || !playerReady
1239
- }), /*#__PURE__*/React.createElement(View, {
1198
+ }, renderTopRightContent))), /*#__PURE__*/React.createElement(View, {
1240
1199
  className: clsx('ipc-player-bottom-content', {
1241
1200
  'ipc-player-bottom-content-hide': componentHideState,
1242
1201
  'ipc-player-bottom-content-show': !componentHideState,
@@ -0,0 +1 @@
1
+ export declare function ensureAlbumPermission(): Promise<boolean>;
@@ -0,0 +1,39 @@
1
+ import { authorize, authorizeStatus, getSystemInfoSync, openAppSystemSettingPage, showModal } from '@ray-js/ray';
2
+ import Strings from '../../i18n';
3
+ export async function ensureAlbumPermission() {
4
+ var _system$match;
5
+ const {
6
+ platform,
7
+ system
8
+ } = getSystemInfoSync();
9
+ // Scoped storage does not require the legacy album permission to save media.
10
+ if (platform === 'android' && Number((_system$match = system.match(/\d+/)) === null || _system$match === void 0 ? void 0 : _system$match[0]) >= 10) return true;
11
+ const granted = await new Promise(resolve => {
12
+ authorizeStatus({
13
+ scope: 'scope.writePhotosAlbum',
14
+ success: () => resolve(true),
15
+ fail: () => {
16
+ authorize({
17
+ scope: 'scope.writePhotosAlbum',
18
+ success: () => resolve(true),
19
+ fail: () => resolve(false)
20
+ });
21
+ }
22
+ });
23
+ });
24
+ if (!granted) {
25
+ showModal({
26
+ title: '',
27
+ content: Strings.getLang('ipc_player_no_album_permission'),
28
+ cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
29
+ confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
30
+ isShowGlobal: true,
31
+ success: res => {
32
+ if (res.confirm) openAppSystemSettingPage({
33
+ scope: 'App-Settings'
34
+ });
35
+ }
36
+ });
37
+ }
38
+ return granted;
39
+ }
@@ -0,0 +1,82 @@
1
+ import { authorize, authorizeStatus, getSystemInfoSync, openAppSystemSettingPage, showModal } from '@ray-js/ray';
2
+ import { ensureAlbumPermission } from './album';
3
+ jest.mock('@ray-js/ray', () => ({
4
+ authorize: jest.fn(),
5
+ authorizeStatus: jest.fn(),
6
+ getSystemInfoSync: jest.fn(),
7
+ openAppSystemSettingPage: jest.fn(),
8
+ showModal: jest.fn()
9
+ }));
10
+ jest.mock('../../i18n', () => ({
11
+ __esModule: true,
12
+ default: {
13
+ getLang: key => key
14
+ }
15
+ }));
16
+ beforeEach(() => {
17
+ jest.resetAllMocks();
18
+ authorizeStatus.mockImplementation(_ref => {
19
+ let {
20
+ fail
21
+ } = _ref;
22
+ return fail({
23
+ errorCode: 9004
24
+ });
25
+ });
26
+ authorize.mockImplementation(_ref2 => {
27
+ let {
28
+ fail
29
+ } = _ref2;
30
+ return fail({
31
+ errorCode: 9004
32
+ });
33
+ });
34
+ });
35
+ describe('album permission', () => {
36
+ it.each(['android 10', 'android 12', 'android 15'])('allows native saving on %s without legacy storage access', async system => {
37
+ getSystemInfoSync.mockReturnValue({
38
+ platform: 'android',
39
+ system
40
+ });
41
+ expect(await ensureAlbumPermission()).toBe(true);
42
+ expect(authorizeStatus).not.toHaveBeenCalled();
43
+ expect(authorize).not.toHaveBeenCalled();
44
+ expect(showModal).not.toHaveBeenCalled();
45
+ });
46
+ it.each([['ios', 'iOS 18'], ['android', 'android 9'], ['android', 'unknown']])('keeps rejection handling on %s %s', async (platform, system) => {
47
+ getSystemInfoSync.mockReturnValue({
48
+ platform,
49
+ system
50
+ });
51
+ expect(await ensureAlbumPermission()).toBe(false);
52
+ expect(showModal).toHaveBeenCalledTimes(1);
53
+ const {
54
+ success
55
+ } = showModal.mock.calls[0][0];
56
+ success({
57
+ confirm: false
58
+ });
59
+ expect(openAppSystemSettingPage).not.toHaveBeenCalled();
60
+ success({
61
+ confirm: true
62
+ });
63
+ expect(openAppSystemSettingPage).toHaveBeenCalledWith({
64
+ scope: 'App-Settings'
65
+ });
66
+ });
67
+ it('allows saving after authorization and checks it again on retry', async () => {
68
+ getSystemInfoSync.mockReturnValue({
69
+ platform: 'ios',
70
+ system: 'iOS 18'
71
+ });
72
+ authorize.mockImplementationOnce(_ref3 => {
73
+ let {
74
+ success
75
+ } = _ref3;
76
+ return success();
77
+ });
78
+ expect(await ensureAlbumPermission()).toBe(true);
79
+ expect(await ensureAlbumPermission()).toBe(false);
80
+ expect(showModal).toHaveBeenCalledTimes(1);
81
+ });
82
+ });
@@ -1,4 +1,3 @@
1
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
2
1
  export type SmartImageQualityResult = {
3
2
  isPurchase: boolean;
4
3
  buttonState: number;
@@ -39,29 +38,4 @@ export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeat
39
38
  export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
40
39
  export declare function setTrailFinish(devId: string): Promise<unknown>;
41
40
  export declare function isLowPhone(): Promise<boolean>;
42
- /**
43
- * 通知宿主离线提示已经展示。
44
- *
45
- * 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
46
- * 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
47
- */
48
- export declare function notifyOfflineShown(deviceId: string): boolean;
49
41
  export declare function getNgRawData(): Promise<unknown>;
50
- export declare function isClarityChangedSupported(): boolean;
51
- export type ClarityChangedResult = {
52
- deviceId?: string;
53
- clarity: ClarityType;
54
- };
55
- export type ClarityChangedHandler = (result: ClarityChangedResult) => void;
56
- type ClarityChangedListener = (payload: ClarityChangedResult) => void;
57
- export declare function getCachedAutoClarity(devId: string): ClarityType | null;
58
- export declare function setCachedAutoClarity(devId: string, clarity: ClarityType): void;
59
- export declare function offClarityChanged(listener: ClarityChangedListener): void;
60
- /**
61
- * 监听自动清晰度变化,返回取消监听函数。
62
- *
63
- * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
64
- * 否则宿主无法正确移除监听。
65
- */
66
- export declare function subscribeClarityChanged(devId: string, handler: ClarityChangedHandler): () => void;
67
- export {};