@ray-js/ipc-player-integration 0.0.1-beta-9 → 0.0.1-beta-11

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.
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  const _excluded = ["title", "duration"];
4
4
  import { createUseCtx } from './ctx';
5
- import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted } from '../plugins';
5
+ import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution } from '../plugins';
6
6
  import { authorizeStatus } from '../utils/authorize';
7
7
  const createPlayContext = ty.createIpcPlayerContext;
8
8
  // const createPlayContext = () => null;
@@ -27,6 +27,9 @@ const bottomContent = [{
27
27
  }, {
28
28
  id: 'Muted',
29
29
  content: Muted
30
+ }, {
31
+ id: 'Resolution',
32
+ content: Resolution
30
33
  }, {
31
34
  id: 'FullScreen',
32
35
  content: FullScreen
package/lib/ctx/ctx.js CHANGED
@@ -28,6 +28,9 @@ export const createUseCtx = _ref => {
28
28
  // 静音
29
29
  const mute = useAtom(false);
30
30
 
31
+ // 清晰度
32
+ const resolution = useAtom('HD');
33
+
31
34
  // 对讲中
32
35
  const intercom = useAtom(false);
33
36
  const playState = useAtom(PlayState.CONNECTING);
@@ -41,12 +44,19 @@ export const createUseCtx = _ref => {
41
44
  if (!IPCPlayerInstance.current) {
42
45
  IPCPlayerInstance.current = createPlayContext(devId);
43
46
  }
47
+
48
+ /**
49
+ * 设置清晰度
50
+ *
51
+ */
52
+
44
53
  return {
45
54
  devId,
46
55
  saveToAlbum,
47
56
  screenType,
48
57
  recording,
49
58
  mute,
59
+ resolution,
50
60
  intercom,
51
61
  playState,
52
62
  setPlayState,
@@ -104,6 +114,24 @@ export const createUseCtx = _ref => {
104
114
  });
105
115
  });
106
116
  },
117
+ setResolution: async target => {
118
+ console.log('执行清晰度方法');
119
+ return new Promise((resolve, reject) => {
120
+ IPCPlayerInstance.current.setClarity({
121
+ clarity: target,
122
+ success: () => {
123
+ console.log('setClarity success');
124
+ updateAtom(resolution, target === 'hd' ? 'HD' : 'SD');
125
+ resolve(true);
126
+ },
127
+ fail: err => {
128
+ console.log('setClarity err');
129
+ // updateAtom(mute, !target);
130
+ reject(err);
131
+ }
132
+ });
133
+ });
134
+ },
107
135
  setRecording: async target => {
108
136
  const store = getDefaultStore();
109
137
  const _recording = store.get(recording);
@@ -6,3 +6,4 @@ export * from './fullScreen';
6
6
  export * from './videoBitKbps';
7
7
  export * from './voiceIntercom';
8
8
  export * from './muted';
9
+ export * from './resolution';
@@ -5,4 +5,5 @@ export * from './recordVideo';
5
5
  export * from './fullScreen';
6
6
  export * from './videoBitKbps';
7
7
  export * from './voiceIntercom';
8
- export * from './muted';
8
+ export * from './muted';
9
+ export * from './resolution';
@@ -0,0 +1 @@
1
+ export * from './resolution';
@@ -0,0 +1 @@
1
+ export * from './resolution';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './resolution.less';
4
+ export declare const Resolution: (props: ComponentConfigProps) => React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { View, Text } from '@ray-js/ray';
2
+ import React, { useEffect } from 'react';
3
+ import { useStore } from '../../ctx/store';
4
+ import './resolution.less';
5
+ export const Resolution = props => {
6
+ console.log(props, 'props');
7
+ const {
8
+ IPCPlayerContext,
9
+ resolution,
10
+ setResolution
11
+ } = props;
12
+ const {
13
+ currentResolution
14
+ } = useStore({
15
+ currentResolution: resolution
16
+ });
17
+ // const setIsMuted = (value: typeof currentResolution) => {
18
+ // // updateAtom(mute, value);
19
+ // };
20
+
21
+ useEffect(() => {
22
+ // init();
23
+ }, []);
24
+ return /*#__PURE__*/React.createElement(View, {
25
+ onClick: () => {
26
+ console.log('_____');
27
+ setResolution(currentResolution === 'HD' ? 'normal' : 'hd');
28
+ // // IPCPlayerContext.setMuted({
29
+ // // mute: !isMuted,
30
+ // // success: res => {
31
+ // // setIsMuted(!isMuted);
32
+ // // },
33
+ // // fail: res => {
34
+ // // console.log('res===setMuted err', res);
35
+ // // },
36
+ // // });
37
+ },
38
+ className: "resolutionWrapper"
39
+ }, /*#__PURE__*/React.createElement(Text, {
40
+ className: "resolutionText"
41
+ }, currentResolution));
42
+ };
@@ -0,0 +1,15 @@
1
+ .resolutionWrapper {
2
+ background-color: rgba(255,255,255,0.2);
3
+ padding: 2px 4px;
4
+ display: flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ border-radius: 8rpx;
8
+ backdrop-filter: blur(8rpx);
9
+ .resolutionText {
10
+ color: #ffffff;
11
+ font-weight: 600;
12
+ font-size: 24rpx;
13
+
14
+ }
15
+ }
package/lib/ui/ui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useRef, useMemo, useEffect, useCallback } from 'react';
3
- import { View, CoverView, getSystemInfoSync } from '@ray-js/ray';
3
+ import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import IPCPlayer from '@ray-js/ray-ipc-player';
6
6
  import { PlayState, PlayerStreamStatus } from '../interface';
@@ -31,6 +31,7 @@ const defaultCSSVariable = {
31
31
  };
32
32
  const HIDE_COMPONENT_TIME = 5000;
33
33
  export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
34
+ console.log(props, 'props');
34
35
  const {
35
36
  className,
36
37
  devId,
@@ -38,8 +39,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
38
39
  CSSVariable = defaultCSSVariable
39
40
  } = props;
40
41
  const instance = getCtxInstance(props.instance, devId);
42
+ console.log(instance, 'instance');
41
43
  const {
42
- setPlayState
44
+ setPlayState,
45
+ setScreenType
43
46
  } = instance;
44
47
  const prevTriggerEvent = useRef();
45
48
  const eventRef = useRef();
@@ -47,6 +50,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
47
50
  if (!eventRef.current) {
48
51
  eventRef.current = getEventInstance();
49
52
  }
53
+
54
+ /**
55
+ * 监听屏幕布局变化
56
+ */
57
+ usePageEvent('onResize', sizeData => {
58
+ const {
59
+ type
60
+ } = sizeData;
61
+ console.log('监听到屏幕布局变化', type);
62
+ setScreenType(type);
63
+ });
50
64
  const systemInfo = useRef(null);
51
65
  if (!systemInfo.current) {
52
66
  systemInfo.current = getSystemInfoSync();
@@ -175,17 +189,32 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
175
189
  // onCtx={getIpcPlayer}
176
190
  // onPlayerTap={handlePlayerClick}
177
191
  ,
178
- onZoomChange: () => {
179
- console.log('res===onZoomChange');
180
- },
181
- onSessionDidDisconnected: () => {
182
- console.log('res===onSessionDidDisconnected');
192
+ onZoomChange: data => {
193
+ console.log(`zoomChange事件: ${JSON.stringify(data)}`);
194
+ ty.showToast({
195
+ title: `zoomChange事件: ${JSON.stringify(data)}`
196
+ });
197
+ setTimeout(() => {
198
+ ty.hideToast();
199
+ }, 3000);
183
200
  },
184
- onCameraPreviewFailure: () => {
185
- console.log('res===onCameraPreviewFailure');
201
+ onCameraPreviewFailure: data => {
202
+ console.log(`onCameraPreviewFailure事件: ${JSON.stringify(data)}`);
203
+ ty.showToast({
204
+ title: `onCameraPreviewFailure事件: ${JSON.stringify(data)}`
205
+ });
206
+ setTimeout(() => {
207
+ ty.hideToast();
208
+ }, 3000);
186
209
  },
187
- onCameraNotifyWeakNetwork: () => {
188
- console.log('res===onCameraNotifyWeakNetwork');
210
+ onCameraNotifyWeakNetwork: data => {
211
+ console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
212
+ ty.showToast({
213
+ title: `onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`
214
+ });
215
+ setTimeout(() => {
216
+ ty.hideToast();
217
+ }, 3000);
189
218
  },
190
219
  clarity: "hd",
191
220
  privateState: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-9",
3
+ "version": "0.0.1-beta-11",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [