@ray-js/ipc-player-integration 0.0.1-beta-1

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 (108) hide show
  1. package/README.md +32 -0
  2. package/lib/core.d.ts +0 -0
  3. package/lib/core.js +0 -0
  4. package/lib/ctx/ctx.composition.d.ts +1 -0
  5. package/lib/ctx/ctx.composition.js +38 -0
  6. package/lib/ctx/ctx.d.ts +10 -0
  7. package/lib/ctx/ctx.js +159 -0
  8. package/lib/ctx/ctx.test.d.ts +1 -0
  9. package/lib/ctx/ctx.test.js +95 -0
  10. package/lib/ctx/index.d.ts +2 -0
  11. package/lib/ctx/index.js +2 -0
  12. package/lib/ctx/ports.output.d.ts +1 -0
  13. package/lib/ctx/ports.output.js +1 -0
  14. package/lib/ctx/useCtx.d.ts +0 -0
  15. package/lib/ctx/useCtx.js +0 -0
  16. package/lib/hooks/index.d.ts +5 -0
  17. package/lib/hooks/index.js +5 -0
  18. package/lib/hooks/useBattery/index.d.ts +2 -0
  19. package/lib/hooks/useBattery/index.js +17 -0
  20. package/lib/hooks/useDpState/index.d.ts +1 -0
  21. package/lib/hooks/useDpState/index.js +1 -0
  22. package/lib/hooks/useDpState/useDpState.d.ts +6 -0
  23. package/lib/hooks/useDpState/useDpState.js +79 -0
  24. package/lib/hooks/useHumidity/index.d.ts +1 -0
  25. package/lib/hooks/useHumidity/index.js +16 -0
  26. package/lib/hooks/useMuted/index.d.ts +1 -0
  27. package/lib/hooks/useMuted/index.js +3 -0
  28. package/lib/hooks/useTemperature/index.d.ts +5 -0
  29. package/lib/hooks/useTemperature/index.js +30 -0
  30. package/lib/hooks/useVideoBitKbps/index.d.ts +1 -0
  31. package/lib/hooks/useVideoBitKbps/index.js +44 -0
  32. package/lib/iconfont/demo.css +539 -0
  33. package/lib/iconfont/demo_index.html +556 -0
  34. package/lib/iconfont/iconfont.css +79 -0
  35. package/lib/iconfont/iconfont.js +42 -0
  36. package/lib/iconfont/iconfont.json +121 -0
  37. package/lib/iconfont/iconfont.ttf +0 -0
  38. package/lib/iconfont/iconfont.woff +0 -0
  39. package/lib/iconfont/iconfont.woff2 +0 -0
  40. package/lib/index.config.js +14 -0
  41. package/lib/index.d.ts +3 -0
  42. package/lib/index.js +3 -0
  43. package/lib/index.less +7 -0
  44. package/lib/interface.d.ts +59 -0
  45. package/lib/interface.js +19 -0
  46. package/lib/plugins/battery/battery.composition.d.ts +27 -0
  47. package/lib/plugins/battery/battery.composition.js +5 -0
  48. package/lib/plugins/battery/battery.d.ts +13 -0
  49. package/lib/plugins/battery/battery.js +39 -0
  50. package/lib/plugins/battery/battery.less +67 -0
  51. package/lib/plugins/battery/index.d.ts +1 -0
  52. package/lib/plugins/battery/index.js +1 -0
  53. package/lib/plugins/fullScreen/fullScreen.d.ts +6 -0
  54. package/lib/plugins/fullScreen/fullScreen.js +71 -0
  55. package/lib/plugins/fullScreen/fullScreen.less +16 -0
  56. package/lib/plugins/fullScreen/index.d.ts +1 -0
  57. package/lib/plugins/fullScreen/index.js +1 -0
  58. package/lib/plugins/fullScreen/verticalScreen.d.ts +8 -0
  59. package/lib/plugins/fullScreen/verticalScreen.js +15 -0
  60. package/lib/plugins/fullScreen/verticalScreen.less +11 -0
  61. package/lib/plugins/index.d.ts +8 -0
  62. package/lib/plugins/index.js +8 -0
  63. package/lib/plugins/muted/index.d.ts +1 -0
  64. package/lib/plugins/muted/index.js +1 -0
  65. package/lib/plugins/muted/muted.d.ts +4 -0
  66. package/lib/plugins/muted/muted.js +42 -0
  67. package/lib/plugins/muted/muted.less +5 -0
  68. package/lib/plugins/recordVideo/index.d.ts +1 -0
  69. package/lib/plugins/recordVideo/index.js +1 -0
  70. package/lib/plugins/recordVideo/recordVideo.d.ts +6 -0
  71. package/lib/plugins/recordVideo/recordVideo.js +93 -0
  72. package/lib/plugins/recordVideo/recordVideo.less +37 -0
  73. package/lib/plugins/screenshot/index.d.ts +1 -0
  74. package/lib/plugins/screenshot/index.js +1 -0
  75. package/lib/plugins/screenshot/screenshot.d.ts +6 -0
  76. package/lib/plugins/screenshot/screenshot.js +55 -0
  77. package/lib/plugins/screenshot/screenshot.less +38 -0
  78. package/lib/plugins/tempHumidity/index.d.ts +1 -0
  79. package/lib/plugins/tempHumidity/index.js +1 -0
  80. package/lib/plugins/tempHumidity/tempHumidity.d.ts +8 -0
  81. package/lib/plugins/tempHumidity/tempHumidity.js +54 -0
  82. package/lib/plugins/tempHumidity/tempHumidity.less +21 -0
  83. package/lib/plugins/videoBitKbps/index.d.ts +1 -0
  84. package/lib/plugins/videoBitKbps/index.js +1 -0
  85. package/lib/plugins/videoBitKbps/videoBitKbps.d.ts +6 -0
  86. package/lib/plugins/videoBitKbps/videoBitKbps.js +13 -0
  87. package/lib/plugins/videoBitKbps/videoBitKbps.less +11 -0
  88. package/lib/plugins/voiceIntercom/index.d.ts +1 -0
  89. package/lib/plugins/voiceIntercom/index.js +1 -0
  90. package/lib/plugins/voiceIntercom/voiceIntercom.d.ts +9 -0
  91. package/lib/plugins/voiceIntercom/voiceIntercom.js +67 -0
  92. package/lib/plugins/voiceIntercom/voiceIntercom.less +10 -0
  93. package/lib/ports.output.d.ts +6 -0
  94. package/lib/ports.output.js +1 -0
  95. package/lib/props.d.ts +14 -0
  96. package/lib/props.js +1 -0
  97. package/lib/ui/index.d.ts +1 -0
  98. package/lib/ui/index.js +1 -0
  99. package/lib/ui/ui.d.ts +21 -0
  100. package/lib/ui/ui.js +121 -0
  101. package/lib/ui/ui.less +44 -0
  102. package/lib/utils/authorize/index.d.ts +1 -0
  103. package/lib/utils/authorize/index.js +31 -0
  104. package/lib/utils/content/dpCode.d.ts +4 -0
  105. package/lib/utils/content/dpCode.js +7 -0
  106. package/lib/utils/device/index.d.ts +13 -0
  107. package/lib/utils/device/index.js +68 -0
  108. package/package.json +74 -0
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './muted.less';
4
+ export declare const Muted: (props: ComponentConfigProps) => React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { View, Text } from '@ray-js/ray';
2
+ import React, { useEffect, useState } from 'react';
3
+ import './muted.less';
4
+ export const Muted = props => {
5
+ const {
6
+ IPCPlayerContext
7
+ } = props;
8
+ const [isMuted, setIsMuted] = useState(true);
9
+ useEffect(() => {
10
+ init();
11
+ }, []);
12
+ const init = () => {
13
+ IPCPlayerContext.isMuted({
14
+ success: res => {
15
+ setIsMuted(res);
16
+ },
17
+ fail: res => {
18
+ console.log('res===isMuted err', res);
19
+ }
20
+ });
21
+ };
22
+ return /*#__PURE__*/React.createElement(View, {
23
+ onClick: () => {
24
+ IPCPlayerContext.setMuted({
25
+ mute: !isMuted,
26
+ success: () => {
27
+ setIsMuted(!isMuted);
28
+ },
29
+ fail: res => {
30
+ console.log('res===setMuted err', res);
31
+ }
32
+ });
33
+ },
34
+ style: {
35
+ display: 'flex'
36
+ }
37
+ }, isMuted ? /*#__PURE__*/React.createElement(Text, {
38
+ className: "text-icon icon-panel icon-panel-jingyin"
39
+ }) : /*#__PURE__*/React.createElement(Text, {
40
+ className: "text-icon icon-panel icon-panel-yinliang"
41
+ }));
42
+ };
@@ -0,0 +1,5 @@
1
+ .text-icon {
2
+ color: var(--iconColor);
3
+ font-size: var(--iconFontSize);
4
+ padding: 8rpx;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './recordVideo';
@@ -0,0 +1 @@
1
+ export * from './recordVideo';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './recordVideo.less';
4
+ type Props = ComponentConfigProps;
5
+ export declare function RecordVideo(props: Props): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,93 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { View } from '@ray-js/ray';
3
+ import './recordVideo.less';
4
+ const RECORD_VIDEO_TOAST_ID = 'record_video_toast_id';
5
+ function formatTimeDiff(diff) {
6
+ const padWithZero = true;
7
+ const diffMs = Math.abs(diff);
8
+ const minutes = Math.floor(diffMs / (1000 * 60));
9
+ const sec = Math.floor(diffMs % (1000 * 60) / 1000);
10
+ const formattedMinutes = String(minutes).padStart(2, '0');
11
+ const formattedSec = String(sec).padStart(2, '0');
12
+ return [formattedMinutes, formattedSec];
13
+ }
14
+ function useTime() {
15
+ const timer = useRef();
16
+ const startTime = useRef(0);
17
+ if (!startTime.current) {
18
+ startTime.current = new Date().getTime();
19
+ }
20
+ const [diffTime, setDiffTime] = useState(0);
21
+ useEffect(() => {
22
+ // @ts-ignore
23
+ timer.current = setInterval(() => {
24
+ const now = new Date().getTime();
25
+ setDiffTime(now - startTime.current);
26
+ }, 1000);
27
+ return () => {
28
+ clearInterval(timer.current);
29
+ };
30
+ }, []);
31
+ const cancel = () => {
32
+ clearInterval(timer.current);
33
+ };
34
+ if (!diffTime) {
35
+ return {
36
+ min: '00',
37
+ sec: '00',
38
+ cancel
39
+ };
40
+ }
41
+ const ret = formatTimeDiff(diffTime);
42
+ return {
43
+ min: ret[0],
44
+ sec: ret[1]
45
+ };
46
+ }
47
+ function TimeRecord() {
48
+ const {
49
+ min,
50
+ sec,
51
+ cancel
52
+ } = useTime();
53
+ return /*#__PURE__*/React.createElement(View, {
54
+ className: "ipc-player-plugin-record-video-toast-time"
55
+ }, /*#__PURE__*/React.createElement(View, {
56
+ className: "ipc-player-plugin-record-video-toast-time-warp"
57
+ }, min), /*#__PURE__*/React.createElement(View, {
58
+ className: "ipc-player-plugin-record-video-toast-time-delimiter"
59
+ }, ":"), /*#__PURE__*/React.createElement(View, {
60
+ className: "ipc-player-plugin-record-video-toast-time-warp"
61
+ }, sec));
62
+ }
63
+ export function RecordVideo(props) {
64
+ const {
65
+ IPCPlayerContext,
66
+ addContent,
67
+ deleteContent
68
+ } = props;
69
+ // const [recording, setRecording] = useState(false);
70
+ const {
71
+ recording,
72
+ setRecording
73
+ } = props;
74
+ const handRecordVideo = async target => {
75
+ await setRecording(target);
76
+ if (target) {
77
+ deleteContent('absolute', RECORD_VIDEO_TOAST_ID);
78
+ } else {
79
+ addContent('absolute', {
80
+ id: RECORD_VIDEO_TOAST_ID,
81
+ content: () => /*#__PURE__*/React.createElement(View, {
82
+ className: "ipc-player-plugin-record-video-toast"
83
+ }, /*#__PURE__*/React.createElement(View, {
84
+ className: "ipc-player-plugin-record-video-toast-point"
85
+ }), /*#__PURE__*/React.createElement(TimeRecord, null))
86
+ });
87
+ }
88
+ };
89
+ return /*#__PURE__*/React.createElement(View, {
90
+ onClick: () => handRecordVideo(!recording),
91
+ className: "ipc-player-plugin-record-video-icon icon-panel icon-panel-luping"
92
+ });
93
+ }
@@ -0,0 +1,37 @@
1
+ .ipc-player-plugin-record-video-icon {
2
+ font-size: var(--iconFontSize);
3
+ color: var(--iconColor);
4
+ }
5
+ .ipc-player-plugin-record-video-toast {
6
+ z-index: 2;
7
+ position: absolute;
8
+ display: flex;
9
+ padding: 24rpx;
10
+ align-items: center;
11
+ left: 50%;
12
+ transform: translateX(-50%);
13
+ top: 14rpx;
14
+ background-color: var(--bg-color);
15
+ border-radius: 16rpx;
16
+ .ipc-player-plugin-record-video-toast-point {
17
+ width: 12rpx;
18
+ height: 12rpx;
19
+ border-radius: 12rpx;
20
+ background-color: #FF3838;
21
+ }
22
+ .ipc-player-plugin-record-video-toast-time {
23
+ font-size: 24rpx;
24
+ font-weight: 600;
25
+ color: var(--fontColor);
26
+ margin-left: 16rpx;
27
+ display: flex;
28
+ align-items: center;
29
+ .ipc-player-plugin-record-video-toast-time-warp {
30
+ width: 34rpx;
31
+ text-align: center;
32
+ }
33
+ .ipc-player-plugin-record-video-toast-time-delimiter {
34
+ margin: 0 4rpx;
35
+ }
36
+ }
37
+ }
@@ -0,0 +1 @@
1
+ export * from './screenshot';
@@ -0,0 +1 @@
1
+ export * from './screenshot';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './screenshot.less';
4
+ type Props = ComponentConfigProps;
5
+ export declare function Screenshot(props: Props): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,55 @@
1
+ import React, { useRef } from 'react';
2
+ import { View, Image, CoverView } from '@ray-js/ray';
3
+ import './screenshot.less';
4
+ const CLOSE_TIME = 5000;
5
+ export function Screenshot(props) {
6
+ const {
7
+ IPCPlayerContext,
8
+ addContent,
9
+ saveToAlbum,
10
+ deleteContent
11
+ } = props;
12
+ const timer = useRef();
13
+ const timeToCloseToast = () => {
14
+ clearInterval(timer.current);
15
+ // @ts-ignore
16
+ timer.current = setTimeout(() => {
17
+ deleteContent('absolute', 'plugin-screenshot-toast');
18
+ }, CLOSE_TIME);
19
+ };
20
+ const handCheck = () => {
21
+ console.log('handCheck');
22
+ };
23
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
24
+ onClick: () => {
25
+ IPCPlayerContext.snapshot({
26
+ saveToAlbum,
27
+ // 保存到 IPC 相册
28
+ success: res => {
29
+ deleteContent('absolute', 'plugin-screenshot-toast');
30
+ addContent('absolute', {
31
+ id: 'plugin-screenshot-toast',
32
+ content: () => {
33
+ return /*#__PURE__*/React.createElement(CoverView, {
34
+ className: "ipc-player-plugin-screenshot-toast"
35
+ }, /*#__PURE__*/React.createElement(Image, {
36
+ className: "ipc-player-plugin-screenshot-toast-image",
37
+ src: res.tempImagePath
38
+ }), /*#__PURE__*/React.createElement(View, {
39
+ className: "ipc-player-plugin-screenshot-toast-title"
40
+ }, "\u622A\u56FE\u5DF2\u4FDD\u5B58\u81F3\u76F8\u518C"), /*#__PURE__*/React.createElement(View, {
41
+ onClick: handCheck,
42
+ className: "ipc-player-plugin-screenshot-toast-bottom"
43
+ }, "\u67E5\u770B"));
44
+ }
45
+ });
46
+ timeToCloseToast();
47
+ },
48
+ fail: err => {
49
+ console.log('保存相册失败', err);
50
+ }
51
+ });
52
+ },
53
+ className: "icon-panel icon-panel-jieping ipc-player-plugin-screenshot-icon"
54
+ }));
55
+ }
@@ -0,0 +1,38 @@
1
+ .ipc-player-plugin-screenshot-icon {
2
+ color: var(--iconColor);
3
+ font-size: var(--iconFontSize);
4
+ }
5
+ .ipc-player-plugin-screenshot-toast {
6
+ position: absolute;
7
+ width: 90%;
8
+ border-radius: 16rpx;
9
+ background-color: var(--bg-color);
10
+ left: 50%;
11
+ transform: translateX(-50%);
12
+ top: 32rpx;
13
+ display: flex;
14
+ align-items: center;
15
+ padding: 16rpx 32rpx;
16
+ z-index: 3;
17
+ .ipc-player-plugin-screenshot-toast-image {
18
+ width: 132rpx;
19
+ height: 74rpx;
20
+ border-radius: 8rpx;
21
+ }
22
+ .ipc-player-plugin-screenshot-toast-title {
23
+ margin-left: 24rpx;
24
+ font-size: 28rpx;
25
+ color: var(--fontColor);
26
+ line-height: 40rpx;
27
+ max-width: 60%;
28
+ }
29
+ .ipc-player-plugin-screenshot-toast-bottom {
30
+ position: absolute;
31
+ right: 32rpx;
32
+ border: 1rpx solid #1989FA;
33
+ border-radius: 8rpx;
34
+ padding: 10rpx 22rpx;
35
+ color: #1989FA;
36
+ font-size: 28rpx;
37
+ }
38
+ }
@@ -0,0 +1 @@
1
+ export * from './tempHumidity';
@@ -0,0 +1 @@
1
+ export * from './tempHumidity';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './tempHumidity.less';
4
+ interface IProp extends ComponentConfigProps {
5
+ className?: string;
6
+ }
7
+ export declare const TempHumidity: (props: IProp) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { View, Text } from '@ray-js/ray';
3
+ import clsx from 'clsx';
4
+ import { useTemperature, useHumidity } from '../../hooks';
5
+ import './tempHumidity.less';
6
+ export const TempHumidity = props => {
7
+ const {
8
+ className,
9
+ devId
10
+ } = props;
11
+ const {
12
+ tempUnit,
13
+ tempC,
14
+ tempF
15
+ } = useTemperature(devId);
16
+ const humidity = useHumidity(devId);
17
+ const tempRender = () => {
18
+ if (tempUnit === '1') {
19
+ return tempF && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
20
+ className: "text-icon-tempHumidity icon-panel icon-panel-wendu"
21
+ }), /*#__PURE__*/React.createElement(Text, {
22
+ className: "tempHumidity"
23
+ }, tempF));
24
+ }
25
+ return tempC && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
26
+ className: "text-icon-tempHumidity icon-panel icon-panel-wendu"
27
+ }), /*#__PURE__*/React.createElement(Text, {
28
+ className: "tempHumidity"
29
+ }, tempC), /*#__PURE__*/React.createElement(Text, {
30
+ className: "divider"
31
+ }, "/"));
32
+ };
33
+ const humRender = () => {
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
35
+ className: "text-icon-tempHumidity icon-panel icon-panel-shidu"
36
+ }), /*#__PURE__*/React.createElement(Text, {
37
+ className: "tempHumidity"
38
+ }, `${humidity}`));
39
+ };
40
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (tempC || humidity) && /*#__PURE__*/React.createElement(View, {
41
+ className: clsx('ipc-player-plugin-tempHumidity', className)
42
+ }, (() => {
43
+ if (tempC && humidity) {
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), humRender());
45
+ }
46
+ if (tempC) {
47
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender());
48
+ }
49
+ if (humidity) {
50
+ return /*#__PURE__*/React.createElement(React.Fragment, null, humRender());
51
+ }
52
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
53
+ })()));
54
+ };
@@ -0,0 +1,21 @@
1
+ .ipc-player-plugin-tempHumidity {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 5px 8px;
5
+ border-radius: 12.5px;
6
+ opacity: 1;
7
+ background: rgba(255, 255, 255, 0.1);
8
+ backdrop-filter: blur(10px);
9
+ color: var(--iconColor);
10
+ }
11
+
12
+ .divider {
13
+ margin: 0 4px;
14
+ color: var(--iconColor);
15
+ }
16
+
17
+ .text-icon-tempHumidity {
18
+ color: var(--iconColor);
19
+ font-size: var(--iconFontSize);
20
+ margin-right: 4rpx;
21
+ }
@@ -0,0 +1 @@
1
+ export * from './videoBitKbps';
@@ -0,0 +1 @@
1
+ export * from './videoBitKbps';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './videoBitKbps.less';
3
+ import { ComponentConfigProps } from '../../interface';
4
+ type Props = ComponentConfigProps;
5
+ export declare const VideoBitKbps: (props: Props) => React.JSX.Element;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { View } from '@ray-js/ray';
3
+ import { useVideoBitKbps } from '../../hooks';
4
+ import './videoBitKbps.less';
5
+ export const VideoBitKbps = props => {
6
+ const {
7
+ devId
8
+ } = props;
9
+ const bitKbps = useVideoBitKbps(devId);
10
+ return /*#__PURE__*/React.createElement(View, {
11
+ className: "videoBitKbps"
12
+ }, bitKbps);
13
+ };
@@ -0,0 +1,11 @@
1
+ .videoBitKbps {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 5px 8px;
5
+ border-radius: 12.5px;
6
+ opacity: 1;
7
+ background: rgba(255, 255, 255, 0.1);
8
+ backdrop-filter: blur(10px);
9
+ margin-right: 8px;
10
+ color: var(--iconColor);
11
+ }
@@ -0,0 +1 @@
1
+ export * from './voiceIntercom';
@@ -0,0 +1 @@
1
+ export * from './voiceIntercom';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './voiceIntercom.less';
3
+ import { ComponentConfigProps } from '../../interface';
4
+ type Props = ComponentConfigProps & {
5
+ style?: React.CSSProperties;
6
+ className?: string;
7
+ };
8
+ export declare function VoiceIntercom({ style, className, recording, intercom, setIntercom, mute, setMute, getStreamStatus, }: Props): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,67 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import React, { useRef } from 'react';
3
+ import { View } from '@ray-js/ray';
4
+ import clsx from 'clsx';
5
+ import './voiceIntercom.less';
6
+ import { PlayerStreamStatus } from '../../interface';
7
+ export function VoiceIntercom(_ref) {
8
+ let {
9
+ style,
10
+ className,
11
+ recording,
12
+ intercom,
13
+ setIntercom,
14
+ mute,
15
+ setMute,
16
+ getStreamStatus
17
+ } = _ref;
18
+ const longClickStartedRef = useRef(false);
19
+ // 对讲开始之前的静音状态
20
+ const originMuteStatusBeforeVoice = useRef(mute);
21
+ const intercomRef = useRef(false);
22
+ const startVoice = async (_intercom, _recording, _mute) => {
23
+ if (intercomRef.current) return;
24
+ if (_recording) {
25
+ console.log('Cannot talk during video recording');
26
+ return;
27
+ }
28
+ if (getStreamStatus() !== PlayerStreamStatus.PreviewSuccess) {
29
+ console.log('PlayerStreamStatus not 1002');
30
+ return;
31
+ }
32
+ intercomRef.current = true;
33
+ originMuteStatusBeforeVoice.current = _mute;
34
+ // 如果对讲开始之前,是静音的,则需要关闭静音
35
+ if (_mute) {
36
+ await setMute(false);
37
+ }
38
+ setIntercom(_intercom);
39
+ };
40
+ const endVoice = async () => {
41
+ try {
42
+ // 将静音状态恢复为开始对讲之前的状态
43
+ await setMute(originMuteStatusBeforeVoice.current);
44
+ await setIntercom(false);
45
+ } catch (err) {
46
+ //
47
+ } finally {
48
+ intercomRef.current = false;
49
+ }
50
+ };
51
+ return /*#__PURE__*/React.createElement(View, {
52
+ style: _objectSpread({}, style),
53
+ className: clsx('ipc-player-plugin-voice-intercom', className),
54
+ onLongClick: () => {
55
+ console.log('2222');
56
+ longClickStartedRef.current = true;
57
+ startVoice(!intercom, recording, mute);
58
+ },
59
+ onTouchEnd: () => {
60
+ if (!longClickStartedRef.current) return;
61
+ longClickStartedRef.current = false;
62
+ endVoice();
63
+ }
64
+ }, /*#__PURE__*/React.createElement(View, {
65
+ className: "icon-panel icon-panel-yuyin"
66
+ }));
67
+ }
@@ -0,0 +1,10 @@
1
+ .ipc-player-plugin-voice-intercom {
2
+ background: var(--ipc-player-plugin-voice-bg, radial-gradient(77% 77% at 34% 28%, #FF997C 0%, #FF592A 99%));
3
+ width: 144rpx;
4
+ height: 144rpx;
5
+ border-radius: 144rpx;
6
+ display: flex;
7
+ justify-content: center;
8
+ align-items: center;
9
+ font-size: 58rpx;
10
+ }
@@ -0,0 +1,6 @@
1
+ export type UseBattery = (devId: string) => {
2
+ batteryValue: number;
3
+ batteryCharging: boolean;
4
+ };
5
+ export type UseTemperature = (devId: string) => number;
6
+ export type UseHumidity = () => number;
@@ -0,0 +1 @@
1
+ export {};
package/lib/props.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export interface IProps {
3
+ /**
4
+ * @description.zh 类名
5
+ * @description.en class name
6
+ */
7
+ className?: string;
8
+ /**
9
+ * @description.zh 样式
10
+ * @description.en Style
11
+ */
12
+ style?: React.CSSProperties;
13
+ }
14
+ export declare const defaultProps: IProps;
package/lib/props.js ADDED
@@ -0,0 +1 @@
1
+ export const defaultProps = {};
@@ -0,0 +1 @@
1
+ export * from './ui';
@@ -0,0 +1 @@
1
+ export * from './ui';
package/lib/ui/ui.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { PlayStatusData } from '../interface';
3
+ import { useCtx } from '../ctx/ctx.composition';
4
+ import './ui.less';
5
+ type CtxInstance = ReturnType<typeof useCtx>;
6
+ type CSSVariable = {
7
+ '--iconColor': string;
8
+ '--iconFontSize': string;
9
+ '--bg-color': string;
10
+ '--fontColor': string;
11
+ };
12
+ type Props = {
13
+ devId: string;
14
+ instance?: CtxInstance;
15
+ className?: string;
16
+ onPlayStatus?: (data: PlayStatusData) => void;
17
+ style?: React.CSSProperties;
18
+ CSSVariable?: Partial<CSSVariable>;
19
+ };
20
+ export declare const IPCPlayerIntegration: (props: Props) => React.JSX.Element;
21
+ export {};