@ray-js/ipc-player-integration 0.0.1-beta-61 → 0.0.1-beta-63

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.
@@ -1,8 +1,11 @@
1
+ /// <reference types="react" />
1
2
  import { UseCtx } from '../../interface';
3
+ import { FullScreen } from '../../widgets/fullScreen';
2
4
  type Ctx = ReturnType<UseCtx>;
3
5
  export declare function initPlayerWidgets(ctx: Ctx, options: {
4
6
  verticalResolutionCustomClick?: boolean;
5
7
  hideHorizontalMenu?: boolean;
6
8
  throttleTime?: number;
9
+ directionControlProps?: Partial<React.ComponentProps<typeof FullScreen>['directionControlProps']>;
7
10
  }): Promise<void>;
8
11
  export {};
@@ -21,7 +21,8 @@ export async function initPlayerWidgets(ctx, options) {
21
21
  // @ts-ignore
22
22
  newDefaultBottomRightContent[fullScreenIndex].initProps = {
23
23
  hideHorizontalMenu: options.hideHorizontalMenu,
24
- throttleTime: options.throttleTime
24
+ throttleTime: options.throttleTime,
25
+ directionControlProps: options.directionControlProps
25
26
  };
26
27
  }
27
28
  ctx.addContent('bottomRight', newDefaultBottomRightContent);
package/lib/ui/ui.js CHANGED
@@ -3,7 +3,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import "core-js/modules/esnext.iterator.constructor.js";
4
4
  import "core-js/modules/esnext.iterator.map.js";
5
5
  import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
6
- import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
6
+ import { View, CoverView, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation } from '@ray-js/ray';
7
7
  import clsx from 'clsx';
8
8
  import IPCPlayer from '@ray-js/ray-ipc-player';
9
9
  import { PlayState, PlayerStreamStatus } from '../interface';
@@ -74,7 +74,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
74
74
  这里用一个统一的状态标志期望控件是否展示
75
75
  */
76
76
  const [componentHideState, setComponentHideState] = useState(false);
77
- const [showRightContent, setShowRightContent] = useState(true);
78
77
  prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
79
78
  const eventRef = useRef(instance.event);
80
79
  if (eventRef.current !== instance.event) {
@@ -88,11 +87,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
88
87
  setBrandColor(brandColor);
89
88
  setVerticalMic(verticalMic);
90
89
  }, []);
91
- const refreshBottomLeft = value => {
90
+ const refreshBottomLeft = () => {
92
91
  event.current.emit(startTimeToHideAllComponent);
93
92
  event.current.emit(showAllComponent);
94
93
  event.current.emit(playerTap);
95
- setShowRightContent(value);
96
94
  };
97
95
 
98
96
  /**
@@ -154,6 +152,43 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
154
152
  mute: instance.mute
155
153
  });
156
154
 
155
+ // 监听物理返回按键
156
+ const hackHandle = () => {
157
+ setPageOrientation({
158
+ pageOrientation: 'portrait',
159
+ success: () => {
160
+ console.log('set success');
161
+ }
162
+ });
163
+ setScreenType('vertical');
164
+ };
165
+ useEffect(() => {
166
+ // 针对安卓使用系统按键导航
167
+ if (screenType === 'full') {
168
+ const {
169
+ platform
170
+ } = getSystemInfoSync();
171
+ if (platform !== 'ios') {
172
+ setNavigationBarBack({
173
+ type: 'custom'
174
+ });
175
+ }
176
+ } else {
177
+ setNavigationBarBack({
178
+ type: 'system'
179
+ });
180
+ }
181
+ }, [screenType]);
182
+ useEffect(() => {
183
+ ty.onNavigationBarBack(hackHandle);
184
+ return () => {
185
+ ty.offNavigationBarBack(hackHandle);
186
+ setNavigationBarBack({
187
+ type: 'system'
188
+ });
189
+ };
190
+ }, []);
191
+
157
192
  /**
158
193
  * 渲染随机定位播放器内容
159
194
  */
@@ -5,6 +5,6 @@ import type { ComponentConfigProps } from '../../interface';
5
5
  type Props = ComponentConfigProps & {
6
6
  className?: string;
7
7
  hideHorizontalMenu?: boolean;
8
- } & Pick<FullTravelRouteControlProps, 'throttleTime'>;
8
+ } & Pick<FullTravelRouteControlProps, 'throttleTime' | 'directionControlProps'>;
9
9
  export declare function FullScreen(props: Props): React.JSX.Element | null;
10
10
  export {};
@@ -2,8 +2,12 @@
2
2
  * 全屏状态下要添加的摄像机行进路线控件
3
3
  */
4
4
  import React from 'react';
5
+ import RectDirectionControl from '@ray-js/direction-control';
5
6
  import type { ComponentConfigProps } from '../../interface';
7
+ type RectDirectionControlProps = React.ComponentProps<typeof RectDirectionControl>;
6
8
  export type FullTravelRouteControlProps = ComponentConfigProps & {
7
9
  throttleTime?: number;
10
+ directionControlProps?: Partial<RectDirectionControlProps>;
8
11
  };
9
12
  export declare function FullTravelRouteControl(props: FullTravelRouteControlProps): React.JSX.Element;
13
+ export {};
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  /**
2
3
  * 全屏状态下要添加的摄像机行进路线控件
3
4
  */
@@ -15,7 +16,8 @@ import { DIRECTION_CONTROL_DP_CODE } from './constant';
15
16
  import { useStore } from '../../ctx/store';
16
17
  export function FullTravelRouteControl(props) {
17
18
  const {
18
- throttleTime = 300
19
+ throttleTime = 300,
20
+ directionControlProps
19
21
  } = props;
20
22
  const [shouldHide] = useComponentHideState();
21
23
  const [isPtzActive, setIsPtzActive] = useState(false);
@@ -29,13 +31,11 @@ export function FullTravelRouteControl(props) {
29
31
  brandColor: props.brandColor
30
32
  });
31
33
  const timerRef = useRef();
32
- const [touching, setTouching] = useState(false);
33
34
  const [state, _, sendDp] = useDpState({
34
35
  devId: props.devId,
35
36
  dpCodes: [DIRECTION_CONTROL_DP_CODE],
36
37
  listenDpChange: true
37
38
  });
38
- console.log('touching', touching);
39
39
  const onPtzControlShow = useMemoizedFn(() => {
40
40
  setIsPtzActive(true);
41
41
  });
@@ -75,28 +75,24 @@ export function FullTravelRouteControl(props) {
75
75
  return /*#__PURE__*/React.createElement(View, {
76
76
  className: clsx('ipc-player-plugin-full-screen-voice', {
77
77
  'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive
78
- }),
79
- style: {
80
- width: touching ? '100vw' : 'auto',
81
- height: touching ? '100vh' : 'auto',
82
- backgroundColor: 'transparent'
83
- }
84
- }, /*#__PURE__*/React.createElement(RectDirectionControl, {
78
+ })
79
+ }, /*#__PURE__*/React.createElement(RectDirectionControl, _extends({
85
80
  className: "ipc-plugin-full-travel-route-control",
86
81
  value: 0,
87
82
  onTouchStart: value => {
88
- setTouching(true);
83
+ pauseTimeToHideAllComponentFn();
89
84
  sendDpValue(String(value));
85
+ ty.nativeDisabled(true);
90
86
  },
91
87
  onTouchMove: value => {
92
- setTouching(true);
93
88
  pauseTimeToHideAllComponentFn();
94
89
  sendDpValue(String(value));
90
+ ty.nativeDisabled(true);
95
91
  },
96
92
  onTouchEnd: () => {
97
93
  event.emit(startTimeToHideAllComponent);
98
- setTouching(false);
99
94
  sendDpValue('-1');
95
+ ty.nativeDisabled(false);
100
96
  },
101
97
  onMoveNonIntersection: () => {
102
98
  sendDpValue('-1');
@@ -104,5 +100,5 @@ export function FullTravelRouteControl(props) {
104
100
  showArcOnTouchInEdgeProximity: true,
105
101
  arcEdgeProximityColor: brandColor,
106
102
  touchDistanceThreshold: 50
107
- }));
103
+ }, directionControlProps)));
108
104
  }
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { View } from '@ray-js/ray';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { View, usePageEvent } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { getVideoBitrateKbps } from '@ray-js/ray-ipc-utils';
5
5
  import { PlayState } from '../../interface';
@@ -15,20 +15,23 @@ export const VideoBitKBP = props => {
15
15
  const store = useStore({
16
16
  playState
17
17
  });
18
+ const timerRef = useRef();
18
19
  useEffect(() => {
19
- let timer;
20
20
  if (store.playState === PlayState.PLAYING) {
21
21
  init();
22
- timer = setInterval(() => {
22
+ timerRef.current = setInterval(() => {
23
23
  init();
24
24
  }, 3000);
25
25
  } else {
26
- clearInterval(timer);
26
+ clearInterval(timerRef.current);
27
27
  }
28
28
  return () => {
29
- clearInterval(timer);
29
+ clearInterval(timerRef.current);
30
30
  };
31
31
  }, [store.playState]);
32
+ usePageEvent('onUnload', () => {
33
+ clearInterval(timerRef.current);
34
+ });
32
35
  const init = async () => {
33
36
  const res = await getVideoBitrateKbps(devId);
34
37
  if (res.code !== -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-61",
3
+ "version": "0.0.1-beta-63",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -32,7 +32,7 @@
32
32
  "test": "yarn jest"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ray-js/direction-control": "0.0.7-beta-3",
35
+ "@ray-js/direction-control": "0.0.7-beta-7",
36
36
  "ahooks": "^3.1.6"
37
37
  },
38
38
  "dependencies": {
@@ -48,7 +48,7 @@
48
48
  "@commitlint/cli": "^7.2.1",
49
49
  "@commitlint/config-conventional": "^9.0.1",
50
50
  "@ray-js/cli": "^1.4.9",
51
- "@ray-js/direction-control": "0.0.7-beta-5",
51
+ "@ray-js/direction-control": "0.0.7-beta-7",
52
52
  "@ray-js/ray": "^1.4.9",
53
53
  "@testing-library/react-hooks": "^8.0.1",
54
54
  "@types/jest": "^29.5.14",