@ray-js/ipc-player-integration 0.0.1-beta-7 → 0.0.1-beta-8

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 (34) hide show
  1. package/lib/ctx/ctx.composition.js +17 -1
  2. package/lib/ctx/ctx.d.ts +3 -2
  3. package/lib/ctx/ctx.js +29 -8
  4. package/lib/ctx/ports.output.d.ts +1 -0
  5. package/lib/hooks/index.d.ts +0 -1
  6. package/lib/hooks/index.js +0 -1
  7. package/lib/iconfont/demo_index.html +491 -123
  8. package/lib/iconfont/iconfont.css +87 -23
  9. package/lib/iconfont/iconfont.js +15 -15
  10. package/lib/iconfont/iconfont.json +154 -42
  11. package/lib/iconfont/iconfont.ttf +0 -0
  12. package/lib/iconfont/iconfont.woff +0 -0
  13. package/lib/iconfont/iconfont.woff2 +0 -0
  14. package/lib/interface.d.ts +2 -0
  15. package/lib/plugins/battery/battery.composition.d.ts +1 -0
  16. package/lib/plugins/fullScreen/fullScreen.js +1 -1
  17. package/lib/plugins/fullScreen/verticalScreen.js +1 -1
  18. package/lib/plugins/muted/muted.js +2 -2
  19. package/lib/plugins/recordVideo/recordVideo.js +25 -7
  20. package/lib/plugins/recordVideo/recordVideo.less +6 -4
  21. package/lib/plugins/screenshot/screenshot.js +34 -23
  22. package/lib/plugins/screenshot/screenshot.less +6 -3
  23. package/lib/plugins/tempHumidity/tempHumidity.js +3 -3
  24. package/lib/plugins/videoBitKbps/videoBitKbps.js +28 -4
  25. package/lib/plugins/voiceIntercom/type.d.ts +4 -0
  26. package/lib/plugins/voiceIntercom/voice.gif +0 -0
  27. package/lib/plugins/voiceIntercom/voiceIntercom.d.ts +2 -1
  28. package/lib/plugins/voiceIntercom/voiceIntercom.js +41 -36
  29. package/lib/plugins/voiceIntercom/voiceIntercom.less +7 -1
  30. package/lib/ports.output.d.ts +4 -0
  31. package/lib/ui/ui.js +2 -1
  32. package/package.json +1 -1
  33. package/lib/hooks/useVideoBitKbps/index.d.ts +0 -1
  34. package/lib/hooks/useVideoBitKbps/index.js +0 -22
@@ -1,6 +1,9 @@
1
- import React, { useState, useEffect, useRef } from 'react';
1
+ import React, { useState, useEffect, useRef, useContext } from 'react';
2
2
  import { View } from '@ray-js/ray';
3
- import { useStore } from '../../ctx/store';
3
+ import clsx from 'clsx';
4
+ import { UIEventContext } from '../../ui/context';
5
+ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
6
+ import { useStore, getDefaultStore } from '../../ctx/store';
4
7
  import './recordVideo.less';
5
8
  const RECORD_VIDEO_TOAST_ID = 'record_video_toast_id';
6
9
  function formatTimeDiff(diff) {
@@ -62,6 +65,9 @@ function TimeRecord() {
62
65
  }, sec));
63
66
  }
64
67
  export function RecordVideo(props) {
68
+ const {
69
+ event
70
+ } = useContext(UIEventContext);
65
71
  const {
66
72
  addContent,
67
73
  deleteContent
@@ -75,23 +81,35 @@ export function RecordVideo(props) {
75
81
  } = useStore({
76
82
  recording: recordingAtom
77
83
  });
78
- const handRecordVideo = async target => {
79
- await setRecording(target);
84
+ const handRecordVideo = async () => {
85
+ const store = getDefaultStore();
86
+ const _recording = store.get(recordingAtom);
87
+ const target = !_recording;
80
88
  if (target) {
81
- deleteContent('absolute', RECORD_VIDEO_TOAST_ID);
89
+ event.emit(pauseTimeToHideAllComponent);
82
90
  } else {
91
+ event.emit(startTimeToHideAllComponent);
92
+ }
93
+ await setRecording(target);
94
+ if (target) {
83
95
  addContent('absolute', {
84
96
  id: RECORD_VIDEO_TOAST_ID,
97
+ absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
85
98
  content: () => /*#__PURE__*/React.createElement(View, {
86
99
  className: "ipc-player-plugin-record-video-toast"
87
100
  }, /*#__PURE__*/React.createElement(View, {
88
101
  className: "ipc-player-plugin-record-video-toast-point"
89
102
  }), /*#__PURE__*/React.createElement(TimeRecord, null))
90
103
  });
104
+ } else {
105
+ deleteContent('absolute', RECORD_VIDEO_TOAST_ID);
91
106
  }
92
107
  };
93
108
  return /*#__PURE__*/React.createElement(View, {
94
- onClick: () => handRecordVideo(!recording),
95
- className: "ipc-player-plugin-record-video-icon icon-panel icon-panel-luping"
109
+ onClick: () => handRecordVideo(),
110
+ className: clsx('ipc-player-plugin-record-video-icon', 'icon-panel', recording ? 'icon-panel-record-stop' : 'icon-panel-record'),
111
+ style: {
112
+ color: recording ? 'rgba(255, 56, 56, 1)' : undefined
113
+ }
96
114
  });
97
115
  }
@@ -2,15 +2,17 @@
2
2
  font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
3
3
  color: var(--iconColor);
4
4
  }
5
- .ipc-player-plugin-record-video-toast {
5
+ .ipc-player-plugin-record-video-toast-wrap {
6
6
  z-index: 2;
7
7
  position: absolute;
8
+ top: calc(7px * var(--ipc-player-size-scale, 1));
9
+ left: 50%;
10
+ transform: translateX(-50%);
11
+ }
12
+ .ipc-player-plugin-record-video-toast {
8
13
  display: flex;
9
14
  padding: calc(12px * var(--ipc-player-size-scale, 1));
10
15
  align-items: center;
11
- left: 50%;
12
- transform: translateX(-50%);
13
- top: calc(7px * var(--ipc-player-size-scale, 1));
14
16
  background-color: var(--bg-color);
15
17
  border-radius: calc(8px * var(--ipc-player-size-scale, 1));
16
18
  .ipc-player-plugin-record-video-toast-point {
@@ -1,5 +1,6 @@
1
1
  import React, { useRef } from 'react';
2
- import { View, Image, CoverView } from '@ray-js/ray';
2
+ import { View, Image } from '@ray-js/ray';
3
+ import IpcUtils from '@ray-js/ray-ipc-utils';
3
4
  import './screenshot.less';
4
5
  const CLOSE_TIME = 5000;
5
6
  export function Screenshot(props) {
@@ -7,7 +8,9 @@ export function Screenshot(props) {
7
8
  IPCPlayerContext,
8
9
  addContent,
9
10
  saveToAlbum,
10
- deleteContent
11
+ deleteContent,
12
+ devId,
13
+ toast
11
14
  } = props;
12
15
  const timer = useRef();
13
16
  const timeToCloseToast = () => {
@@ -18,7 +21,28 @@ export function Screenshot(props) {
18
21
  }, CLOSE_TIME);
19
22
  };
20
23
  const handCheck = () => {
21
- console.log('handCheck');
24
+ IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
25
+ };
26
+ const showToast = str => {
27
+ deleteContent('absolute', 'plugin-screenshot-toast');
28
+ addContent('absolute', {
29
+ id: 'plugin-screenshot-toast',
30
+ absoluteContentClassName: 'ipc-player-plugin-screenshot-toast-warp',
31
+ content: () => {
32
+ return /*#__PURE__*/React.createElement(View, {
33
+ className: "ipc-player-plugin-screenshot-toast"
34
+ }, /*#__PURE__*/React.createElement(Image, {
35
+ className: "ipc-player-plugin-screenshot-toast-image",
36
+ src: str
37
+ }), /*#__PURE__*/React.createElement(View, {
38
+ className: "ipc-player-plugin-screenshot-toast-title"
39
+ }, I18n.t('screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
40
+ onClick: handCheck,
41
+ className: "ipc-player-plugin-screenshot-toast-bottom"
42
+ }, I18n.t('check')));
43
+ }
44
+ });
45
+ timeToCloseToast();
22
46
  };
23
47
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
24
48
  onClick: () => {
@@ -26,30 +50,17 @@ export function Screenshot(props) {
26
50
  saveToAlbum,
27
51
  // 保存到 IPC 相册
28
52
  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();
53
+ showToast(res.tempImagePath);
47
54
  },
48
55
  fail: err => {
49
- console.log('保存相册失败', err);
56
+ const errObj = err.innerError || err || {};
57
+ const errMsg = errObj.errorMsg || I18n.t('error_screenshot');
58
+ toast({
59
+ title: errMsg
60
+ });
50
61
  }
51
62
  });
52
63
  },
53
- className: "icon-panel icon-panel-jieping ipc-player-plugin-screenshot-icon"
64
+ className: "icon-panel icon-panel-screenshot ipc-player-plugin-screenshot-icon"
54
65
  }));
55
66
  }
@@ -2,14 +2,17 @@
2
2
  color: var(--iconColor);
3
3
  font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
4
4
  }
5
- .ipc-player-plugin-screenshot-toast {
5
+ .ipc-player-plugin-screenshot-toast-warp {
6
6
  position: absolute;
7
7
  width: 90%;
8
- border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
9
- background-color: var(--bg-color);
8
+ max-width: 750rpx;
10
9
  left: 50%;
11
10
  transform: translateX(-50%);
12
11
  top: calc(16px * var(--ipc-player-size-scale, 1));
12
+ }
13
+ .ipc-player-plugin-screenshot-toast {
14
+ border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
15
+ background-color: var(--bg-color);
13
16
  display: flex;
14
17
  align-items: center;
15
18
  padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(16px * var(--ipc-player-size-scale, 1));
@@ -17,20 +17,20 @@ export const TempHumidity = props => {
17
17
  const tempRender = () => {
18
18
  if (tempUnit === '1') {
19
19
  return tempF && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
20
- className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-wendu"
20
+ className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-temperature"
21
21
  }), /*#__PURE__*/React.createElement(Text, {
22
22
  className: "tempHumidity"
23
23
  }, tempF));
24
24
  }
25
25
  return tempC && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
26
- className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-wendu"
26
+ className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-temperature"
27
27
  }), /*#__PURE__*/React.createElement(Text, null, tempC), /*#__PURE__*/React.createElement(Text, {
28
28
  className: "ipc-player-plugin-tempHumidity-divider"
29
29
  }, "/"));
30
30
  };
31
31
  const humRender = () => {
32
32
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
33
- className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-shidu"
33
+ className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-humidity"
34
34
  }), /*#__PURE__*/React.createElement(Text, {
35
35
  className: "tempHumidity"
36
36
  }, `${humidity}`));
@@ -1,12 +1,36 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { View } from '@ray-js/ray';
3
- import { useVideoBitKbps } from '../../hooks';
4
3
  import './videoBitKbps.less';
4
+ import IpcUtils from '@ray-js/ray-ipc-utils';
5
+ import { PlayState } from '../../interface';
6
+ import { useStore } from '../../ctx/store';
5
7
  export const VideoBitKbps = props => {
6
8
  const {
7
- devId
9
+ devId,
10
+ playState
8
11
  } = props;
9
- const bitKbps = useVideoBitKbps(devId);
12
+ const [bitKbps, setBitKbps] = useState('');
13
+ const store = useStore({
14
+ playState
15
+ });
16
+ useEffect(() => {
17
+ let timer;
18
+ if (store.playState === PlayState.PLAYING) {
19
+ init();
20
+ timer = setInterval(() => {
21
+ init();
22
+ }, 5000);
23
+ }
24
+ return () => {
25
+ clearInterval(timer);
26
+ };
27
+ }, [store.playState]);
28
+ const init = async () => {
29
+ const res = await IpcUtils.getVideoBitrateKbps(devId);
30
+ if (res.code !== -1) {
31
+ setBitKbps(`${res.data.kbps}KB/S`);
32
+ }
33
+ };
10
34
  return /*#__PURE__*/React.createElement(View, {
11
35
  className: "ipc-player-plugin-videoBitKbps"
12
36
  }, bitKbps);
@@ -0,0 +1,4 @@
1
+ declare module '*.gif' {
2
+ const content: any;
3
+ export default content;
4
+ }
@@ -5,8 +5,9 @@ import { ComponentConfigProps } from '../../interface';
5
5
  type Props = ComponentConfigProps & {
6
6
  style?: React.CSSProperties;
7
7
  className?: string;
8
+ iconClassName?: string;
8
9
  onTouchStart?: TouchEventHandler['onTouchStart'];
9
10
  onTouchEnd?: TouchEventHandler['onTouchEnd'];
10
11
  };
11
- export declare function VoiceIntercom({ style, className, recording: recordingAtom, intercom: intercomAtom, setIntercom, mute: muteAtom, setMute, getStreamStatus, onTouchStart, onTouchEnd, }: Props): React.JSX.Element;
12
+ export declare function VoiceIntercom({ style, className, iconClassName, recording: recordingAtom, intercom: intercomAtom, setIntercom, mute: muteAtom, setMute, getStreamStatus, onTouchStart, onTouchEnd, }: Props): React.JSX.Element;
12
13
  export {};
@@ -1,15 +1,19 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import React, { useRef } from 'react';
3
- import { View } from '@ray-js/ray';
2
+ import React, { useRef, useContext } from 'react';
3
+ import { View, Image } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
- import { useStore } from '../../ctx/store';
5
+ import Res from './voice.gif';
6
+ import { useStore, getDefaultStore } from '../../ctx/store';
6
7
  import './voiceIntercom.less';
7
8
  import { PlayerStreamStatus } from '../../interface';
9
+ import { UIEventContext } from '../../ui/context';
10
+ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
8
11
  const NILL = () => null;
9
12
  export function VoiceIntercom(_ref) {
10
13
  let {
11
14
  style,
12
15
  className,
16
+ iconClassName,
13
17
  recording: recordingAtom,
14
18
  intercom: intercomAtom,
15
19
  setIntercom,
@@ -20,62 +24,63 @@ export function VoiceIntercom(_ref) {
20
24
  onTouchEnd = NILL
21
25
  } = _ref;
22
26
  const {
23
- recording,
27
+ event
28
+ } = useContext(UIEventContext);
29
+ const {
24
30
  mute,
25
31
  intercom
26
32
  } = useStore({
27
- recording: recordingAtom,
28
33
  mute: muteAtom,
29
34
  intercom: intercomAtom
30
35
  });
31
- const longClickStartedRef = useRef(false);
32
36
  // 对讲开始之前的静音状态
33
37
  const originMuteStatusBeforeVoice = useRef(mute);
34
- const intercomRef = useRef(false);
35
- const startVoice = async (_intercom, _recording, _mute) => {
36
- if (intercomRef.current) return;
37
- if (_recording) {
38
- console.log('Cannot talk during video recording');
39
- return;
40
- }
38
+ const loading = useRef(false);
39
+ const startVoice = async _mute => {
41
40
  if (getStreamStatus() !== PlayerStreamStatus.PreviewSuccess) {
42
41
  console.log('PlayerStreamStatus not 1002');
43
42
  return;
44
43
  }
45
- intercomRef.current = true;
46
44
  originMuteStatusBeforeVoice.current = _mute;
47
45
  // 如果对讲开始之前,是静音的,则需要关闭静音
48
46
  if (_mute) {
49
47
  await setMute(false);
50
48
  }
51
- setIntercom(_intercom);
49
+ await setIntercom(true);
52
50
  };
53
51
  const endVoice = async () => {
54
- try {
55
- // 将静音状态恢复为开始对讲之前的状态
56
- await setMute(originMuteStatusBeforeVoice.current);
57
- await setIntercom(false);
58
- } catch (err) {
59
- //
60
- } finally {
61
- intercomRef.current = false;
62
- }
52
+ await setMute(originMuteStatusBeforeVoice.current);
53
+ await setIntercom(false);
63
54
  };
64
55
  return /*#__PURE__*/React.createElement(View, {
65
56
  style: _objectSpread({}, style),
66
57
  className: clsx('ipc-player-plugin-voice-intercom', className),
67
- onTouchStart: onTouchStart,
68
- onLongClick: () => {
69
- longClickStartedRef.current = true;
70
- startVoice(!intercom, recording, mute);
58
+ onTouchStart: async e => {
59
+ onTouchStart(e);
60
+ const store = getDefaultStore();
61
+ if (loading.current) return;
62
+ loading.current = true;
63
+ const _intercom = store.get(intercomAtom);
64
+ const _recording = store.get(recordingAtom);
65
+ if (!_intercom && _recording) {
66
+ console.log('录制中,无法对讲');
67
+ loading.current = false;
68
+ return;
69
+ }
70
+ if (!_intercom) {
71
+ event.emit(pauseTimeToHideAllComponent);
72
+ await startVoice(mute);
73
+ } else {
74
+ event.emit(startTimeToHideAllComponent);
75
+ await endVoice();
76
+ }
77
+ loading.current = false;
71
78
  },
72
- onTouchEnd: e => {
73
- onTouchEnd(e);
74
- if (!longClickStartedRef.current) return;
75
- longClickStartedRef.current = false;
76
- endVoice();
77
- }
78
- }, /*#__PURE__*/React.createElement(View, {
79
- className: "icon-panel icon-panel-yuyin"
79
+ onTouchEnd: onTouchEnd
80
+ }, intercom ? /*#__PURE__*/React.createElement(Image, {
81
+ src: Res,
82
+ className: clsx('ipc-player-plugin-voice-intercom-img', iconClassName)
83
+ }) : /*#__PURE__*/React.createElement(View, {
84
+ className: clsx('icon-panel', 'icon-panel-one-way-intercom', iconClassName)
80
85
  }));
81
86
  }
@@ -1,3 +1,5 @@
1
+ @size: 24px;
2
+
1
3
  .ipc-player-plugin-voice-intercom {
2
4
  background: var(--ipc-player-plugin-voice-bg, radial-gradient(77% 77% at 34% 28%, #FF997C 0%, #FF592A 99%));
3
5
  width: calc(72px * var(--ipc-player-size-scale, 1));
@@ -6,6 +8,10 @@
6
8
  display: flex;
7
9
  justify-content: center;
8
10
  align-items: center;
9
- font-size: calc(29px * var(--ipc-player-size-scale, 1));
11
+ font-size: calc(@size * var(--ipc-player-size-scale, 1));
10
12
  color: #fff;
13
+ }
14
+ .ipc-player-plugin-voice-intercom-img {
15
+ width: calc(@size * var(--ipc-player-size-scale, 1));
16
+ height: calc(@size * var(--ipc-player-size-scale, 1));;
11
17
  }
@@ -4,3 +4,7 @@ export type UseBattery = (devId: string) => {
4
4
  };
5
5
  export type UseTemperature = (devId: string) => number;
6
6
  export type UseHumidity = () => number;
7
+ export type Toast = (options: {
8
+ title: string;
9
+ duration?: number;
10
+ } & Record<string, any>) => void;
package/lib/ui/ui.js CHANGED
@@ -139,7 +139,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
139
139
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
140
140
  };
141
141
  });
142
- const playerReady = playState === PlayState.PLAYING;
142
+ // const playerReady = playState === PlayState.PLAYING;
143
+ const playerReady = true;
143
144
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
144
145
  value: {
145
146
  event: eventRef.current
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-7",
3
+ "version": "0.0.1-beta-8",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -1 +0,0 @@
1
- export declare const useVideoBitKbps: (devId: string) => string;
@@ -1,22 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import IpcUtils from '@ray-js/ray-ipc-utils';
3
- export const useVideoBitKbps = devId => {
4
- const [bitKbps, setBitKbps] = useState('');
5
- useEffect(() => {
6
- // const timer = setInterval(() => {
7
- init();
8
- // }, 1000);
9
- // return () => {
10
- // clearInterval(timer);
11
- // timer === null;
12
- // };
13
- }, []);
14
- const init = async () => {
15
- const res = await IpcUtils.getVideoBitrateKbps(devId);
16
- console.log('res===getVideoBitrateKbps', res);
17
- if (res.code !== -1) {
18
- setBitKbps(res.data.kbps + 'KB/S');
19
- }
20
- };
21
- return bitKbps;
22
- };