Commit e16f1a2a authored by martin hou's avatar martin hou

fix: 增加对录音状态新指令的兼容

parent b1e07455
......@@ -344,7 +344,7 @@ declare class Jensen {
sendKeyCode: (mode: number, keyCode: number, seconds?: number) => Promise<ReturnStruct['common']>;
// 获取录音状态
getRecordingStatus: (seconds?: number) => Promise<{ recording: null | string; duration: number; samples: number[] }>;
getRecordingStatus: (seconds?: number) => Promise<{ recording: null | string; duration: number; samples: number[], type: 'recording' | 'whisper' | null }>;
// 获取录音质量
getRecordingQuality: (seconds?: number) => Promise<{ quality: 'normal' | 'high' }>;
......
......@@ -812,6 +812,16 @@ export function Home() {
await releaseJensen();
}
const switchAutoRecord = async () => {
let jensen = await getJensen();
if (jensen == null) return;
const current = await jensen.getSettings(5);
Logger.info('jensen', 'auto-record', 'Current Auto Record: ' + JSON.stringify(current));
let rst = await jensen.setAutoRecord(true, 5);
Logger.info('jensen', 'auto-record', 'Set Auto Record: ' + JSON.stringify(rst));
await releaseJensen();
}
return (
<>
<div className="btn-container" style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center', flexWrap: 'wrap' }}>
......@@ -842,6 +852,7 @@ export function Home() {
<button onClick={turnPopupOn}>Turn Popup On</button>
<button onClick={turnPopupOff}>Turn Popup Off</button>
<button onClick={getSettings}>Get Settings</button>
<button onClick={switchAutoRecord}>Switch Auto Record</button>
<button onClick={startLive}>Start Live</button>
<button onClick={stopLive}>Stop Live</button>
<button onClick={muteControl}>{mute ? 'Muted' : 'Unmuted'}</button>
......
......@@ -1798,22 +1798,23 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
});
Jensen.registerHandler(GET_RECORDING_STATUS, (msg) => {
if (msg.body.length == 0) return null;
if (msg.body.length == 0) return { recording: null, duration: 0, samples: [], type: null };
let fname = '';
let idx = 0;
let len = ((msg.body[idx++] & 0xff) << 8) || (msg.body[idx++] & 0xff);
const type = msg.body[idx++] & 0xff;
let len = (msg.body[idx++] & 0xff);
for (let i = 0; i < len && i < msg.body.length; i++) {
fname += String.fromCharCode(msg.body[idx++] & 0xff);
}
// 录音时长
let duration = ((msg.body[idx+1] & 0xff) << 8) || (msg.body[idx+2] & 0xff);
let duration = ((msg.body[idx++] & 0xff) << 8) || (msg.body[idx++] & 0xff);
// 声音采样
len = ((msg.body[idx++] & 0xff) << 8) || (msg.body[idx++] & 0xff);
len = (msg.body[idx++] & 0xff);
let samples = [];
for (let i = 0; i < len && i < msg.body.length; i++) {
samples.push(msg.body[idx++] & 0xff);
}
return { recording: fname, duration: duration, samples: samples };
return { recording: fname, duration: duration, samples: samples, type: type == 0x00 ? 'recording' : 'whisper' };
});
Jensen.registerHandler(GET_RECORDING_QUALITY, (msg) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment