@ray-js/ipc-player-integration 0.0.1-beta-62 → 0.0.1-beta-64

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.d.ts CHANGED
@@ -25,6 +25,7 @@ type Props = {
25
25
  brandColor?: string;
26
26
  verticalMic?: boolean;
27
27
  landscapeMode?: 'fill' | 'standard';
28
+ playerMode: 'portrait' | 'landscape';
28
29
  eventRef?: React.RefObject<EventInstance>;
29
30
  onPlayerTap?: (data: any) => void;
30
31
  extend?: Record<string, any>;
package/lib/ui/ui.js CHANGED
@@ -52,6 +52,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
52
52
  verticalMic = true,
53
53
  eventRef: eventRefProp,
54
54
  landscapeMode = 'standard',
55
+ playerMode = 'portrait',
55
56
  onPlayerTap,
56
57
  extend = {}
57
58
  } = props;
@@ -81,8 +82,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
81
82
  }
82
83
  useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
83
84
  const timer = useRef();
84
- const [scaleMultiple, setScaleMultiple] = useState(1);
85
- const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
85
+ const [scaleMultiple, setScaleMultiple] = useState(playerMode === 'portrait' ? 1 : -2);
86
+ const [currentZoomLevel, setCurrentZoomLevel] = useState(playerMode === 'portrait' ? 1 : -2);
87
+
88
+ // 监听playerMode的变化,更新scaleMultiple
89
+ useEffect(() => {
90
+ setScaleMultiple(playerMode === 'portrait' ? 1 : -2);
91
+ setCurrentZoomLevel(playerMode === 'portrait' ? 1 : -2);
92
+ }, [playerMode]);
86
93
  useEffect(() => {
87
94
  setBrandColor(brandColor);
88
95
  setVerticalMic(verticalMic);
@@ -120,7 +127,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
120
127
  setScaleMultiple(-1);
121
128
  } else {
122
129
  // 将屏幕播放比例设为1
123
- setScaleMultiple(1);
130
+ setScaleMultiple(playerMode === 'portrait' ? 1 : -2);
124
131
  }
125
132
  } catch (err) {
126
133
  console.log(err, 'err');
@@ -328,6 +335,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
328
335
  };
329
336
  }, []);
330
337
  playState === PlayState.PLAYING;
338
+ console.log(scaleMultiple, 'scaleMultiple===');
331
339
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
332
340
  value: {
333
341
  event: eventRef.current,
@@ -355,6 +363,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
355
363
  const {
356
364
  zoomLevel
357
365
  } = data === null || data === void 0 ? void 0 : data.detail;
366
+ console.log(zoomLevel, 'zoomLevel======');
358
367
  setCurrentZoomLevel(zoomLevel);
359
368
  },
360
369
  scaleMultiple: scaleMultiple
@@ -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);
@@ -74,7 +76,7 @@ export function FullTravelRouteControl(props) {
74
76
  className: clsx('ipc-player-plugin-full-screen-voice', {
75
77
  'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive
76
78
  })
77
- }, /*#__PURE__*/React.createElement(RectDirectionControl, {
79
+ }, /*#__PURE__*/React.createElement(RectDirectionControl, _extends({
78
80
  className: "ipc-plugin-full-travel-route-control",
79
81
  value: 0,
80
82
  onTouchStart: value => {
@@ -98,5 +100,5 @@ export function FullTravelRouteControl(props) {
98
100
  showArcOnTouchInEdgeProximity: true,
99
101
  arcEdgeProximityColor: brandColor,
100
102
  touchDistanceThreshold: 50
101
- }));
103
+ }, directionControlProps)));
102
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) {
@@ -1,5 +1,5 @@
1
1
  .ipc-player-plugin-videoBitKBP-container {
2
- min-width: calc(100px * var(--ipc-player-size-scale, 1));
2
+ min-width: calc(92px * var(--ipc-player-size-scale, 1));
3
3
  display: flex;
4
4
  justify-content: center;
5
5
  align-items: center;
@@ -10,7 +10,7 @@
10
10
  justify-content: center;
11
11
  width: 100%;
12
12
  height: calc(24px * var(--ipc-player-size-scale, 1));
13
- padding: 0 calc(9px * var(--ipc-player-size-scale, 1));
13
+ padding: 0 calc(6px * var(--ipc-player-size-scale, 1));
14
14
  border-radius: calc(24px * var(--ipc-player-size-scale, 1));
15
15
  color: var(--iconColor);
16
16
  font-size: calc(12px * var(--ipc-player-size-scale, 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-62",
3
+ "version": "0.0.1-beta-64",
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",