@ray-js/ipc-player-integration 0.0.53-beta.5 → 0.0.53-beta.6

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
@@ -12,7 +12,7 @@ import { changeIgnoreHideStopPreview } from '../ui/constant';
12
12
  import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
13
13
  import { getEventInstance } from './event';
14
14
  import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
15
- import { isClarityChangedSupported } from '../utils/ttt';
15
+ import { isClarityChangedSupported, subscribeClarityChanged } from '../utils/ttt';
16
16
  const SAVE_TO_ALBUM = 1;
17
17
  export const createUseCtx = _ref => {
18
18
  let {
@@ -75,6 +75,8 @@ export const createUseCtx = _ref => {
75
75
  const [resolution] = useAtom('HD');
76
76
  // resolution 清晰度列表
77
77
  const [resolutionList, setResolutionList] = useAtom([]);
78
+ // 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
79
+ const [autoClarity] = useAtom(null);
78
80
 
79
81
  // 单向对讲还是双向对讲
80
82
  const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
@@ -102,10 +104,19 @@ export const createUseCtx = _ref => {
102
104
  const [bottomRightContent] = useAtom(initBottomRightContent || defaultBottomRightContent || []);
103
105
  const [absoluteContent] = useAtom(initAbsoluteContent || defaultAbsoluteContent || []);
104
106
  const {
105
- _playState
107
+ _playState,
108
+ currentResolution
106
109
  } = useStore({
107
- _playState: playState
110
+ _playState: playState,
111
+ currentResolution: resolution
108
112
  });
113
+ useEffect(() => {
114
+ updateAtom(autoClarity, null);
115
+ if (currentResolution !== ClarityType.AUTO || !devId) return undefined;
116
+ return subscribeClarityChanged(devId, res => {
117
+ updateAtom(autoClarity, res.clarity);
118
+ });
119
+ }, [autoClarity, currentResolution, devId]);
109
120
  const eventRef = useRef();
110
121
  if (!eventRef.current) {
111
122
  eventRef.current = getEventInstance();
@@ -325,6 +336,7 @@ export const createUseCtx = _ref => {
325
336
  mute,
326
337
  resolution,
327
338
  resolutionList,
339
+ autoClarity,
328
340
  intercom,
329
341
  intercomMode,
330
342
  intercomSupported,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { PrimitiveAtom } from 'jotai';
3
+ import type { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
3
4
  import type { Toast, IntercomMode } from './ports.output';
4
5
  import { useMultiCameraCtx } from './ctx/multiCameraCtx';
5
6
  import type { ZoomSkill } from './widgets/zoomTurntable/lensSkill';
@@ -74,6 +75,7 @@ export type UseCtx = (options: {
74
75
  setZoomLensIndex: (value: number) => void;
75
76
  resolution: RetAtom<string>;
76
77
  resolutionList: RetAtom<string[]>;
78
+ autoClarity: RetAtom<ClarityType | null>;
77
79
  playState: RetAtom<PlayState>;
78
80
  IPCPlayerInstance: IpcContext;
79
81
  topLeftContent: RetAtom<ComponentConfig[]>;
@@ -60,12 +60,6 @@ export declare const widgetLabs: {
60
60
  */
61
61
  export declare const bottomLeftContentResize = "bottomLeftContentResize";
62
62
  export declare const zoomLevelChange = "zoomLevelChange";
63
- /**
64
- * 自动清晰度状态变化事件:Resolution 控件检测到清晰度进入/退出自动模式或收到
65
- * onClarityChanged 事件时触发,携带 { enabled, clarity }(clarity 为 ClarityType | null)。
66
- * VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
67
- */
68
- export declare const autoClarityChange = "autoClarityChange";
69
63
  export declare const setScaleMultipleEvent = "setScaleMultipleEvent";
70
64
  export declare const decodeClarityDic: {
71
65
  SS: string;
@@ -63,13 +63,6 @@ export const widgetLabs = {
63
63
  */
64
64
  export const bottomLeftContentResize = 'bottomLeftContentResize';
65
65
  export const zoomLevelChange = 'zoomLevelChange';
66
-
67
- /**
68
- * 自动清晰度状态变化事件:Resolution 控件检测到清晰度进入/退出自动模式或收到
69
- * onClarityChanged 事件时触发,携带 { enabled, clarity }(clarity 为 ClarityType | null)。
70
- * VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
71
- */
72
- export const autoClarityChange = 'autoClarityChange';
73
66
  export const setScaleMultipleEvent = 'setScaleMultipleEvent';
74
67
  export const decodeClarityDic = {
75
68
  SS: 'ss',
@@ -1,19 +1,16 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import React, { useContext, useEffect, useRef } from 'react';
4
+ import React, { useContext } from 'react';
5
5
  import { useMemoizedFn } from 'ahooks';
6
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
7
6
  import Strings from '../../i18n';
8
7
  import { FullResolutionControl } from './fullResolutionControl';
9
- import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick, autoClarityChange } from '../../ui/constant';
8
+ import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick } from '../../ui/constant';
10
9
  import { UIEventContext } from '../../ui/context';
11
10
  import { useStore } from '../../ctx/store';
12
- import { subscribeClarityChanged } from '../../utils/ttt';
13
11
  import './resolution.less';
14
12
  export const Resolution = props => {
15
13
  const {
16
- devId,
17
14
  setResolution,
18
15
  addContent,
19
16
  hasContent,
@@ -31,30 +28,6 @@ export const Resolution = props => {
31
28
  const {
32
29
  event
33
30
  } = useContext(UIEventContext);
34
- const autoClarityRef = useRef(null);
35
-
36
- // 广播自动清晰度状态给 VideoBitKBP 等监听方;
37
- // 自动模式下监听当前实际清晰度,仅用于码率区域展示。
38
- useEffect(() => {
39
- const emitClarity = (enabled, clarity) => {
40
- event.emit(autoClarityChange, {
41
- enabled,
42
- clarity
43
- });
44
- };
45
- if (resolution !== ClarityType.AUTO) {
46
- autoClarityRef.current = null;
47
- emitClarity(false, null);
48
- return undefined;
49
- }
50
- // 横竖屏切换会重新布局码率区域,重放最近一次实际清晰度,避免前缀丢失。
51
- emitClarity(true, autoClarityRef.current);
52
- if (!devId) return undefined;
53
- return subscribeClarityChanged(devId, res => {
54
- autoClarityRef.current = res.clarity;
55
- emitClarity(true, res.clarity);
56
- });
57
- }, [devId, event, resolution, screenType]);
58
31
  const onResolution = useMemoizedFn(() => {
59
32
  event.emit(widgetClick, {
60
33
  widgetId: widgetLabs.RESOLUTION
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { View, Text, usePageEvent } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { getVideoBitrateKbps, requestWifiSignal } from '@ray-js/ray-ipc-utils';
@@ -7,8 +7,6 @@ import { PlayState } from '../../interface';
7
7
  import './videoBitKBP.less';
8
8
  import { useStore } from '../../ctx/store';
9
9
  import Strings from '../../i18n';
10
- import { UIEventContext } from '../../ui/context';
11
- import { autoClarityChange } from '../../ui/constant';
12
10
  export const VideoBitKBP = props => {
13
11
  const {
14
12
  devId,
@@ -19,31 +17,12 @@ export const VideoBitKBP = props => {
19
17
  } = props;
20
18
  const [bitKBP, setBitKBP] = useState('');
21
19
  const [signalStrength, setSignalStrength] = useState(null);
22
- // 自动清晰度当前实际档位:null 表示未开启自动模式,不展示
23
- const [autoClarity, setAutoClarity] = useState(null);
24
20
  const store = useStore({
25
21
  playState,
26
- resolution: props.resolution
22
+ resolution: props.resolution,
23
+ autoClarity: props.autoClarity
27
24
  });
28
- const {
29
- event
30
- } = useContext(UIEventContext);
31
25
  const timerRef = useRef();
32
- // 监听 Resolution 控件广播的自动清晰度状态
33
- useEffect(() => {
34
- const onAutoClarityChange = payload => {
35
- setAutoClarity(payload.enabled ? payload.clarity : null);
36
- };
37
- event.on(autoClarityChange, onAutoClarityChange);
38
- return () => {
39
- event.off(autoClarityChange, onAutoClarityChange);
40
- };
41
- }, [event]);
42
- useEffect(() => {
43
- if (store.resolution !== ClarityType.AUTO) {
44
- setAutoClarity(null);
45
- }
46
- }, [store.resolution]);
47
26
  useEffect(() => {
48
27
  if (store.playState === PlayState.PLAYING && (!hideKbsMenu || !hideSignalMenu)) {
49
28
  init();
@@ -79,6 +58,7 @@ export const VideoBitKBP = props => {
79
58
  };
80
59
  const hasKbps = !hideKbsMenu && bitKBP !== '' && bitKBP !== '0';
81
60
  const hasSignal = !hideSignalMenu && signalStrength !== null;
61
+ const activeClarity = store.resolution === ClarityType.AUTO ? store.autoClarity : null;
82
62
  if (!hasKbps && !hasSignal || store.playState !== PlayState.PLAYING) {
83
63
  return null;
84
64
  }
@@ -100,7 +80,7 @@ export const VideoBitKBP = props => {
100
80
  className: "ipc-player-plugin-videoBitKBP-divider"
101
81
  }), hasKbps && /*#__PURE__*/React.createElement(View, {
102
82
  className: "ipc-player-plugin-videoBitKBP-kbps"
103
- }, autoClarity && /*#__PURE__*/React.createElement(Text, {
83
+ }, activeClarity && /*#__PURE__*/React.createElement(Text, {
104
84
  className: "ipc-player-plugin-videoBitKBP-clarity"
105
85
  }, (clarity => {
106
86
  switch (clarity) {
@@ -121,7 +101,7 @@ export const VideoBitKBP = props => {
121
101
  default:
122
102
  return clarity;
123
103
  }
124
- })(autoClarity)), /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
104
+ })(activeClarity)), /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
125
105
  className: "ipc-player-plugin-videoBitKBP-unit-kbs"
126
106
  }, "KB/S"))));
127
107
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.53-beta.5",
3
+ "version": "0.0.53-beta.6",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [