1e41f4b71Sopenharmony_ci# systemTonePlayer (系统提示音播放器)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci系统提示音播放器提供了短信提示音、通知提示音的播放、配置、获取信息等功能。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_cisystemTonePlayer需要和[@ohos.multimedia.systemSoundManager](js-apis-systemSoundManager-sys.md)配合使用,才能完成管理系统提示音的功能。
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci> **说明:**
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> - 本模块首批接口从API version 11开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
10e41f4b71Sopenharmony_ci> - 本模块接口为系统接口。
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## 导入模块
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport { systemSoundManager } from '@kit.AudioKit';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## SystemToneOptions
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci提示音参数选项。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| 名称        | 类型    | 必填 | 说明                                          |
27e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | --------------------------------------------- |
28e41f4b71Sopenharmony_ci| muteAudio   | boolean | 否   | 是否静音,true表示静音,false表示正常发声。   |
29e41f4b71Sopenharmony_ci| muteHaptics | boolean | 否   | 是否震动,true表示无振动,false表示正常振动。 |
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci## SystemTonePlayer
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci系统提示音播放器提供了短信提示音、通知提示音的播放、配置、获取信息等功能。在调用SystemTonePlayer的接口前,需要先通过[getSystemTonePlayer](js-apis-systemSoundManager-sys.md#getsystemtoneplayer11)创建实例。
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci### getTitle
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_cigetTitle(): Promise<string>
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci获取提示音标题,使用Promise方式异步返回结果。
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**返回值:**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci| 类型    | 说明                                  |
48e41f4b71Sopenharmony_ci| ------- | ------------------------------------- |
49e41f4b71Sopenharmony_ci| Promise<string> | Promise回调返回获取的系统提示音标题。 |
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci**错误码:**
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
56e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
57e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
58e41f4b71Sopenharmony_ci| 5400103  | I/O error.                          |
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**示例:**
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci```ts
63e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_cisystemTonePlayer.getTitle().then((value: string) => {
66e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone player title is obtained ${value}.`);
67e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
68e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone player title ${err}`);
69e41f4b71Sopenharmony_ci});
70e41f4b71Sopenharmony_ci```
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci### prepare
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ciprepare(): Promise<void>
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci准备播放提示音,使用Promise方式异步返回结果。
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**返回值:**
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| 类型    | 说明                            |
85e41f4b71Sopenharmony_ci| ------- | ------------------------------- |
86e41f4b71Sopenharmony_ci| Promise<void> | Promise回调返回准备成功或失败。 |
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**错误码:**
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
93e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
94e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
95e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.              |
96e41f4b71Sopenharmony_ci| 5400103  | I/O error.                          |
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**示例:**
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci```ts
101e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_cisystemTonePlayer.prepare().then(() => {
104e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful prepareing of system tone player.`);
105e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
106e41f4b71Sopenharmony_ci  console.error(`Failed to prepareing system tone player. ${err}`);
107e41f4b71Sopenharmony_ci});
108e41f4b71Sopenharmony_ci```
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci### start
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_cistart(toneOptions?: SystemToneOptions): Promise<number>
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci开始播放提示音,使用Promise方式异步返回结果。
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.VIBRATE
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci**参数:**
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci| 参数名      | 类型                                    | 必填 | 说明             |
125e41f4b71Sopenharmony_ci| ----------- | --------------------------------------- | ---- | ---------------- |
126e41f4b71Sopenharmony_ci| toneOptions | [SystemToneOptions](#systemtoneoptions) | 否   | 系统提示音选项。 |
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci**返回值:**
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci| 类型    | 说明                      |
131e41f4b71Sopenharmony_ci| ------- | ------------------------- |
132e41f4b71Sopenharmony_ci| Promise<number> | Promise回调返回streamID。 |
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**错误码:**
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                                                    |
139e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------------------------------------------------------- |
140e41f4b71Sopenharmony_ci| 201      | Permission denied.                                                                                          |
141e41f4b71Sopenharmony_ci| 202      | Caller is not a system application.                                                                         |
142e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
143e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.                                                                                      |
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**示例:**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci```ts
148e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ciclass SystemToneOptions {
151e41f4b71Sopenharmony_ci  muteAudio: boolean = false;
152e41f4b71Sopenharmony_ci  muteHaptics: boolean = false;
153e41f4b71Sopenharmony_ci}
154e41f4b71Sopenharmony_cilet systemToneOptions: SystemToneOptions = {muteAudio: true, muteHaptics: false};
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_cisystemTonePlayer.start(systemToneOptions).then((value: number) => {
157e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone player streamID is obtained ${value}.`);
158e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
159e41f4b71Sopenharmony_ci  console.error(`Failed to start system tone player. ${err}`);
160e41f4b71Sopenharmony_ci});
161e41f4b71Sopenharmony_ci```
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci### stop
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_cistop(id: number): Promise<void>
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci停止播放提示音,使用Promise方式异步返回结果。
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci**参数:**
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                      |
176e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------- |
177e41f4b71Sopenharmony_ci| id     | number | 是   | start方法返回的streamID。 |
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci**返回值:**
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci| 类型    | 说明                                |
182e41f4b71Sopenharmony_ci| ------- | ----------------------------------- |
183e41f4b71Sopenharmony_ci| Promise<void> | Promise回调返回停止播放成功或失败。 |
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**错误码:**
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                                                    |
190e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------------------------------------------------------- |
191e41f4b71Sopenharmony_ci| 202      | Caller is not a system application.                                                                         |
192e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
193e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.                                                                                      |
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**示例:**
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci```ts
198e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_cilet streamID: number = 0; //streamID为start方法返回的streamID,此处只做初始化。
201e41f4b71Sopenharmony_cisystemTonePlayer.stop(streamID).then(() => {
202e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful stopping of system tone player.`);
203e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
204e41f4b71Sopenharmony_ci  console.error(`Failed to stop system tone player. ${err}`);
205e41f4b71Sopenharmony_ci});
206e41f4b71Sopenharmony_ci```
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci### release
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_cirelease(): Promise<void>
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci释放提示音播放器,使用Promise方式异步返回结果。
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci**返回值:**
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci| 类型    | 说明                            |
221e41f4b71Sopenharmony_ci| ------- | ------------------------------- |
222e41f4b71Sopenharmony_ci| Promise<void> | Promise回调返回释放成功或失败。 |
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**错误码:**
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
229e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
230e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**示例:**
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci```ts
235e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_cisystemTonePlayer.release().then(() => {
238e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful releasing of system tone player.`);
239e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
240e41f4b71Sopenharmony_ci  console.error(`Failed to release system tone player. ${err}`);
241e41f4b71Sopenharmony_ci});
242e41f4b71Sopenharmony_ci```
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci### setAudioVolumeScale<sup>13+</sup>
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_cisetAudioVolumeScale(scale: number): void
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci设置音频音量大小,无返回结果。
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**参数:**
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                 |
257e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------ |
258e41f4b71Sopenharmony_ci| scale  | number | 是   | 音频音量大小,必须在[0, 1]之间取值。 |
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci**错误码:**
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                                                    |
265e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------------------------------------------------------- |
266e41f4b71Sopenharmony_ci| 202      | Caller is not a system application.                                                                         |
267e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
268e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.                                                                                      |
269e41f4b71Sopenharmony_ci| 20700002 | Parameter check error, For example, value is out side [0, 1]                                                |
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**示例:**
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci```ts
274e41f4b71Sopenharmony_cilet scale: number = 0.5;
275e41f4b71Sopenharmony_citry {
276e41f4b71Sopenharmony_ci  systemTonePlayer.setAudioVolumeScale(scale);
277e41f4b71Sopenharmony_ci} catch (err) {
278e41f4b71Sopenharmony_ci  console.error(`Failed to set audio volume scale. ${err}`);
279e41f4b71Sopenharmony_ci}
280e41f4b71Sopenharmony_ci```
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci### getAudioVolumeScale<sup>13+</sup>
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_cigetAudioVolumeScale(): number;
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci获取当前音频音量大小,同步返回当前音量。
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**返回值:**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci| 类型   | 说明         |
296e41f4b71Sopenharmony_ci| ------ | ------------ |
297e41f4b71Sopenharmony_ci| number | 当前音频音量。 |
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**错误码:**
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
305e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
306e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci**示例:**
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci```ts
311e41f4b71Sopenharmony_citry {
312e41f4b71Sopenharmony_ci  let scale: number = systemTonePlayer.getAudioVolumeScale();
313e41f4b71Sopenharmony_ci  console.info(` get audio volume scale. ${scale}`);
314e41f4b71Sopenharmony_ci} catch (err) {
315e41f4b71Sopenharmony_ci  console.error(`Failed to get audio volume scale. ${err}`);
316e41f4b71Sopenharmony_ci}
317e41f4b71Sopenharmony_ci```
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci### getSupportedHapticsFeatures<sup>13+</sup>
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_cigetSupportedHapticsFeatures(): Promise&lt;Array&lt;systemSoundManager.ToneHapticsFeature&gt;&gt;
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci获取当前支持的振动风格,使用Promise方式异步返回支持的振动风格列表。
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**返回值:**
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci| 类型                                                                                                                          | 说明                                                                                                                  |
333e41f4b71Sopenharmony_ci|-----------------------------------------------------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------------------------- |
334e41f4b71Sopenharmony_ci| Promise&lt;Array&lt;[systemSoundManager.ToneHapticsFeature](js-apis-systemSoundManager-sys.md#tonehapticsfeature13)&gt;&gt; | Promise回调返回当前支持的振动风格。 |
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**错误码:**
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
342e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
343e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
344e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation.              |
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci**示例:**
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ci```ts
349e41f4b71Sopenharmony_citry {
350e41f4b71Sopenharmony_ci  let features: Array<systemSoundManager.ToneHapticsFeature> = await systemTonePlayer.getSupportedHapticsFeatures();
351e41f4b71Sopenharmony_ci  console.info(` get supported haptics features. ${features}`);
352e41f4b71Sopenharmony_ci} catch (err) {
353e41f4b71Sopenharmony_ci  console.error(`Failed to get supported haptics features. ${err}`);
354e41f4b71Sopenharmony_ci}
355e41f4b71Sopenharmony_ci```
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci### setHapticsFeature<sup>13+</sup>
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_cisetHapticsFeature(hapticsFeature: systemSoundManager.ToneHapticsFeature): void
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci设置播放铃音时的振动风格。
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci调用本接口前,应该先调用[getSupportedHapticsFeatures](#getsupportedhapticsfeatures13)查询支持的振动风格,如果设置不支持的振动风格,则设置失败。
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
368e41f4b71Sopenharmony_ci**参数:**
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci| 参数名         | 类型                                                                                              | 必填 | 说明             |
372e41f4b71Sopenharmony_ci| -------------- |-------------------------------------------------------------------------------------------------| ---- | ---------------- |
373e41f4b71Sopenharmony_ci| hapticsFeature | [systemSoundManager.ToneHapticsFeature](js-apis-systemSoundManager-sys.md#tonehapticsfeature13) | 是   | 振动风格。 |
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci**错误码:**
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                                                    |
381e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------------------------------------------------------- |
382e41f4b71Sopenharmony_ci| 202      | Caller is not a system application.                                                                         |
383e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
384e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.                                                                                      |
385e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation.                                                                                      |
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci**示例:**
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci```ts
390e41f4b71Sopenharmony_citry {
391e41f4b71Sopenharmony_ci  let features: Array<systemSoundManager.ToneHapticsFeature> = await systemTonePlayer.getSupportedHapticsFeatures();
392e41f4b71Sopenharmony_ci  if (features.lenght == 0) {
393e41f4b71Sopenharmony_ci    return;
394e41f4b71Sopenharmony_ci  }
395e41f4b71Sopenharmony_ci  let feature: systemSoundManager.ToneHapticsFeature = features[0];
396e41f4b71Sopenharmony_ci  systemTonePlayer.setHapticsFeature(feature);
397e41f4b71Sopenharmony_ci  console.info(` set haptics feature success`);
398e41f4b71Sopenharmony_ci} catch (err) {
399e41f4b71Sopenharmony_ci  console.error(`Failed to set haptics feature. ${err}`);
400e41f4b71Sopenharmony_ci}
401e41f4b71Sopenharmony_ci```
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci### getHapticsFeature<sup>13+</sup>
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_cigetHapticsFeature(): systemSoundManager.ToneHapticsFeature
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci获取播放铃音时的振动风格,同步返回振动风格枚举值。
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci**返回值:**
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci| 类型                                                                                              | 说明     |
417e41f4b71Sopenharmony_ci|-------------------------------------------------------------------------------------------------| -------- |
418e41f4b71Sopenharmony_ci| [systemSoundManager.ToneHapticsFeature](js-apis-systemSoundManager-sys.md#tonehapticsfeature13) | 振动风格 |
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci**错误码:**
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                            |
426e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
427e41f4b71Sopenharmony_ci| 202      | Caller is not a system application. |
428e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation.              |
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**示例:**
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci```ts
433e41f4b71Sopenharmony_citry {
434e41f4b71Sopenharmony_ci  let feature: systemSoundManager.ToneHapticsFeature = systemTonePlayer.getHapticsFeature();
435e41f4b71Sopenharmony_ci  console.info(` get haptics feature success. ${features}`);
436e41f4b71Sopenharmony_ci} catch (err) {
437e41f4b71Sopenharmony_ci  console.error(`Failed to get haptics feature. ${err}`);
438e41f4b71Sopenharmony_ci}
439e41f4b71Sopenharmony_ci```
440