For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/device/gyroscope/startGyroscope.md.

startGyroscope

开始监听陀螺仪。

扫码预览

扫码预览 startGyroscope

支持版本

前端库版本不低于 0.0.25。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

接入准备

前置条件

  • 无额外前置条件;建议在启动前注册 onGyroscopeChange

使用说明

需配对调用 stopGyroscope。

  • 不再需要时及时调用 stopGyroscope,避免持续采集造成额外功耗

调用方式

异步 API

startGyroscope(params?: StartGyroscopeParams): Promise<object>

入参

名称类型必填默认值约束说明
intervalSensorInterval否normalgame 表示约 20 次/秒,ui 表示约 60 次/秒,normal 表示约 5 次/秒监听频率。

调用示例

import { startGyroscope } from '@doubao-dev/framework/api';

await startGyroscope({ interval: 'normal' });

成功返回

无返回字段。

返回示例

{}

错误处理

错误对象和通用错误码见 通用错误处理。

失败示例

{
  "errNo": 103,
  "errMsg": "feature not support"
}

错误码

errNoerrMsg平台触发条件处理建议
103feature not supportAndroid、iOS当前设备不支持陀螺仪传感器或无法注册监听在具备陀螺仪传感器的设备上调用,或提前提示用户设备不支持。

通用错误码

errNoerrMsg说明平台
102internal error内部错误Android、iOS