@ledvance/ui-biz-bundle 1.0.28 → 1.0.30
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/package.json +1 -1
- package/src/hooks/DeviceDpStateHooks.d.ts +4 -4
- package/src/modules/biorhythm/BiorhythmActions.d.ts +3 -3
- package/src/modules/biorhythm/BiorhythmEditPage.d.ts +1 -1
- package/src/modules/biorhythm/BiorhythmPage.d.ts +1 -1
- package/src/modules/biorhythm/IconSelect.d.ts +1 -1
- package/src/modules/biorhythm/circular/ItemIcon.d.ts +1 -1
- package/src/modules/biorhythm/circular/Progress.d.ts +1 -1
- package/src/modules/biorhythm/circular/TimeCircular.d.ts +1 -1
- package/src/modules/config/ldvConfig.d.ts +1 -14
- package/src/modules/history/HistoryPage.d.ts +1 -1
- package/src/modules/history/SwitchHistoryPageActions.d.ts +1 -1
- package/src/modules/mood/AddMoodPage.d.ts +1 -1
- package/src/modules/mood/DynamicMoodEditorPage.d.ts +1 -1
- package/src/modules/mood/MoodItem.d.ts +1 -1
- package/src/modules/mood/MoodPage.d.ts +1 -1
- package/src/modules/mood/RecommendMoodItem.d.ts +1 -1
- package/src/modules/mood/StaticMoodEditorPage.d.ts +1 -1
- package/src/modules/music/MusicDataBean.d.ts +47 -0
- package/src/modules/music/MusicDataBean.ts +110 -0
- package/src/modules/music/MusicManager.d.ts +27 -0
- package/src/modules/music/MusicManager.ts +207 -0
- package/src/modules/music/MusicPage.d.ts +10 -0
- package/src/modules/music/MusicPage.tsx +231 -0
- package/src/modules/music/MusicPageActions.d.ts +35 -0
- package/src/modules/music/MusicPageActions.ts +229 -0
- package/src/modules/music/SelecetGenre.d.ts +7 -0
- package/src/modules/music/SelecetGenre.tsx +64 -0
- package/src/modules/music/color.d.ts +2 -0
- package/src/modules/music/color.ts +73 -0
- package/src/modules/music/res/app_music_ball@2x.png +0 -0
- package/src/modules/music/res/app_music_ball@3x.png +0 -0
- package/src/modules/music/res/app_music_game@2x.png +0 -0
- package/src/modules/music/res/app_music_game@3x.png +0 -0
- package/src/modules/music/res/app_music_music@2x.png +0 -0
- package/src/modules/music/res/app_music_music@3x.png +0 -0
- package/src/modules/music/res/app_music_romantic@2x.png +0 -0
- package/src/modules/music/res/app_music_romantic@3x.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck@2x.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck@3x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic@2x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic@3x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled@2x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled@3x.png +0 -0
- package/src/modules/music/res/index.d.ts +10 -0
- package/src/modules/music/res/index.ts +9 -0
- package/src/modules/scene/SceneAction.d.ts +1 -1
- package/src/modules/scene/SceneDetailPage.d.ts +1 -1
- package/src/modules/scene/ScenePage.d.ts +1 -1
- package/src/modules/select/SelectPage.d.ts +1 -1
- package/src/modules/sleepWakeup/DeviceState.d.ts +1 -1
- package/src/modules/sleepWakeup/LdvScheduleItem.d.ts +1 -1
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.d.ts +1 -1
- package/src/modules/sleepWakeup/SleepWakeUpPage.d.ts +2 -2
- package/src/modules/sleepWakeup/utils.d.ts +19 -46
- package/src/modules/timeSchedule/DeviceState.d.ts +1 -1
- package/src/modules/timeSchedule/LdvScheduleItem.d.ts +1 -1
- package/src/modules/timeSchedule/ManualSetting.d.ts +1 -1
- package/src/modules/timeSchedule/MoodSetting.d.ts +1 -1
- package/src/modules/timeSchedule/ScheduleScene.d.ts +1 -1
- package/src/modules/timeSchedule/SingleLightView.d.ts +1 -1
- package/src/modules/timeSchedule/TimeScheduleEditpage.d.ts +1 -1
- package/src/modules/timeSchedule/TimeSchedulePage.d.ts +2 -2
- package/src/modules/timeSchedule/mix/MixLightView.d.ts +1 -1
- package/src/modules/timer/TimerPage.d.ts +2 -2
- package/src/modules/timer/TimerPageAction.d.ts +2 -3
- package/src/navigation/Routers.d.ts +2 -0
- package/src/navigation/Routers.ts +25 -1
- package/src/navigation/tools.ts +1 -1
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@ export declare const modeOptions: {
|
|
|
7
7
|
label: string;
|
|
8
8
|
value: string;
|
|
9
9
|
}[];
|
|
10
|
-
export declare const setBiorhythmDp: (deviceId: string, dpKey: string, value: string) =>
|
|
11
|
-
export declare const setMixRgbcwDp: (deviceId: string, value: string, enable: boolean | undefined, dpCodes: Record<string, string>) =>
|
|
12
|
-
export declare const setSceneDp: (deviceId: string, value: string, sceneDpCode: string, workModeDpCode: string, switchDpCode: string) =>
|
|
13
|
-
export declare const setMixSceneDp: (deviceId: string, value: string, dpCodes: Record<string, string>) =>
|
|
10
|
+
export declare const setBiorhythmDp: (deviceId: string, dpKey: string, value: string) => any;
|
|
11
|
+
export declare const setMixRgbcwDp: (deviceId: string, value: string, enable: boolean | undefined, dpCodes: Record<string, string>) => any;
|
|
12
|
+
export declare const setSceneDp: (deviceId: string, value: string, sceneDpCode: string, workModeDpCode: string, switchDpCode: string) => any;
|
|
13
|
+
export declare const setMixSceneDp: (deviceId: string, value: string, dpCodes: Record<string, string>) => any;
|
|
14
14
|
export declare const useWorkMode: (workModeDpCode: string) => [string, (mode: string) => Promise<Result<any>>];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BiorhythmBean } from './BiorhythmBean';
|
|
2
2
|
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type UseBiorhythmType = (dpKey: string) => [BiorhythmBean, SetBiorhythmType];
|
|
4
|
+
type SetBiorhythmType = (deviceId: string, biorhythmObj: BiorhythmBean) => Promise<Result<any>>;
|
|
5
5
|
export declare const useBiorhythm: UseBiorhythmType;
|
|
6
|
-
export declare const userOperation: (deviceId: string, value: boolean) => Promise<
|
|
6
|
+
export declare const userOperation: (deviceId: string, value: boolean) => Promise<any>;
|
|
7
7
|
export declare function dp2Obj(dp: string): BiorhythmBean;
|
|
8
8
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function IconSelect():
|
|
1
|
+
declare function IconSelect(): any;
|
|
2
2
|
export default IconSelect;
|
|
@@ -6,7 +6,7 @@ export default class Progress extends Component<any> {
|
|
|
6
6
|
constructor(props: any);
|
|
7
7
|
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
8
8
|
componentWillUnmount(): void;
|
|
9
|
-
render():
|
|
9
|
+
render(): any;
|
|
10
10
|
playTimeChangeCallBack(id: number, time: string): void;
|
|
11
11
|
getTimeIntVale(time: any): number;
|
|
12
12
|
createFormTime(totalMinutes: any): string;
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
declare const ldvStyles:
|
|
2
|
-
shadow: {
|
|
3
|
-
shadowColor: string;
|
|
4
|
-
shadowOpacity: number;
|
|
5
|
-
shadowRadius: number;
|
|
6
|
-
elevation: number;
|
|
7
|
-
shadowOffset: {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
backgroundColor: string;
|
|
12
|
-
borderRadius: number;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
1
|
+
declare const ldvStyles: any;
|
|
15
2
|
export default ldvStyles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const SwitchHistoryPage: () =>
|
|
1
|
+
declare const SwitchHistoryPage: () => any;
|
|
2
2
|
export default SwitchHistoryPage;
|
|
@@ -9,6 +9,6 @@ export interface SwitchHistoryUIItemActionData {
|
|
|
9
9
|
action: string;
|
|
10
10
|
dpId: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type getSwitchHistoryDataFunType = (deviceId: string, dpIds: string[], offset: number, limit?: number, stringOn?: string, stringOff?: string, actionKey?: string, showLimit?: boolean) => Promise<PagingResult<SwitchHistoryUIItemData[]>>;
|
|
13
13
|
export declare const getSwitchHistoryData: getSwitchHistoryDataFunType;
|
|
14
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SceneNodeTransitionMode } from '../scene/SceneInfo';
|
|
2
2
|
import { SelectPageData } from '../select/SelectPage';
|
|
3
|
-
declare const DynamicMoodEditorPage: () =>
|
|
3
|
+
declare const DynamicMoodEditorPage: () => any;
|
|
4
4
|
export default DynamicMoodEditorPage;
|
|
5
5
|
export declare function getTransitionModeString(transitionMode: SceneNodeTransitionMode): string;
|
|
6
6
|
export declare function createSelectPageData(transitionMode: SceneNodeTransitionMode, mode: SceneNodeTransitionMode): SelectPageData<SceneNodeTransitionMode>;
|
|
@@ -9,5 +9,5 @@ interface RecommendMoodItemProps {
|
|
|
9
9
|
moodColorsLineProps?: ColorsLineProps;
|
|
10
10
|
onPress: () => void;
|
|
11
11
|
}
|
|
12
|
-
export default function RecommendMoodItem(props: RecommendMoodItemProps):
|
|
12
|
+
export default function RecommendMoodItem(props: RecommendMoodItemProps): any;
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface AppleMusicColorAreaType {
|
|
2
|
+
area: number[];
|
|
3
|
+
hue: number;
|
|
4
|
+
saturation: number;
|
|
5
|
+
value: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AppleMusicDataType {
|
|
8
|
+
mode: number;
|
|
9
|
+
hue: number;
|
|
10
|
+
saturation: number;
|
|
11
|
+
value: number;
|
|
12
|
+
brightness: number;
|
|
13
|
+
temperature: number;
|
|
14
|
+
}
|
|
15
|
+
export interface AppMusicListItemType {
|
|
16
|
+
id: number;
|
|
17
|
+
mode: number;
|
|
18
|
+
title: string;
|
|
19
|
+
colorArea?: AppleMusicColorAreaType[];
|
|
20
|
+
}
|
|
21
|
+
export interface OpenMusicOptions {
|
|
22
|
+
isColourExist?: boolean;
|
|
23
|
+
isTempExist?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type MusicCallback = (data: AppleMusicDataType, i: number) => void;
|
|
26
|
+
export declare const musicDefalutDatasource: ({
|
|
27
|
+
id: number;
|
|
28
|
+
mode: number;
|
|
29
|
+
title: any;
|
|
30
|
+
icon: any;
|
|
31
|
+
lable: any;
|
|
32
|
+
value: any;
|
|
33
|
+
colorArea?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
id: number;
|
|
36
|
+
mode: number;
|
|
37
|
+
title: any;
|
|
38
|
+
icon: any;
|
|
39
|
+
colorArea: {
|
|
40
|
+
area: number[];
|
|
41
|
+
hue: number;
|
|
42
|
+
saturation: number;
|
|
43
|
+
value: number;
|
|
44
|
+
}[];
|
|
45
|
+
lable: any;
|
|
46
|
+
value: any;
|
|
47
|
+
})[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import Strings from '@ledvance/base/src/i18n'
|
|
2
|
+
import res from './res'
|
|
3
|
+
|
|
4
|
+
export interface AppleMusicColorAreaType {
|
|
5
|
+
area: number[];
|
|
6
|
+
hue: number;
|
|
7
|
+
saturation: number;
|
|
8
|
+
value: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AppleMusicDataType {
|
|
12
|
+
mode: number;
|
|
13
|
+
hue: number;
|
|
14
|
+
saturation: number;
|
|
15
|
+
value: number;
|
|
16
|
+
brightness: number;
|
|
17
|
+
temperature: number;
|
|
18
|
+
}
|
|
19
|
+
export interface AppMusicListItemType {
|
|
20
|
+
id: number;
|
|
21
|
+
mode: number;
|
|
22
|
+
title: string;
|
|
23
|
+
colorArea?: AppleMusicColorAreaType[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface OpenMusicOptions {
|
|
27
|
+
isColourExist?: boolean;
|
|
28
|
+
isTempExist?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type MusicCallback = (data: AppleMusicDataType, i: number) => void;
|
|
31
|
+
export const musicDefalutDatasource = [
|
|
32
|
+
{
|
|
33
|
+
id: 0,
|
|
34
|
+
mode: 1,
|
|
35
|
+
title: Strings.getLang('devicemusic_music_text'),
|
|
36
|
+
icon: res.app_music_music,
|
|
37
|
+
lable: Strings.getLang('devicemusic_music_text'),
|
|
38
|
+
value: Strings.getLang('devicemusic_music_text')
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 1,
|
|
42
|
+
mode: 0,
|
|
43
|
+
title: Strings.getLang('devicemusic_ball_game_text'),
|
|
44
|
+
icon: res.app_music_ball,
|
|
45
|
+
lable: Strings.getLang('devicemusic_ball_game_text'),
|
|
46
|
+
value: Strings.getLang('devicemusic_ball_game_text')
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 2,
|
|
50
|
+
mode: 0,
|
|
51
|
+
title: Strings.getLang('devicemusic_game_text'),
|
|
52
|
+
icon: res.app_music_game,
|
|
53
|
+
colorArea: [
|
|
54
|
+
{
|
|
55
|
+
area: [0, 2],
|
|
56
|
+
hue: 350,
|
|
57
|
+
saturation: 400,
|
|
58
|
+
value: 1000,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
area: [3, 5],
|
|
62
|
+
hue: 50,
|
|
63
|
+
saturation: 600,
|
|
64
|
+
value: 1000,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
area: [6, 9],
|
|
68
|
+
hue: 160,
|
|
69
|
+
saturation: 600,
|
|
70
|
+
value: 1000,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
lable: Strings.getLang('devicemusic_game_text'),
|
|
74
|
+
value: Strings.getLang('devicemusic_game_text')
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 3,
|
|
78
|
+
mode: 1,
|
|
79
|
+
title: Strings.getLang('devicemusic_romantic_text'),
|
|
80
|
+
icon: res.app_music_romantic,
|
|
81
|
+
colorArea: [
|
|
82
|
+
{
|
|
83
|
+
area: [0, 2],
|
|
84
|
+
hue: 20,
|
|
85
|
+
saturation: 100,
|
|
86
|
+
value: 1000,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
area: [3, 4],
|
|
90
|
+
hue: 0,
|
|
91
|
+
saturation: 1000,
|
|
92
|
+
value: 1000,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
area: [5, 6],
|
|
96
|
+
hue: 350,
|
|
97
|
+
saturation: 400,
|
|
98
|
+
value: 1000,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
area: [7, 9],
|
|
102
|
+
hue: 300,
|
|
103
|
+
saturation: 1000,
|
|
104
|
+
value: 1000,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
lable: Strings.getLang('devicemusic_romantic_text'),
|
|
108
|
+
value: Strings.getLang('devicemusic_romantic_text')
|
|
109
|
+
},
|
|
110
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppleMusicDataType, AppMusicListItemType } from './MusicDataBean';
|
|
2
|
+
interface OpenMusicOptions {
|
|
3
|
+
isColourExist?: boolean;
|
|
4
|
+
isTempExist?: boolean;
|
|
5
|
+
}
|
|
6
|
+
type MusicCallback = (data: AppleMusicDataType, i: number) => void;
|
|
7
|
+
type Type = 'checking' | 'failure' | 'success' | 'close';
|
|
8
|
+
export declare const addListener: (type: Type, cb: Function) => void;
|
|
9
|
+
export declare const removeListener: (type: Type, cb: Function) => void;
|
|
10
|
+
export declare const handleAudioRgbChange: any;
|
|
11
|
+
/**
|
|
12
|
+
* Turn on the microphone and start monitoring
|
|
13
|
+
*/
|
|
14
|
+
export declare const open: (musicOption: AppMusicListItemType, musicCallback: MusicCallback, onMusicDataPut: (data: AppleMusicDataType) => void, options: OpenMusicOptions) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Turn off the microphone
|
|
17
|
+
*/
|
|
18
|
+
export declare const close: (needFire?: boolean) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Suspend sending
|
|
21
|
+
*/
|
|
22
|
+
export declare const pause: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Continue to send
|
|
25
|
+
*/
|
|
26
|
+
export declare const resume: () => void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* eslint-disable consistent-return */
|
|
2
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
import { NativeModules } from 'react-native';
|
|
6
|
+
import { TYSdk } from 'tuya-panel-kit';
|
|
7
|
+
import _ from 'lodash';
|
|
8
|
+
import ColorUtils from './color';
|
|
9
|
+
import { AppleMusicDataType, AppMusicListItemType } from './MusicDataBean';
|
|
10
|
+
|
|
11
|
+
interface OpenMusicOptions {
|
|
12
|
+
isColourExist?: boolean;
|
|
13
|
+
isTempExist?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type MusicCallback = (data: AppleMusicDataType, i: number) => void;
|
|
16
|
+
type Type = 'checking' | 'failure' | 'success' | 'close';
|
|
17
|
+
|
|
18
|
+
const { native: TYNative, DeviceEventEmitter: DeviceEvent } = TYSdk;
|
|
19
|
+
const { TYRCTMusicManager: TYPublicNative } = NativeModules;
|
|
20
|
+
let isListening = false;
|
|
21
|
+
let isSendEnabled = true;
|
|
22
|
+
let timeOutTimer: number;
|
|
23
|
+
const listeners: {
|
|
24
|
+
checking?: Function[];
|
|
25
|
+
failure?: Function[];
|
|
26
|
+
success?: Function[];
|
|
27
|
+
close?: Function[];
|
|
28
|
+
} = {};
|
|
29
|
+
|
|
30
|
+
const startVoice = async () =>
|
|
31
|
+
new Promise((resolve, reject) => {
|
|
32
|
+
TYPublicNative.startVoice(d => {
|
|
33
|
+
TYNative.screenAlwaysOn(true);
|
|
34
|
+
resolve(d);
|
|
35
|
+
}, reject);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const stopVoice = async () =>
|
|
39
|
+
new Promise((resolve, reject) => {
|
|
40
|
+
TYPublicNative.stopVoice(d => {
|
|
41
|
+
TYNative.screenAlwaysOn(false);
|
|
42
|
+
resolve(d);
|
|
43
|
+
}, reject);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const fireEvent = (type: Type) => {
|
|
47
|
+
listeners[type]?.forEach((cb: Function) => {
|
|
48
|
+
cb?.();
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleTimeOut = () => {
|
|
53
|
+
return setTimeout(() => {
|
|
54
|
+
// If there is no audio input within 10 seconds, call the detection event
|
|
55
|
+
fireEvent('checking');
|
|
56
|
+
// If there is no audio input within 30 seconds, call the missing event and actively stop monitoring
|
|
57
|
+
timeOutTimer = setTimeout(() => {
|
|
58
|
+
close(false);
|
|
59
|
+
fireEvent('failure');
|
|
60
|
+
}, 30000);
|
|
61
|
+
}, 10000);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleSuccess = _.throttle(() => {
|
|
65
|
+
fireEvent('success');
|
|
66
|
+
}, 1000);
|
|
67
|
+
|
|
68
|
+
export const addListener = (type: Type, cb: Function) => {
|
|
69
|
+
if (!listeners[type]) {
|
|
70
|
+
listeners[type] = [];
|
|
71
|
+
}
|
|
72
|
+
listeners[type].push(cb);
|
|
73
|
+
};
|
|
74
|
+
export const removeListener = (type: Type, cb: Function) => {
|
|
75
|
+
if (listeners[type]) {
|
|
76
|
+
const index = listeners[type].indexOf(cb);
|
|
77
|
+
if (index >= 0) {
|
|
78
|
+
listeners[type].splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const handleAudioRgbChange = _.throttle(
|
|
84
|
+
(
|
|
85
|
+
{ R, G, B, C: temp, L: bright, index }: any,
|
|
86
|
+
musicOption: AppMusicListItemType,
|
|
87
|
+
musicCallback: MusicCallback,
|
|
88
|
+
onMusicDataPut: (data: AppleMusicDataType) => void,
|
|
89
|
+
options: OpenMusicOptions
|
|
90
|
+
) => {
|
|
91
|
+
if (!isListening) return;
|
|
92
|
+
const { isColourExist, isTempExist } = options;
|
|
93
|
+
|
|
94
|
+
clearTimeout(timeOutTimer);
|
|
95
|
+
timeOutTimer = handleTimeOut();
|
|
96
|
+
handleSuccess();
|
|
97
|
+
let hue = 0;
|
|
98
|
+
let saturation = 0;
|
|
99
|
+
let value = 0;
|
|
100
|
+
let brightness = 0;
|
|
101
|
+
let temperature = 0;
|
|
102
|
+
|
|
103
|
+
const { mode, colorArea } = musicOption;
|
|
104
|
+
|
|
105
|
+
if (isColourExist) {
|
|
106
|
+
[hue, saturation, value] = ColorUtils.rgb2hsb(R, G, B).map((v, i) => (i > 0 ? v * 10 : v));
|
|
107
|
+
} else {
|
|
108
|
+
// 是否支持白光音乐功能
|
|
109
|
+
if (typeof bright === 'undefined' || typeof temp === 'undefined') return;
|
|
110
|
+
|
|
111
|
+
brightness = bright * 10;
|
|
112
|
+
temperature = temp * 10;
|
|
113
|
+
if (!isTempExist) temperature = 1000;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (colorArea) {
|
|
117
|
+
colorArea.forEach(({ area, hue: h, saturation: s, value: v }) => {
|
|
118
|
+
const [left, right] = area;
|
|
119
|
+
if (index >= left && index <= right) {
|
|
120
|
+
hue = h;
|
|
121
|
+
saturation = s;
|
|
122
|
+
value = v;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const musicData: AppleMusicDataType = {
|
|
128
|
+
mode,
|
|
129
|
+
hue: Math.round(hue),
|
|
130
|
+
saturation: Math.round(saturation),
|
|
131
|
+
value: Math.round(value),
|
|
132
|
+
brightness,
|
|
133
|
+
temperature,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
musicCallback(musicData, index || 5);
|
|
137
|
+
|
|
138
|
+
if (isListening && isSendEnabled) onMusicDataPut?.(musicData);
|
|
139
|
+
},
|
|
140
|
+
300
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Turn on the microphone and start monitoring
|
|
145
|
+
*/
|
|
146
|
+
export const open = async (
|
|
147
|
+
musicOption: AppMusicListItemType,
|
|
148
|
+
musicCallback: MusicCallback,
|
|
149
|
+
onMusicDataPut: (data: AppleMusicDataType) => void,
|
|
150
|
+
options: OpenMusicOptions
|
|
151
|
+
) => {
|
|
152
|
+
if (isListening) return Promise.resolve();
|
|
153
|
+
|
|
154
|
+
if (!isSendEnabled) {
|
|
155
|
+
resume();
|
|
156
|
+
} else {
|
|
157
|
+
try {
|
|
158
|
+
DeviceEvent.addListener('audioRgbChange', (musicData: any) => {
|
|
159
|
+
handleAudioRgbChange(musicData, musicOption, musicCallback, onMusicDataPut, options);
|
|
160
|
+
});
|
|
161
|
+
// Turn on the microphone
|
|
162
|
+
await startVoice();
|
|
163
|
+
isListening = true;
|
|
164
|
+
isSendEnabled = true;
|
|
165
|
+
} catch (e) {
|
|
166
|
+
return Promise.reject(e);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Turn off the microphone
|
|
173
|
+
*/
|
|
174
|
+
export const close = async (needFire = true) => {
|
|
175
|
+
if (!isListening) return Promise.resolve();
|
|
176
|
+
|
|
177
|
+
handleSuccess.cancel();
|
|
178
|
+
clearTimeout(timeOutTimer);
|
|
179
|
+
needFire && fireEvent('close');
|
|
180
|
+
isListening = false;
|
|
181
|
+
isSendEnabled = true;
|
|
182
|
+
try {
|
|
183
|
+
DeviceEvent.removeAllListeners('audioRgbChange');
|
|
184
|
+
|
|
185
|
+
// Turn off the microphone
|
|
186
|
+
await stopVoice();
|
|
187
|
+
// Turn off keep screen
|
|
188
|
+
TYNative.screenAlwaysOn(false);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
return Promise.reject(e);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Suspend sending
|
|
196
|
+
*/
|
|
197
|
+
export const pause = () => {
|
|
198
|
+
handleSuccess.cancel();
|
|
199
|
+
isSendEnabled = false;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Continue to send
|
|
204
|
+
*/
|
|
205
|
+
export const resume = () => {
|
|
206
|
+
isSendEnabled = true;
|
|
207
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JudgeTimeScheduleProps } from "@ledvance/ui-biz-bundle/src/modules/timeSchedule/TimeScheduleBean";
|
|
2
|
+
export interface MusicPageRouterParams extends JudgeTimeScheduleProps {
|
|
3
|
+
switch_led: string;
|
|
4
|
+
work_mode: string;
|
|
5
|
+
mix_rgbcw: string;
|
|
6
|
+
mix_light_scene: string;
|
|
7
|
+
music_data: string;
|
|
8
|
+
}
|
|
9
|
+
declare const MusicPage: () => any;
|
|
10
|
+
export default MusicPage;
|