@ray-js/ipc-player-integration 0.0.1-beta-37 → 0.0.1-beta-39

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
@@ -1,3 +1,7 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.filter.js";
3
+ import "core-js/modules/esnext.iterator.find.js";
4
+ import "core-js/modules/esnext.iterator.map.js";
1
5
  import { useRef, useCallback, useEffect } from 'react';
2
6
  import Strings from '../i18n';
3
7
  import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
@@ -80,10 +84,10 @@ export const createUseCtx = _ref => {
80
84
  // 获取缓存的值且同步
81
85
  getMemoryState(devId).then(res => {
82
86
  console.log('==== getMemoryState ====', res);
83
- _setMute(res.mute);
84
- setIntercomMode(res.intercomMode);
85
87
  setResolutionList(res.resolutionList);
86
88
  _setResolution(res.resolution);
89
+ _setMute(res.mute);
90
+ setIntercomMode(res.intercomMode);
87
91
  });
88
92
  }
89
93
  }, [devId, _playState]);
@@ -122,6 +126,7 @@ export const createUseCtx = _ref => {
122
126
  IPCPlayerInstance.current = createPlayContext(devId);
123
127
  }
124
128
  const _setMute = async target => {
129
+ console.log(target, '_setMute====');
125
130
  return new Promise((resolve, reject) => {
126
131
  IPCPlayerInstance.current.setMuted({
127
132
  mute: target,
@@ -138,12 +143,12 @@ export const createUseCtx = _ref => {
138
143
  updateAtom(mute, res);
139
144
  }
140
145
  });
146
+ console.log('喇叭调用失败', JSON.stringify(err));
141
147
  reject(err);
142
- const errObj = err.innerError || err || {};
143
- const errMsg = errObj.errorMsg || I18n.t('error_setMute');
144
- toast({
145
- title: errMsg
146
- });
148
+
149
+ // const errObj = err.innerError || err || {};
150
+ // const errMsg = errObj.errorMsg || I18n.t('error_setMute');
151
+ // toast({ title: errMsg });
147
152
  }
148
153
  });
149
154
  });
package/lib/ctx/event.js CHANGED
@@ -1,3 +1,6 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.filter.js";
3
+ import "core-js/modules/esnext.iterator.for-each.js";
1
4
  export function getEventInstance() {
2
5
  const map = {};
3
6
  return {
package/lib/ctx/store.js CHANGED
@@ -1,3 +1,5 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.for-each.js";
1
3
  import { useRef } from 'react';
2
4
  import { atom, useAtomValue, getDefaultStore } from 'jotai';
3
5
  export { getDefaultStore } from 'jotai';
@@ -3,3 +3,4 @@ export * from './useHumidity';
3
3
  export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
+ export * from './usePtz';
@@ -2,4 +2,5 @@ export * from './useBattery';
2
2
  export * from './useHumidity';
3
3
  export * from './useTemperature';
4
4
  export * from './useDpState';
5
- export * from './useMemoizedFn';
5
+ export * from './useMemoizedFn';
6
+ export * from './usePtz';
@@ -1,4 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.for-each.js";
4
+ import "core-js/modules/esnext.iterator.reduce.js";
2
5
  import { useState, useEffect, useRef, useCallback } from 'react';
3
6
  import { getDeviceInfo, onDpDataChange, offDpDataChange } from '@ray-js/ray';
4
7
  import { useMemoizedFn } from '../useMemoizedFn';
@@ -0,0 +1 @@
1
+ export declare const usePtz: (devId: string) => boolean;
@@ -0,0 +1,13 @@
1
+ import { useMemo } from 'react';
2
+ import { PTZ_CONTROL } from '../../utils/content/dpCode';
3
+ import { useDpState } from '../useDpState';
4
+ export const usePtz = devId => {
5
+ const [dpState] = useDpState({
6
+ devId,
7
+ dpCodes: [PTZ_CONTROL]
8
+ });
9
+ const supportPtz = useMemo(() => {
10
+ return dpState[PTZ_CONTROL];
11
+ }, [dpState]);
12
+ return supportPtz;
13
+ };
package/lib/interface.js CHANGED
@@ -1,17 +1,26 @@
1
1
  export { IntercomMode } from './ports.output';
2
2
  export let PlayerStreamStatus = /*#__PURE__*/function (PlayerStreamStatus) {
3
3
  PlayerStreamStatus[PlayerStreamStatus["UnknownException"] = -1000] = "UnknownException";
4
+ // 未知异常
4
5
  PlayerStreamStatus[PlayerStreamStatus["ConnectSuccess"] = 1001] = "ConnectSuccess";
6
+ // 连接成功
5
7
  PlayerStreamStatus[PlayerStreamStatus["ConnectFail"] = -1001] = "ConnectFail";
8
+ // 链接失败
6
9
  PlayerStreamStatus[PlayerStreamStatus["PreviewSuccess"] = 1002] = "PreviewSuccess";
10
+ // preview 成功
7
11
  PlayerStreamStatus[PlayerStreamStatus["PreviewFail"] = -1002] = "PreviewFail";
12
+ // preview 失败
8
13
  PlayerStreamStatus[PlayerStreamStatus["NetworkError"] = -1010] = "NetworkError";
14
+ // 网络状态不可用
9
15
  PlayerStreamStatus[PlayerStreamStatus["DeviceDelete"] = -1012] = "DeviceDelete";
16
+ // 设备被移除
10
17
  PlayerStreamStatus[PlayerStreamStatus["DisconnectSuccess"] = 1009] = "DisconnectSuccess";
18
+ // 断连成功
11
19
  PlayerStreamStatus[PlayerStreamStatus["DisconnectFail"] = -1009] = "DisconnectFail";
12
- PlayerStreamStatus[PlayerStreamStatus["PAUSE"] = 4] = "PAUSE";
20
+ // 断连失败
21
+ PlayerStreamStatus[PlayerStreamStatus["PAUSE"] = 4] = "PAUSE"; // 暂停
13
22
  return PlayerStreamStatus;
14
- }({}); // 暂停
23
+ }({});
15
24
  export let PlayState = /*#__PURE__*/function (PlayState) {
16
25
  PlayState[PlayState["CONNECTING"] = 0] = "CONNECTING";
17
26
  PlayState[PlayState["PLAYING"] = 1] = "PLAYING";
@@ -93,17 +93,17 @@ export function FullScreen(props) {
93
93
  handleFull();
94
94
  },
95
95
  vertical: () => {
96
+ event.emit(pauseTimeToHideAllComponent);
96
97
  ty.setNavigationBarBack({
97
98
  type: 'system'
98
99
  });
99
- event.emit(pauseTimeToHideAllComponent);
100
+ ty.showMenuButton();
101
+ ty.showStatusBar();
102
+ deleteContent('topLeft', verticalScreenId);
100
103
  deleteContent('absolute', voiceIntercomId);
101
104
  deleteContent('absolute', ptzControlId);
102
- deleteContent('topLeft', verticalScreenId);
103
105
  deleteContent('absolute', fullResolutionId);
104
106
  deleteContent('absolute', fullTravelRouteControlId);
105
- ty.showMenuButton();
106
- ty.showStatusBar();
107
107
  }
108
108
  };
109
109
  useUpdateEffect(() => {
@@ -24,6 +24,12 @@
24
24
  }
25
25
  }
26
26
 
27
+ .ipc-player-plugin-full-screen-voice-disappear {
28
+ width: 0;
29
+ height: 0;
30
+ overflow: hidden;
31
+ }
32
+
27
33
  .ipc-plugin-full-travel-route-control {
28
34
  width: calc(172px * var(--ipc-player-size-scale, 1));
29
35
  height: calc(172px * var(--ipc-player-size-scale, 1));
@@ -10,12 +10,18 @@ import { useComponentHideState } from '../../ui/hooks';
10
10
  import { useMemoizedFn } from '../../hooks';
11
11
  import { UIEventContext } from '../../ui/context';
12
12
  import { pauseTimeToHideAllComponent } from '../../ui/constant';
13
+ import { useStore } from '../../ctx/store';
13
14
  export function FullVoiceIntercom(props) {
14
15
  const [shouldHide] = useComponentHideState();
15
16
  const [isPtzActive, setIsPtzActive] = useState(false);
16
17
  const {
17
18
  event
18
19
  } = useContext(UIEventContext);
20
+ const {
21
+ screenType
22
+ } = useStore({
23
+ screenType: props.screenType
24
+ });
19
25
  const onPtzControlShow = useMemoizedFn(() => {
20
26
  setIsPtzActive(true);
21
27
  });
@@ -32,7 +38,8 @@ export function FullVoiceIntercom(props) {
32
38
  }, []);
33
39
  return /*#__PURE__*/React.createElement(View, {
34
40
  className: clsx('ipc-player-plugin-full-screen-voice', {
35
- 'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive
41
+ 'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive,
42
+ 'ipc-player-plugin-full-screen-voice-disappear': screenType === 'vertical'
36
43
  })
37
44
  }, /*#__PURE__*/React.createElement(VoiceIntercom, _extends({}, props, {
38
45
  talkingColor: "#FFFFFF",
@@ -1,4 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.map.js";
2
4
  import React from 'react';
3
5
  import { View, ScrollView } from '@ray-js/ray';
4
6
  import clsx from 'clsx';
@@ -3,6 +3,7 @@ import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import React, { useEffect, useState, useContext } from 'react';
5
5
  import { UIEventContext } from '../../ui/context';
6
+ import { usePtz } from '../../hooks';
6
7
  import { useStore } from '../../ctx/store';
7
8
  import { ptzControlId } from '../../ui/constant';
8
9
  import './ptz.less';
@@ -15,7 +16,8 @@ export const Ptz = props => {
15
16
  deleteContent,
16
17
  showContent,
17
18
  hideContent,
18
- className
19
+ className,
20
+ devId
19
21
  } = props;
20
22
  const {
21
23
  screenType,
@@ -28,13 +30,14 @@ export const Ptz = props => {
28
30
  const {
29
31
  event
30
32
  } = useContext(UIEventContext);
33
+ const supportPtz = usePtz(devId);
31
34
  useEffect(() => {
32
35
  if (screenType === 'vertical') {
33
36
  event.emit('ptzControlHide');
34
37
  setIsPtzActive(false);
35
38
  }
36
39
  }, [screenType]);
37
- if (screenType === 'vertical') {
40
+ if (screenType === 'vertical' || !supportPtz) {
38
41
  return null;
39
42
  }
40
43
  return /*#__PURE__*/React.createElement(View, {
@@ -1,3 +1,5 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
1
3
  import React, { useCallback, useState, useContext, useEffect } from 'react';
2
4
  import { Text, View } from '@ray-js/ray';
3
5
  import clsx from 'clsx';
@@ -57,7 +57,9 @@ export const Resolution = props => {
57
57
  onClick: onResolution,
58
58
  className: clsx(className, screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
59
59
  }, /*#__PURE__*/React.createElement(View, {
60
- className: "ipc-player-plugin-resolution"
60
+ className: clsx('ipc-player-plugin-resolution', {
61
+ 'ipc-player-plugin-resolution-full': screenType === 'full'
62
+ })
61
63
  }, /*#__PURE__*/React.createElement(Text, {
62
64
  className: "resolutionText"
63
65
  }, Strings.getLang(`ipc_player_resolution_${resolution}`))));
@@ -2,19 +2,23 @@
2
2
 
3
3
  .ipc-player-plugin-resolution {
4
4
  background-color: rgba(255,255,255,0.2);
5
- padding: calc(4px * var(--ipc-player-size-scale, 1)) calc(5px * var(--ipc-player-size-scale, 1)) !important;
5
+ padding: calc(4px * var(--ipc-player-size-scale, 1)) calc(5px * var(--ipc-player-size-scale, 1));
6
6
  display: flex;
7
7
  justify-content: center;
8
8
  align-items: center;
9
- border-radius: calc(8px * var(--ipc-player-size-scale, 1));
9
+ border-radius: calc(3px * var(--ipc-player-size-scale, 1));
10
10
  background-color: rgba(255, 255, 255, 0.3);
11
11
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
12
12
  .resolutionText {
13
13
  color: var(--iconColor);
14
14
  font-weight: 600;
15
- font-size: calc(14px * var(--ipc-player-size-scale, 1));
15
+ font-size: calc(12px * var(--ipc-player-size-scale, 1));
16
16
  }
17
17
  }
18
+ .ipc-player-plugin-resolution-full {
19
+ padding-left: calc(8px * var(--ipc-player-size-scale, 1));
20
+ padding-right: calc(8px * var(--ipc-player-size-scale, 1));
21
+ }
18
22
 
19
23
  .ipc-player-plugin-full-resolution-control {
20
24
  height: 100%;
@@ -3,6 +3,7 @@ export type UseBattery = (devId: string) => {
3
3
  batteryValue: number;
4
4
  batteryCharging: boolean;
5
5
  };
6
+ export type UsePtz = (devId: string) => boolean;
6
7
  export type UseTemperature = (devId: string) => number;
7
8
  export type UseHumidity = () => number;
8
9
  export type Toast = (options: {
@@ -2,6 +2,8 @@ export { IntercomMode } from '@ray-js/ray-ipc-utils/lib/interface';
2
2
 
3
3
  // plugin 获取电池电量 todo
4
4
 
5
+ // plugin 获取是否支持Ptz
6
+
5
7
  // plugin 获取温度
6
8
 
7
9
  // plugin 获取湿度
package/lib/ui/event.js CHANGED
@@ -1,3 +1,6 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.filter.js";
3
+ import "core-js/modules/esnext.iterator.for-each.js";
1
4
  export function getEventInstance() {
2
5
  const map = {};
3
6
  return {
package/lib/ui/ui.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.map.js";
2
4
  import React, { useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
3
5
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
6
  import clsx from 'clsx';
package/lib/ui/ui.less CHANGED
@@ -191,6 +191,9 @@
191
191
  // 左下角子元素容器
192
192
  .bottom-left-item-container {
193
193
  padding: 0 12px;
194
+ display: flex;
195
+ justify-content: center;
196
+ align-items: center;
194
197
  }
195
198
 
196
199
  .bottom-left-item-container:first-of-type {
@@ -1,3 +1,6 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.find.js";
3
+ import "core-js/modules/esnext.iterator.for-each.js";
1
4
  import IpcUtils from '@ray-js/ray-ipc-utils';
2
5
  export function getDpValue(options) {
3
6
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-37",
3
+ "version": "0.0.1-beta-39",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -36,7 +36,7 @@
36
36
  "ahooks": "^3.1.6"
37
37
  },
38
38
  "dependencies": {
39
- "@ray-js/ipc-ptz-zoom": "0.0.2-beta-6",
39
+ "@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
41
  "@ray-js/ray-ipc-player": "2.0.20-beta-6",
42
42
  "@ray-js/ray-ipc-utils": "1.1.0-beta-13",
@@ -1,9 +0,0 @@
1
- import { IntercomMode } from '../ports.output';
2
- export type { Toast, IntercomMode } from '../ports.output';
3
- export type createPlayContext = (devId: string) => IpcContext;
4
- export type AuthorizeStatus = (type: string) => Promise<boolean>;
5
- export type GetMemoryState = (devId: string) => Promise<{
6
- mute: boolean;
7
- intercomMode: IntercomMode;
8
- }>;
9
- export type SetMuteMemoryState = (devId: string, value: boolean) => void;
@@ -1,102 +0,0 @@
1
- import React from 'react';
2
- import { PrimitiveAtom } from 'jotai';
3
- import type { Toast, IntercomMode } from './ports.output';
4
- export { IntercomMode } from './ports.output';
5
- type WithInitialValue<Value> = {
6
- init: Value;
7
- };
8
- export type RetAtom<T> = PrimitiveAtom<T> & WithInitialValue<T>;
9
- export type ScreenType = 'full' | 'vertical';
10
- export declare const enum PlayerStreamStatus {
11
- UnknownException = -1000,
12
- ConnectSuccess = 1001,
13
- ConnectFail = -1001,
14
- PreviewSuccess = 1002,
15
- PreviewFail = -1002,
16
- NetworkError = -1010,
17
- DeviceDelete = -1012,
18
- DisconnectSuccess = 1009,
19
- DisconnectFail = -1009,
20
- PAUSE = 4
21
- }
22
- export declare const enum PlayState {
23
- CONNECTING = 0,
24
- PLAYING = 1,
25
- PAUSE = 2
26
- }
27
- export type ContentPlaceType = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'absolute';
28
- type Task = (...args: any[]) => void;
29
- export type EventInstance = {
30
- on: (type: string, cb: Task) => void;
31
- off: (type: string, cb: Task) => void;
32
- emit: (type: string, ...args: any[]) => void;
33
- };
34
- export type UseCtx = (options: {
35
- devId: string;
36
- initTopLeftContent?: ComponentConfig[];
37
- initTopRightContent?: ComponentConfig[];
38
- initBottomLeftContent?: ComponentConfig[];
39
- initBottomRightContent?: ComponentConfig[];
40
- initAbsoluteContent?: ComponentConfig[];
41
- saveToAlbum?: 0 | 1;
42
- }) => {
43
- devId: string;
44
- brandColor: RetAtom<string>;
45
- verticalMic: RetAtom<boolean>;
46
- saveToAlbum: 0 | 1;
47
- screenType: RetAtom<ScreenType>;
48
- recording: RetAtom<boolean>;
49
- recordingDisabled: RetAtom<boolean>;
50
- mute: RetAtom<boolean>;
51
- intercom: RetAtom<boolean>;
52
- intercomMode: RetAtom<IntercomMode>;
53
- resolution: RetAtom<string>;
54
- resolutionList: RetAtom<string[]>;
55
- playState: RetAtom<PlayState>;
56
- IPCPlayerInstance: IpcContext;
57
- topLeftContent: RetAtom<ComponentConfig[]>;
58
- topRightContent: RetAtom<ComponentConfig[]>;
59
- bottomLeftContent: RetAtom<ComponentConfig[]>;
60
- bottomRightContent: RetAtom<ComponentConfig[]>;
61
- absoluteContent: RetAtom<ComponentConfig[]>;
62
- setBrandColor: (color: string) => void;
63
- setVerticalMic: (color: boolean) => void;
64
- setScreenType: (type: ScreenType) => void;
65
- setRecordingDisabled: (type: boolean) => void;
66
- setResolution: (type: string) => void;
67
- setResolutionList: (type: string[]) => void;
68
- setRecording: (value: boolean) => Promise<RecordInfoData>;
69
- setIntercom: (value: boolean) => Promise<boolean>;
70
- setMute: (value: boolean) => Promise<boolean>;
71
- changeStreamStatus: (value: PlayerStreamStatus) => void;
72
- getStreamStatus: () => PlayerStreamStatus;
73
- setPlayState: (value: PlayState) => void;
74
- addContent: <T>(type: ContentPlaceType, config: ComponentConfig<T> | ComponentConfig<T>[], position?: number) => void;
75
- deleteContent: (type: ContentPlaceType, id: string) => void;
76
- hasContent: (type: ContentPlaceType, id: string) => boolean;
77
- hideContent: (type: ContentPlaceType, id: string) => void;
78
- showContent: (type: ContentPlaceType, id: string) => void;
79
- toast: Toast;
80
- event: EventInstance;
81
- };
82
- export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
83
- id: string;
84
- content: (props: T) => React.ReactElement;
85
- initProps?: T;
86
- absolutePosition?: React.CSSProperties;
87
- absoluteContentClassName?: string;
88
- absoluteContentStyle?: React.CSSProperties;
89
- hidden?: boolean;
90
- };
91
- export type ComponentConfigProps = {
92
- IPCPlayerContext: IpcContext;
93
- } & ReturnType<UseCtx>;
94
- export type PlayStatusData = {
95
- playState: PlayState;
96
- playCode: number;
97
- };
98
- export type RecordInfoData = boolean | {
99
- tempImagePath: string;
100
- filePath: string;
101
- thumbPath: string;
102
- };
@@ -1,23 +0,0 @@
1
- export declare function getDpValue<T extends string>(options: {
2
- devId: string;
3
- dps: T[];
4
- }): Promise<Record<T, number | string | boolean>>;
5
- export interface IDpCode {
6
- code: string;
7
- dpId: number;
8
- value: string;
9
- time: number;
10
- type: string;
11
- }
12
- type ReturnDeviceInfo = Parameters<Parameters<typeof ty.device.getDeviceInfo>[0]['success']>[0];
13
- export declare function getDeviceInfo(devId: string): Promise<ReturnDeviceInfo>;
14
- export declare function getDpIdsByCodes<T extends string>(devId: string, dpIds: T[]): Promise<Record<T, string>>;
15
- export declare const showMathPowValue: (value: any, scale: any) => string | 0;
16
- export declare const getDevInfo: <T>(deviceId: string) => Promise<any>;
17
- /**
18
- * 根据DpCode获取枚举型DP的range是否包含对应项
19
- * @param result: {code: number, msg: string}
20
- */
21
- export declare const getEnumRangeIsValid: (devId: any, dpCode: any, rangValue: any) => Promise<any>;
22
- export declare function hasDpCode(devId: string, code: string): Promise<boolean>;
23
- export {};