Electron SDK 接入
公开对象只在 Electron 主进程创建;Renderer 通过应用自己的窄 preload bridge 调用。
确认运行环境
支持 macOS Apple Silicon(darwin/arm64)与 Windows x64(win32/x64)。
安装 SDK
bash
npm install @tange-ai/tirtc-electron@2.4.0-alpha.2不要在 Renderer 直接 import Native addon,也不要为接入 SDK 开启 nodeIntegration。
在主进程初始化并查询录像
appId 来自申请开通。appAccessToken 由自己的业务服务端签发,见云端签发 Token。查询时间使用 UTC Unix 毫秒。
typescript
import {
TiStore,
TISTORE_ERROR_OK,
} from '@tange-ai/tirtc-electron';
const initCode = TiStore.init({appId});
if (initCode !== TISTORE_ERROR_OK) {
throw new Error(TiStore.errorToString(initCode));
}
const store = new TiStore(appAccessToken);
const result = await store.listRecordings(startTimeMs, endTimeMs);
if (result.code !== TISTORE_ERROR_OK) {
throw new Error(TiStore.errorToString(result.code));
}
const recordings = result.recordings;窗口退出时,先停止录像播放对象(Replay)。依次 detach、unmount 并 dispose 音视频输出对象(Output),随后 dispose Replay、TiVideoView 与 Store。
确认可以查询录像
查询成功且 recordings 非空,说明 SDK 已完成初始化,Token 可以访问目标设备,并且查询范围内存在录像。列表为空时,确认查询范围覆盖设备已经完成上传的 UTC 时间。