1e41f4b71Sopenharmony_ci# vibrator.h
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## 概述
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci为您提供标准的开放api,用于控制马达振动的启停。
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**库:** libohvibrator.z.so
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Sensors.MiscDevice
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci**起始版本:** 11
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci**相关模块:** [Vibrator](_vibrator.md)
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 汇总
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci### 函数
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| 名称 | 描述 |
23e41f4b71Sopenharmony_ci| -------- | -------- |
24e41f4b71Sopenharmony_ci| [OHOS::Sensors::OH_Vibrator_PlayVibration](#oh_vibrator_playvibration)(int32_t duration, Vibrator_Attribute attribute) | 控制马达在指定时间内持续振动。 |
25e41f4b71Sopenharmony_ci| [OHOS::Sensors::OH_Vibrator_PlayVibrationCustom](#oh_vibrator_playvibrationcustom)(Vibrator_FileDescription fileDescription, Vibrator_Attribute vibrateAttribute) | 播放自定义振动序列。           |
26e41f4b71Sopenharmony_ci| [OHOS::Sensors::OH_Vibrator_Cancel](#oh_vibrator_cancel)() | 停止马达振动。  |
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## 函数说明
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci### OH_Vibrator_Cancel()
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci```
35e41f4b71Sopenharmony_ciint32_t OHOS::Sensors::OH_Vibrator_Cancel()
36e41f4b71Sopenharmony_ci```
37e41f4b71Sopenharmony_ci**描述:**
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci停止马达振动。
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**起始版本:** 11
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci**返回:**
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci如果操作成功,则返回0;否则返回非零值。请参阅 [Vibrator_ErrorCode](_vibrator.md#vibrator_errorcode)。
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci**Permission:**
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciohos.permission.VIBRATE
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci### OH_Vibrator_PlayVibration()
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci```
55e41f4b71Sopenharmony_ciint32_t OHOS::Sensors::OH_Vibrator_PlayVibration(int32_t duration, Vibrator_Attribute attribute)
56e41f4b71Sopenharmony_ci```
57e41f4b71Sopenharmony_ci**描述:**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci控制马达在指定时间内持续振动。
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**起始版本:** 11
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**参数:**
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci| 名称 | 描述 |
66e41f4b71Sopenharmony_ci| -------- | -------- |
67e41f4b71Sopenharmony_ci| duration | 振动时长,单位:毫秒。  |
68e41f4b71Sopenharmony_ci| attribute | 振动属性,请参考 [Vibrator_Attribute](_vibrator.md#vibrator_attribute)。 |
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**返回:**
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci如果操作成功,则返回0;否则返回非零值。请参阅 [Vibrator_ErrorCode](_vibrator.md#vibrator_errorcode)。
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**Permission:**
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ciohos.permission.VIBRATE
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci### OH_Vibrator_PlayVibrationCustom()
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci```
82e41f4b71Sopenharmony_ciint32_t OHOS::Sensors::OH_Vibrator_PlayVibrationCustom(Vibrator_FileDescription fileDescription, Vibrator_Attribute vibrateAttribute)
83e41f4b71Sopenharmony_ci```
84e41f4b71Sopenharmony_ci**描述:**
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci播放自定义振动序列。
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**起始版本:** 11
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**参数:**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| 名称 | 描述 |
93e41f4b71Sopenharmony_ci| -------- | -------- |
94e41f4b71Sopenharmony_ci| fileDescription | 自定义振动效果文件描述符,请参阅 [Vibrator_FileDescription](_vibrator.md#vibrator_filedescription)。 |
95e41f4b71Sopenharmony_ci| vibrateAttribute | 振动属性,请参阅 [Vibrator_Attribute](_vibrator.md#vibrator_attribute)。 |
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**返回:**
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci如果操作成功,则返回0;否则返回非零值。请参阅 [Vibrator_ErrorCode](_vibrator.md#vibrator_errorcode)。
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**Permission:**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ciohos.permission.VIBRATE
104