1e41f4b71Sopenharmony_ci# @ohos.multimedia.systemSoundManager (系统声音管理)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci系统声音管理提供管理系统声音的一些基础能力,包括对系统铃声的资源设置与读取、获取系统铃声播放器等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci> - 本模块接口为系统接口。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## 导入模块
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { systemSoundManager } from '@kit.AudioKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## 常量
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| 名称                                      | 值   | 说明      |
23e41f4b71Sopenharmony_ci|------------------------------------------|-----|---------|
24e41f4b71Sopenharmony_ci| TONE_CATEGORY_RINGTONE<sup>12+</sup>     | 1   | 铃声类别。   |
25e41f4b71Sopenharmony_ci| TONE_CATEGORY_TEXT_MESSAGE<sup>12+</sup> | 2   | 短信铃声类别。 |
26e41f4b71Sopenharmony_ci| TONE_CATEGORY_NOTIFICATION<sup>12+</sup> | 4   | 通知铃声类别。 |
27e41f4b71Sopenharmony_ci| TONE_CATEGORY_ALARM<sup>12+</sup>        | 8   | 闹钟铃声类别。 |
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## RingtoneType
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci枚举,铃声类型。
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| 名称                            | 值  | 说明                                                                     |
38e41f4b71Sopenharmony_ci| ------------------------------- |----|------------------------------------------------------------------------|
39e41f4b71Sopenharmony_ci| RINGTONE_TYPE_DEFAULT<sup>(deprecated)</sup>           | 0  | 默认铃声类型。<br/> 从 API version 11 开始废弃。建议使用该枚举中的RINGTONE_TYPE_SIM_CARD_0替代。 |
40e41f4b71Sopenharmony_ci| RINGTONE_TYPE_SIM_CARD_0<sup>11+</sup> | 0  | sim卡1的铃声。                                                              |
41e41f4b71Sopenharmony_ci| RINGTONE_TYPE_MULTISIM<sup>(deprecated)</sup>          | 1  | 多SIM卡铃声类型。<br/> 从 API version 11 开始废弃。建议使用该枚举中的RINGTONE_TYPE_SIM_CARD_1替代。 |
42e41f4b71Sopenharmony_ci| RINGTONE_TYPE_SIM_CARD_1<sup>11+</sup> | 1  | sim卡2的铃声。                                                              |
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## SystemToneType<sup>11+</sup>
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci枚举,系统铃声类型。
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci| 名称                            | 值   | 说明         |
53e41f4b71Sopenharmony_ci| ------------------------------- |-----|------------|
54e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_SIM_CARD_0     | 0   | sim卡1的短信提示音。 |
55e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_SIM_CARD_1     | 1   | sim卡2的短信提示音。 |
56e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_NOTIFICATION   | 32  | 通知提示音。     |
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci## ToneCustomizedType<sup>12+</sup>
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci枚举,铃声自定义类型。
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci| 名称                         | 值   | 说明         |
68e41f4b71Sopenharmony_ci| ----------------------------|-----|------------|
69e41f4b71Sopenharmony_ci| PRE_INSTALLED<sup>12+</sup> | 0   | 预安装铃声类型。 |
70e41f4b71Sopenharmony_ci| CUSTOMIZED<sup>12+</sup>    | 1   | 自定义铃声类型。 |
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci## ToneAttrs<sup>12+</sup>
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci管理铃声属性。在调用ToneAttrs<sup>12+</sup>的接口前,需要先通过[createCustomizedToneAttrs](#systemsoundmanagercreatecustomizedtoneattrs12)或[getDefaultRingtoneAttrs](#getdefaultringtoneattrs12)、[getRingtoneAttrList](#getringtoneattrlist12)等方法获取实例。
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci### getTitle<sup>12+</sup>
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_cigetTitle(): string
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci获取铃声标题。
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**返回值:**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci| 类型    | 说明  |
89e41f4b71Sopenharmony_ci|--------|-----|
90e41f4b71Sopenharmony_ci| string | 标题。 |
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**错误码:**
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
95e41f4b71Sopenharmony_ci|---------| -------------------- |
96e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**示例:**
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci```ts
101e41f4b71Sopenharmony_citoneAttrs.getTitle();
102e41f4b71Sopenharmony_ci```
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci### setTitle<sup>12+</sup>
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_cisetTitle(title: string): void
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci设置铃声标题。
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**参数:**
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci| 参数名  | 类型    | 必填 | 说明          |
117e41f4b71Sopenharmony_ci| -------| -------| ---- | ------------|
118e41f4b71Sopenharmony_ci| title  | string | 是   | 铃声的标题。   |
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**错误码:**
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
123e41f4b71Sopenharmony_ci|-------| -------------------- |
124e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
125e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**示例:**
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci```ts
130e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
131e41f4b71Sopenharmony_cilet title = 'text';
132e41f4b71Sopenharmony_citoneAttrs.setTitle(title);
133e41f4b71Sopenharmony_ci```
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci### getFileName<sup>12+</sup>
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_cigetFileName(): string
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci获取铃声文件名。
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**返回值:**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| 类型    | 说明   |
148e41f4b71Sopenharmony_ci|--------|------|
149e41f4b71Sopenharmony_ci| string | 文件名。 |
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**错误码:**
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
154e41f4b71Sopenharmony_ci|---------| -------------------- |
155e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**示例:**
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci```ts
161e41f4b71Sopenharmony_citoneAttrs.getFileName();
162e41f4b71Sopenharmony_ci```
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci### setFileName<sup>12+</sup>
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_cisetFileName(name: string): void
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci设置铃声文件名。
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**参数:**
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci| 参数名 | 类型    | 必填 | 说明         |
177e41f4b71Sopenharmony_ci| ------| -------|-----| ------------|
178e41f4b71Sopenharmony_ci| name  | string | 是   | 铃声的文件名。 |
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**错误码:**
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
183e41f4b71Sopenharmony_ci|-------| -------------------- |
184e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
185e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**示例:**
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci```ts
190e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
191e41f4b71Sopenharmony_cilet fileName = 'textFileName';
192e41f4b71Sopenharmony_citoneAttrs.setFileName(fileName);
193e41f4b71Sopenharmony_ci```
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci### getUri<sup>12+</sup>
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_cigetUri(): string
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci获取铃声资源路径。
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci**返回值:**
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci| 类型    | 说明                                                      |
208e41f4b71Sopenharmony_ci|--------|---------------------------------------------------------|
209e41f4b71Sopenharmony_ci| string | uri(如:'/data/storage/el2/base/RingTone/alarms/test.ogg')。 |
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci**错误码:**
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
214e41f4b71Sopenharmony_ci|---------| -------------------- |
215e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**示例:**
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci```ts
220e41f4b71Sopenharmony_citoneAttrs.getUri();
221e41f4b71Sopenharmony_ci```
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci### getCustomizedType<sup>12+</sup>
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_cigetCustomizedType(): string
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci获取铃声自定义类型。
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**返回值:**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| 类型                                         | 说明      |
236e41f4b71Sopenharmony_ci|--------------------------------------------|---------|
237e41f4b71Sopenharmony_ci| [ToneCustomizedType](#tonecustomizedtype12) | 定制铃音类型。 |
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**错误码:**
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
242e41f4b71Sopenharmony_ci|---------| -------------------- |
243e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**示例:**
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci```ts
248e41f4b71Sopenharmony_citoneAttrs.getCustomizedType();
249e41f4b71Sopenharmony_ci```
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci### setCategory<sup>12+</sup>
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_cisetCategory(category: number): void
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci设置铃声类别。
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**参数:**
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci| 参数名      | 类型      | 必填 | 说明       |
264e41f4b71Sopenharmony_ci|----------| ---------| ---- |----------|
265e41f4b71Sopenharmony_ci| category | number   | 是   | 铃声类别,取值参考[铃声类别的常量](#常量)。  |
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci**错误码:**
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
270e41f4b71Sopenharmony_ci|-------| -------------------- |
271e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
272e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**示例:**
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci```ts
277e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
278e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM; // 需更改为实际所需类型常量
279e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
280e41f4b71Sopenharmony_ci```
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci### getCategory<sup>12+</sup>
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_cigetCategory(): string
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| number | 铃声类别,取值参考[铃声类别的常量](#常量)。 |
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci**错误码:**
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
301e41f4b71Sopenharmony_ci|---------| -------------------- |
302e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci**示例:**
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci```ts
308e41f4b71Sopenharmony_citoneAttrs.getCategory();
309e41f4b71Sopenharmony_ci```
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci## ToneAttrsArray<sup>12+</sup>
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_citype ToneAttrsArray = Array&lt;[ToneAttrs](#toneattrs12)&gt;
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci铃音属性数组。
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci| 类型                                     | 说明      |
320e41f4b71Sopenharmony_ci|----------------------------------------|---------|
321e41f4b71Sopenharmony_ci| Array&lt;[ToneAttrs](#toneattrs12)&gt; | 铃音属性数组。 |
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci## systemSoundManager.createCustomizedToneAttrs<sup>12+</sup>
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_cicreateCustomizedToneAttrs(): ToneAttrs
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci创建自定义铃声属性。
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**返回值:**
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci| 类型                        | 说明         |
336e41f4b71Sopenharmony_ci|---------------------------| ------------ |
337e41f4b71Sopenharmony_ci| [ToneAttrs](#toneattrs12) | 铃声属性类。 |
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**错误码:**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
344e41f4b71Sopenharmony_ci|---------| -------------------- |
345e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**示例:**
348e41f4b71Sopenharmony_ci```ts
349e41f4b71Sopenharmony_cilet toneAttrs: systemSoundManager.ToneAttrs = systemSoundManager.createCustomizedToneAttrs();
350e41f4b71Sopenharmony_ci```
351e41f4b71Sopenharmony_ci## ToneHapticsFeature<sup>13+</sup>
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci枚举,系统振动风格定义。
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci| 名称                          | 值 | 说明                 |
360e41f4b71Sopenharmony_ci| ----------------------------- | -- | -------------------- |
361e41f4b71Sopenharmony_ci| STANDARD| 0  | 标准振动风格。 |
362e41f4b71Sopenharmony_ci| GENTLE   | 1  | 轻柔振动风格。 |
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci## ToneHapticsType<sup>13+</sup>
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_citype ToneHapticsType = RingtoneType | SystemToneType
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci联合枚举,系统铃音的振动类型。
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci| 名称                                 | 说明         |
375e41f4b71Sopenharmony_ci| ------------------------------------|------------|
376e41f4b71Sopenharmony_ci| [RingtoneType](#ringtonetype)       | 通话铃音类型。 |
377e41f4b71Sopenharmony_ci| [SystemToneType](#systemtonetype11) | 系统短音类型。 |
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci## ToneHapticsMode<sup>13+</sup>
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci枚举,系统铃音场景的振动模式。
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci| 名称                          | 值 | 说明                 |
388e41f4b71Sopenharmony_ci| ----------------------------- | -- | -------------------- |
389e41f4b71Sopenharmony_ci| NONE        | 0  | 无振动模式。 |
390e41f4b71Sopenharmony_ci| SYNC        | 1  | 与铃音同步模式。 |
391e41f4b71Sopenharmony_ci| NON_SYNC    | 2  | 非同步模式。 |
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci## ToneHapticsSettings<sup>13+</sup>
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci系统铃音的振动设置。
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci| 名称          | 类型 | 只读 | 可选 | 说明                 |
402e41f4b71Sopenharmony_ci| ------------ | -- | -- | -- | -------------------- |
403e41f4b71Sopenharmony_ci| mode | [ToneHapticsMode](#tonehapticsmode13) | 否 | 否 | 系统铃音的振动模式。 |
404e41f4b71Sopenharmony_ci| hapticsUri | string                          | 否 | 是 | 系统铃音的振动路径,当振动模式不是非同步振动应该被忽略,振动的路径可通过[getToneHapticsList](#gettonehapticslist13)获取。 |
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci## ToneHapticsAttrs<sup>13+</sup>
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci系统铃音的振动属性。在调用ToneHapticsAttrs<sup>13+</sup>的接口前,需要先通过[getToneHapticsList](#gettonehapticslist13)或[getHapticsAttrsSyncedWithTone](#gethapticsattrssyncedwithtone13)方法获取实例。
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci### getUri<sup>13+</sup>
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_cigetUri(): string
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci获取振动资源路径。
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci**返回值:**
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci| 类型    | 说明  |
423e41f4b71Sopenharmony_ci|--------|-----|
424e41f4b71Sopenharmony_ci| string | uri(如:'/data/storage/el2/base/haptics/synchronized/alarms/test.json')。 |
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci**错误码:**
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
429e41f4b71Sopenharmony_ci|---------| -------------------- |
430e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**示例:**
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci```ts
435e41f4b71Sopenharmony_citoneHapticsAttrs.getUri();
436e41f4b71Sopenharmony_ci```
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci### getTitle<sup>13+</sup>
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_cigetTitle(): string
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci获取振动标题。
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci**返回值:**
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci| 类型    | 说明  |
451e41f4b71Sopenharmony_ci|--------|-----|
452e41f4b71Sopenharmony_ci| string | 标题。 |
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**错误码:**
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
457e41f4b71Sopenharmony_ci|---------| -------------------- |
458e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**示例:**
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci```ts
463e41f4b71Sopenharmony_citoneHapticsAttrs.getTitle();
464e41f4b71Sopenharmony_ci```
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci### getFileName<sup>13+</sup>
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_cigetFileName(): string
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci获取振动文件名。
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci**返回值:**
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci| 类型    | 说明  |
479e41f4b71Sopenharmony_ci|--------|-----|
480e41f4b71Sopenharmony_ci| string | 文件名。 |
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**错误码:**
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
485e41f4b71Sopenharmony_ci|---------| -------------------- |
486e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**示例:**
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci```ts
491e41f4b71Sopenharmony_citoneHapticsAttrs.getFileName();
492e41f4b71Sopenharmony_ci```
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci## ToneHapticsAttrsArray<sup>13+</sup>
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_citype ToneHapticsAttrsArray = Array&lt;ToneHapticsAttrs&gt;
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ci系统铃音的振动属性数组。
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci| 类型                                     | 说明      |
503e41f4b71Sopenharmony_ci|----------------------------------------|---------|
504e41f4b71Sopenharmony_ci| Array&lt;[ToneHapticsAttrs](#tonehapticsattrs13)&gt; | 系统铃音的振动属性数组。 |
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci## systemSoundManager.getSystemSoundManager
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_cigetSystemSoundManager(): SystemSoundManager
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci获取系统声音管理器。
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci**返回值:**
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci| 类型                          | 说明         |
519e41f4b71Sopenharmony_ci| ----------------------------- | ------------ |
520e41f4b71Sopenharmony_ci| [SystemSoundManager](#systemsoundmanager) | 系统声音管理类。 |
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**示例:**
523e41f4b71Sopenharmony_ci```ts
524e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
525e41f4b71Sopenharmony_ci```
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci## SystemSoundManager
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci管理系统声音。在调用SystemSoundManager的接口前,需要先通过[getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager)创建实例。
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci### setSystemRingtoneUri<sup>(deprecated)</sup>
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_cisetSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback&lt;void&gt;): void
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci设置系统铃声uri,使用callback方式异步返回结果。
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci> **说明:**
538e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[setRingtoneUri](#setringtoneuri11)替代。
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci**参数:**
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                     |
547e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------ |
548e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | 是   | 当前应用的上下文。           |
549e41f4b71Sopenharmony_ci| uri      | string                                   | 是   | 被设置的系统铃声的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
550e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | 是   | 被设置的系统铃声的类型。     |
551e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                | 是   | 回调返回设置成功或失败。     |
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci**示例:**
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci```ts
556e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
557e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_cilet context: Context = getContext(this);
560e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
561e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
564e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemRingtoneUri(context, uri, type, (err: BusinessError) => {
565e41f4b71Sopenharmony_ci  if (err) {
566e41f4b71Sopenharmony_ci    console.error(`Failed to set system ringtone uri. ${err}`);
567e41f4b71Sopenharmony_ci    return;
568e41f4b71Sopenharmony_ci  }
569e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate a successful setting of the system ringtone uri.`);
570e41f4b71Sopenharmony_ci});
571e41f4b71Sopenharmony_ci```
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci### setSystemRingtoneUri<sup>(deprecated)</sup>
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_cisetSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise&lt;void&gt;
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci设置系统铃声uri,使用Promise方式异步返回结果。
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci> **说明:**
580e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[setRingtoneUri](#setringtoneuri11)替代。
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci**参数:**
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                     |
589e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------ |
590e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | 是   | 当前应用的上下文。         |
591e41f4b71Sopenharmony_ci| uri      | string                                   | 是   | 被设置的系统铃声的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
592e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | 是   | 被设置的系统铃声的类型。   |
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci**返回值:**
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci| 类型                | 说明                            |
597e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
598e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。   |
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci**示例:**
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci```ts
603e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
604e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_cilet context: Context = getContext(this);
607e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
608e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
611e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemRingtoneUri(context, uri, type).then(() => {
612e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
613e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
614e41f4b71Sopenharmony_ci  console.error(`Failed to set the system ringtone uri ${err}`);
615e41f4b71Sopenharmony_ci});
616e41f4b71Sopenharmony_ci```
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci### getSystemRingtoneUri<sup>(deprecated)</sup>
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_cigetSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback&lt;string&gt;): void
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci获取系统铃声uri,使用callback方式异步返回结果。
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci> **说明:**
625e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[getRingtoneUri](#getringtoneuri11)替代。
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci**参数:**
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci| 参数名   | 类型                                                                    | 必填 | 说明                     |
634e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------| ---- | ------------------------ |
635e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | 是   | 当前应用的上下文。         |
636e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                         | 是   | 待获取的系统铃声的类型。    |
637e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;string&gt;                                           | 是   | 回调返回获取的系统铃声uri。 |
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**示例:**
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci```ts
642e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
643e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_cilet context: Context = getContext(this);
646e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
649e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtoneUri(context, type, (err: BusinessError, value: string) => {
650e41f4b71Sopenharmony_ci  if (err) {
651e41f4b71Sopenharmony_ci    console.error(`Failed to get system ringtone uri. ${err}`);
652e41f4b71Sopenharmony_ci    return;
653e41f4b71Sopenharmony_ci  }
654e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate the value of the system ringtone uri is obtained ${value}.`);
655e41f4b71Sopenharmony_ci});
656e41f4b71Sopenharmony_ci```
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci### getSystemRingtoneUri<sup>(deprecated)</sup>
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_cigetSystemRingtoneUri(context: Context, type: RingtoneType): Promise&lt;string&gt;
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci获取系统铃声uri,使用Promise方式异步返回结果。
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci> **说明:**
665e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[getRingtoneUri](#getringtoneuri11)替代。
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
670e41f4b71Sopenharmony_ci
671e41f4b71Sopenharmony_ci**参数:**
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci| 参数名   | 类型                                                                   | 必填 | 说明                     |
674e41f4b71Sopenharmony_ci| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
675e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | 是   | 当前应用的上下文。         |
676e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                        | 是   | 被设置的系统铃声的类型。   |
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ci**返回值:**
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci| 类型                | 说明                                |
681e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
682e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回获取的系统铃声uri。 |
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci**示例:**
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ci```ts
687e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
688e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_cilet context: Context = getContext(this);
691e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
694e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtoneUri(context, type).then((value: string) => {
695e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
696e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
697e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone uri ${err}`);
698e41f4b71Sopenharmony_ci});
699e41f4b71Sopenharmony_ci```
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci### getSystemRingtonePlayer<sup>(deprecated)</sup>
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_cigetSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback&lt;RingtonePlayer&gt;): void
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci获取系统铃声播放器,使用callback方式异步返回结果。
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci> **说明:**
708e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[getRingtonePlayer](#getringtoneplayer11)替代。
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**参数:**
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                         |
717e41f4b71Sopenharmony_ci| -------- | -----------------------------------------| ---- | --------------------------- |
718e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | 是   | 当前应用的上下文。            |
719e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | 是   | 待获取播放器的系统铃声的类型。 |
720e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | 是 | 回调返回获取的系统铃声播放器。 |
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci**示例:**
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ci```ts
725e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
726e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_cilet context: Context = getContext(this);
729e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
730e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
733e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtonePlayer(context, type, (err: BusinessError, value: systemSoundManager.RingtonePlayer) => {
734e41f4b71Sopenharmony_ci  if (err) {
735e41f4b71Sopenharmony_ci    console.error(`Failed to get system ringtone player. ${err}`);
736e41f4b71Sopenharmony_ci    return;
737e41f4b71Sopenharmony_ci  }
738e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate the value of the system ringtone player is obtained.`);
739e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
740e41f4b71Sopenharmony_ci});
741e41f4b71Sopenharmony_ci```
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ci### getSystemRingtonePlayer<sup>(deprecated)</sup>
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_cigetSystemRingtonePlayer(context: Context, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci获取系统铃声播放器,使用Promise方式异步返回结果。
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci> **说明:**
750e41f4b71Sopenharmony_ci> 从 API version 10 开始支持,从 API version 11 开始废弃,建议使用[getRingtonePlayer](#getringtoneplayer11)替代。
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci**参数:**
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci| 参数名   | 类型                                                                  | 必填 | 说明                         |
759e41f4b71Sopenharmony_ci| -------- |---------------------------------------------------------------------| ---- | --------------------------- |
760e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。            |
761e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                       | 是   | 待获取播放器的系统铃声的类型。 |
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci**返回值:**
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci| 类型                | 说明                            |
766e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
767e41f4b71Sopenharmony_ci| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise回调返回获取的系统铃声播放器。 |
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci**示例:**
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci```ts
772e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
773e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_cilet context: Context = getContext(this);
776e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
777e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
780e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
781e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
782e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
783e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
784e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone player ${err}`);
785e41f4b71Sopenharmony_ci});
786e41f4b71Sopenharmony_ci```
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_ci### setRingtoneUri<sup>11+</sup>
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_cisetRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise&lt;void&gt;
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci设置系统铃声uri,使用Promise方式异步返回结果。
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**参数:**
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci| 参数名   | 类型                            | 必填 | 说明                     |
801e41f4b71Sopenharmony_ci| -------- |-------------------------------| ---- | ------------------------ |
802e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)            | 是   | 当前应用的上下文。         |
803e41f4b71Sopenharmony_ci| uri      | string                        | 是   | 被设置的系统铃声的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
804e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype) | 是   | 被设置的系统铃声的类型。   |
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**返回值:**
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci| 类型                | 说明                            |
809e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
810e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。   |
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci**错误码:**
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
817e41f4b71Sopenharmony_ci| ------- | --------------------- |
818e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
819e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
820e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**示例:**
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci```ts
825e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
826e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
829e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
830e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
833e41f4b71Sopenharmony_cisystemSoundManagerInstance.setRingtoneUri(context, uri, type).then(() => {
834e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
835e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
836e41f4b71Sopenharmony_ci  console.error(`Failed to set the system ringtone uri ${err}`);
837e41f4b71Sopenharmony_ci});
838e41f4b71Sopenharmony_ci```
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ci### getRingtoneUri<sup>11+</sup>
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_cigetRingtoneUri(context: BaseContext, type: RingtoneType): Promise&lt;string&gt;
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci获取系统铃声uri,使用Promise方式异步返回结果。
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci**参数:**
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci| 参数名   | 类型                             | 必填 | 说明                     |
853e41f4b71Sopenharmony_ci| -------- | -------------------------------| ---- | ------------------------ |
854e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)| 是   | 当前应用的上下文。         |
855e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)  | 是   | 被设置的系统铃声的类型。   |
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci**返回值:**
858e41f4b71Sopenharmony_ci
859e41f4b71Sopenharmony_ci| 类型                | 说明                                |
860e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
861e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回获取的系统铃声uri。 |
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci**错误码:**
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
868e41f4b71Sopenharmony_ci| -------- | --------------------- |
869e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
870e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
871e41f4b71Sopenharmony_ci| 5400103  | I/O error. |
872e41f4b71Sopenharmony_ci
873e41f4b71Sopenharmony_ci**示例:**
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ci```ts
876e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
877e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
880e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
883e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtoneUri(context, type).then((value: string) => {
884e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
885e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
886e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone uri ${err}`);
887e41f4b71Sopenharmony_ci});
888e41f4b71Sopenharmony_ci```
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci### getRingtonePlayer<sup>11+</sup>
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_cigetRingtonePlayer(context: BaseContext, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci获取系统铃声播放器,使用Promise方式异步返回结果。
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_ci**参数:**
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ci| 参数名   | 类型                              | 必填 | 说明                         |
903e41f4b71Sopenharmony_ci| -------- | --------------------------------| ---- | --------------------------- |
904e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
905e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)   | 是   | 待获取播放器的系统铃声的类型。 |
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci**返回值:**
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci| 类型                | 说明                            |
910e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
911e41f4b71Sopenharmony_ci| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise回调返回获取的系统铃声播放器。 |
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci**错误码:**
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
918e41f4b71Sopenharmony_ci| -------- | --------------------- |
919e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
920e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci**示例:**
923e41f4b71Sopenharmony_ci
924e41f4b71Sopenharmony_ci```ts
925e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
926e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
929e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
930e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
933e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
934e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
935e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
936e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
937e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone player ${err}`);
938e41f4b71Sopenharmony_ci});
939e41f4b71Sopenharmony_ci```
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci### setSystemToneUri<sup>11+</sup>
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_cisetSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise&lt;void&gt;
944e41f4b71Sopenharmony_ci
945e41f4b71Sopenharmony_ci设置系统提示音uri,使用Promise方式异步返回结果。
946e41f4b71Sopenharmony_ci
947e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci**参数:**
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                     |
954e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | ------------------------ |
955e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。         |
956e41f4b71Sopenharmony_ci| uri      | string                              | 是   | 被设置的系统提示音的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
957e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | 是   | 被设置的系统提示音的类型。   |
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ci**返回值:**
960e41f4b71Sopenharmony_ci
961e41f4b71Sopenharmony_ci| 类型                | 说明                            |
962e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
963e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。   |
964e41f4b71Sopenharmony_ci
965e41f4b71Sopenharmony_ci**错误码:**
966e41f4b71Sopenharmony_ci
967e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
968e41f4b71Sopenharmony_ci
969e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
970e41f4b71Sopenharmony_ci| ------- | --------------------- |
971e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
972e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
973e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ci**示例:**
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ci```ts
978e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
979e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
982e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
983e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
986e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemToneUri(context, uri, type).then(() => {
987e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system tone uri.`);
988e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
989e41f4b71Sopenharmony_ci  console.error(`Failed to set the system tone uri ${err}`);
990e41f4b71Sopenharmony_ci});
991e41f4b71Sopenharmony_ci```
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci### getSystemToneUri<sup>11+</sup>
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_cigetSystemToneUri(context: BaseContext, type: SystemToneType): Promise&lt;string&gt;
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci获取系统提示音uri,使用Promise方式异步返回结果。
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**参数:**
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                     |
1006e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | ------------------------ |
1007e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。         |
1008e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | 是   | 被设置的系统提示音的类型。   |
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_ci**返回值:**
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ci| 类型                | 说明                                |
1013e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
1014e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回获取的系统提示音uri。 |
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci**错误码:**
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1021e41f4b71Sopenharmony_ci| ------- | --------------------- |
1022e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1023e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1024e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_ci**示例:**
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ci```ts
1029e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1030e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1033e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1036e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemToneUri(context, type).then((value: string) => {
1037e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone uri is obtained ${value}.`);
1038e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1039e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone uri ${err}`);
1040e41f4b71Sopenharmony_ci});
1041e41f4b71Sopenharmony_ci```
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci### getSystemTonePlayer<sup>11+</sup>
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_cigetSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise&lt;SystemTonePlayer&gt;
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci获取系统提示音播放器,使用Promise方式异步返回结果。
1048e41f4b71Sopenharmony_ci
1049e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1050e41f4b71Sopenharmony_ci
1051e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1052e41f4b71Sopenharmony_ci
1053e41f4b71Sopenharmony_ci**参数:**
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                         |
1056e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
1057e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
1058e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | 是   | 待获取播放器的系统提示音的类型。 |
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ci**返回值:**
1061e41f4b71Sopenharmony_ci
1062e41f4b71Sopenharmony_ci| 类型                                                                                               | 说明                            |
1063e41f4b71Sopenharmony_ci|--------------------------------------------------------------------------------------------------| ------------------------------- |
1064e41f4b71Sopenharmony_ci| Promise&lt;[SystemTonePlayer](js-apis-inner-multimedia-systemTonePlayer-sys.md#systemtoneplayer)&gt; | Promise回调返回获取的系统提示音播放器。 |
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ci**错误码:**
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1071e41f4b71Sopenharmony_ci| ------- | --------------------- |
1072e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1073e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_ci**示例:**
1076e41f4b71Sopenharmony_ci
1077e41f4b71Sopenharmony_ci```ts
1078e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1079e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1080e41f4b71Sopenharmony_ci
1081e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1082e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1083e41f4b71Sopenharmony_cilet systemTonePlayer: systemSoundManager.SystemTonePlayer | undefined = undefined;
1084e41f4b71Sopenharmony_ci
1085e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1086e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemTonePlayer(context, type).then((value: systemSoundManager.SystemTonePlayer) => {
1087e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone player is obtained.`);
1088e41f4b71Sopenharmony_ci    systemTonePlayer = value;
1089e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1090e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone player ${err}`);
1091e41f4b71Sopenharmony_ci});
1092e41f4b71Sopenharmony_ci```
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci### getDefaultRingtoneAttrs<sup>12+</sup>
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_cigetDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrs&gt;
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci获取系统铃声的属性,使用Promise方式异步返回结果。
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ci**参数:**
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                         |
1107e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
1108e41f4b71Sopenharmony_ci| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
1109e41f4b71Sopenharmony_ci| type     |[RingtoneType](#ringtonetype)        | 是   | 被设置的系统铃声的类型。  |
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci**返回值:**
1112e41f4b71Sopenharmony_ci
1113e41f4b71Sopenharmony_ci| 类型                                       | 说明                  |
1114e41f4b71Sopenharmony_ci|------------------------------------------|---------------------|
1115e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise回调返回系统铃声的属性。 |
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci**错误码:**
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1122e41f4b71Sopenharmony_ci| ------- | --------------------- |
1123e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1124e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1125e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_ci**示例:**
1128e41f4b71Sopenharmony_ci
1129e41f4b71Sopenharmony_ci```ts
1130e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1131e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1134e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1135e41f4b71Sopenharmony_ci
1136e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1137e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultRingtoneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1138e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the default ringtone is obtained.`);
1139e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1140e41f4b71Sopenharmony_ci  console.error(`Failed to get the default ring tone attrs ${err}`);
1141e41f4b71Sopenharmony_ci});
1142e41f4b71Sopenharmony_ci```
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci### getRingtoneAttrList<sup>12+</sup>
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_cigetRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrsArray&gt;
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci获取系统铃声的属性列表,使用Promise方式异步返回结果。
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**参数:**
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                         |
1157e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
1158e41f4b71Sopenharmony_ci| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
1159e41f4b71Sopenharmony_ci| type     |[RingtoneType](#ringtonetype)        | 是   | 被设置的系统铃声的类型。  |
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_ci**返回值:**
1162e41f4b71Sopenharmony_ci
1163e41f4b71Sopenharmony_ci| 类型                                                 | 说明                    |
1164e41f4b71Sopenharmony_ci|----------------------------------------------------|-----------------------|
1165e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise回调返回系统铃声的属性列表。 |
1166e41f4b71Sopenharmony_ci
1167e41f4b71Sopenharmony_ci**错误码:**
1168e41f4b71Sopenharmony_ci
1169e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1172e41f4b71Sopenharmony_ci| ------- | --------------------- |
1173e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1174e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1175e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_ci**示例:**
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ci```ts
1180e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1181e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1184e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1185e41f4b71Sopenharmony_ci
1186e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1187e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtoneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1188e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of ringtone is obtained.`);
1189e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1190e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of ringtone ${err}`);
1191e41f4b71Sopenharmony_ci});
1192e41f4b71Sopenharmony_ci```
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ci### getDefaultSystemToneAttrs<sup>12+</sup>
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_cigetDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrs&gt;
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_ci获取系统提示音的属性,使用Promise方式异步返回结果。
1199e41f4b71Sopenharmony_ci
1200e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1201e41f4b71Sopenharmony_ci
1202e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_ci**参数:**
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci| 参数名   | 类型                                                                          | 必填 | 说明                         |
1207e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1208e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
1209e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11)                                         | 是   | 待获取播放器的系统提示音的类型。 |
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**返回值:**
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ci| 类型                                      | 说明                   |
1214e41f4b71Sopenharmony_ci|-----------------------------------------|----------------------|
1215e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise回调返回系统提示音的属性。 |
1216e41f4b71Sopenharmony_ci
1217e41f4b71Sopenharmony_ci**错误码:**
1218e41f4b71Sopenharmony_ci
1219e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1220e41f4b71Sopenharmony_ci
1221e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1222e41f4b71Sopenharmony_ci| ------- | --------------------- |
1223e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1224e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1225e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1226e41f4b71Sopenharmony_ci
1227e41f4b71Sopenharmony_ci**示例:**
1228e41f4b71Sopenharmony_ci
1229e41f4b71Sopenharmony_ci```ts
1230e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1231e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1232e41f4b71Sopenharmony_ci
1233e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1234e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1237e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultSystemToneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1238e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the system ringtone is obtained.`);
1239e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1240e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone attrs ${err}`);
1241e41f4b71Sopenharmony_ci});
1242e41f4b71Sopenharmony_ci```
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci### getSystemToneAttrList<sup>12+</sup>
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_cigetSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrsArray&gt;
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci获取系统提示音的属性列表,使用Promise方式异步返回结果。
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci**参数:**
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci| 参数名   | 类型                                                                          | 必填 | 说明                         |
1257e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1258e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。            |
1259e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11)                                         | 是   | 待获取播放器的系统提示音的类型。  |
1260e41f4b71Sopenharmony_ci
1261e41f4b71Sopenharmony_ci**返回值:**
1262e41f4b71Sopenharmony_ci
1263e41f4b71Sopenharmony_ci| 类型                                                | 说明                     |
1264e41f4b71Sopenharmony_ci|---------------------------------------------------|------------------------|
1265e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise回调返回系统提示音的属性列表。 |
1266e41f4b71Sopenharmony_ci
1267e41f4b71Sopenharmony_ci**错误码:**
1268e41f4b71Sopenharmony_ci
1269e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1270e41f4b71Sopenharmony_ci
1271e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1272e41f4b71Sopenharmony_ci| ------- | --------------------- |
1273e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1274e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1275e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ci**示例:**
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ci```ts
1280e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1281e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1284e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1285e41f4b71Sopenharmony_ci
1286e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1287e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemToneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1288e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of system tone is obtained.`);
1289e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1290e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of system tone ${err}`);
1291e41f4b71Sopenharmony_ci});
1292e41f4b71Sopenharmony_ci```
1293e41f4b71Sopenharmony_ci
1294e41f4b71Sopenharmony_ci### getDefaultAlarmToneAttrs<sup>12+</sup>
1295e41f4b71Sopenharmony_ci
1296e41f4b71Sopenharmony_cigetDefaultAlarmToneAttrs(context: BaseContext): Promise&lt;ToneAttrs&gt;
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci获取系统闹铃的属性,使用Promise方式异步返回结果。
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci**参数:**
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ci| 参数名   | 类型         | 必填 | 说明        |
1307e41f4b71Sopenharmony_ci| --------|------------| ---- |-----------|
1308e41f4b71Sopenharmony_ci| context | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | 是   | 当前应用的上下文。 |
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci**返回值:**
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci| 类型                                      | 说明                  |
1313e41f4b71Sopenharmony_ci|-----------------------------------------|---------------------|
1314e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; | Promise回调返回系统闹铃的属性。 |
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci**错误码:**
1317e41f4b71Sopenharmony_ci
1318e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1321e41f4b71Sopenharmony_ci| ------- | --------------------- |
1322e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1323e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1324e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_ci**示例:**
1327e41f4b71Sopenharmony_ci
1328e41f4b71Sopenharmony_ci```ts
1329e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1330e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1331e41f4b71Sopenharmony_ci
1332e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1335e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultAlarmToneAttrs(context).then((value: systemSoundManager.ToneAttrs) => {
1336e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the default alarm tone is obtained.`);
1337e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1338e41f4b71Sopenharmony_ci  console.error(`Failed to get the default alarm tone attrs ${err}`);
1339e41f4b71Sopenharmony_ci});
1340e41f4b71Sopenharmony_ci```
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci### setAlarmToneUri<sup>12+</sup>
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_cisetAlarmToneUri(context: Context, uri: string): Promise&lt;void&gt;
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_ci设置系统闹铃uri,使用Promise方式异步返回结果。
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1349e41f4b71Sopenharmony_ci
1350e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1351e41f4b71Sopenharmony_ci
1352e41f4b71Sopenharmony_ci**参数:**
1353e41f4b71Sopenharmony_ci
1354e41f4b71Sopenharmony_ci| 参数名   | 类型        | 必填 | 说明   |
1355e41f4b71Sopenharmony_ci| -------- | --------- | ---- |--------------------------|
1356e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。                                                                           |
1357e41f4b71Sopenharmony_ci| uri      | string    | 是   | 被设置的系统闹铃的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci**返回值:**
1360e41f4b71Sopenharmony_ci
1361e41f4b71Sopenharmony_ci| 类型                | 说明                   |
1362e41f4b71Sopenharmony_ci| ------------------- |----------------------|
1363e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。  |
1364e41f4b71Sopenharmony_ci
1365e41f4b71Sopenharmony_ci**示例:**
1366e41f4b71Sopenharmony_ci
1367e41f4b71Sopenharmony_ci```ts
1368e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1369e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1370e41f4b71Sopenharmony_ci
1371e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1372e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
1373e41f4b71Sopenharmony_ci
1374e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1375e41f4b71Sopenharmony_cisystemSoundManagerInstance.setAlarmToneUri(context, uri).then(() => {
1376e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the alarm tone uri.`);
1377e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1378e41f4b71Sopenharmony_ci  console.error(`Failed to set the alarm tone uri ${err}`);
1379e41f4b71Sopenharmony_ci});
1380e41f4b71Sopenharmony_ci```
1381e41f4b71Sopenharmony_ci
1382e41f4b71Sopenharmony_ci### getAlarmToneUri<sup>12+</sup>
1383e41f4b71Sopenharmony_ci
1384e41f4b71Sopenharmony_cigetAlarmToneUri(context: Context): Promise&lt;string&gt;
1385e41f4b71Sopenharmony_ci
1386e41f4b71Sopenharmony_ci获取系统当前闹铃uri,使用Promise方式异步返回结果。
1387e41f4b71Sopenharmony_ci
1388e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1389e41f4b71Sopenharmony_ci
1390e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1391e41f4b71Sopenharmony_ci
1392e41f4b71Sopenharmony_ci**参数:**
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ci| 参数名   | 类型      | 必填 | 说明              |
1395e41f4b71Sopenharmony_ci| -------- | --------| ---- |-----------------|
1396e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。  |
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_ci**返回值:**
1399e41f4b71Sopenharmony_ci
1400e41f4b71Sopenharmony_ci| 类型                    | 说明                    |
1401e41f4b71Sopenharmony_ci|-----------------------|-----------------------|
1402e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回系统当前闹铃uri。 |
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci**示例:**
1405e41f4b71Sopenharmony_ci
1406e41f4b71Sopenharmony_ci```ts
1407e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1408e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1409e41f4b71Sopenharmony_ci
1410e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1411e41f4b71Sopenharmony_ci
1412e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1413e41f4b71Sopenharmony_cisystemSoundManagerInstance.getAlarmToneUri(context).then((value: string) => {
1414e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of alarm tone uri.`);
1415e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1416e41f4b71Sopenharmony_ci  console.error(`Failed to get the alarm tone uri ${err}`);
1417e41f4b71Sopenharmony_ci});
1418e41f4b71Sopenharmony_ci```
1419e41f4b71Sopenharmony_ci
1420e41f4b71Sopenharmony_ci### getAlarmToneAttrList<sup>12+</sup>
1421e41f4b71Sopenharmony_ci
1422e41f4b71Sopenharmony_cigetAlarmToneAttrList(context: BaseContext): Promise&lt;ToneAttrsArray&gt;
1423e41f4b71Sopenharmony_ci
1424e41f4b71Sopenharmony_ci获取全部闹铃属性列表,使用Promise方式异步返回结果。
1425e41f4b71Sopenharmony_ci
1426e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1427e41f4b71Sopenharmony_ci
1428e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1429e41f4b71Sopenharmony_ci
1430e41f4b71Sopenharmony_ci**参数:**
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci| 参数名   | 类型            | 必填 | 说明                         |
1433e41f4b71Sopenharmony_ci| -------- |--------------| ---- | --------------------------- |
1434e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)  | 是   | 当前应用的上下文。            |
1435e41f4b71Sopenharmony_ci
1436e41f4b71Sopenharmony_ci**返回值:**
1437e41f4b71Sopenharmony_ci
1438e41f4b71Sopenharmony_ci| 类型                                                 | 说明                   |
1439e41f4b71Sopenharmony_ci|----------------------------------------------------|----------------------|
1440e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise回调返回全部闹铃属性列表。 |
1441e41f4b71Sopenharmony_ci
1442e41f4b71Sopenharmony_ci**错误码:**
1443e41f4b71Sopenharmony_ci
1444e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1445e41f4b71Sopenharmony_ci
1446e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1447e41f4b71Sopenharmony_ci| ------- | --------------------- |
1448e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1449e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1450e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1451e41f4b71Sopenharmony_ci
1452e41f4b71Sopenharmony_ci**示例:**
1453e41f4b71Sopenharmony_ci
1454e41f4b71Sopenharmony_ci```ts
1455e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1456e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1457e41f4b71Sopenharmony_ci
1458e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1459e41f4b71Sopenharmony_ci
1460e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1461e41f4b71Sopenharmony_cisystemSoundManagerInstance.getAlarmToneAttrList(context).then((value: systemSoundManager.ToneAttrsArray) => {
1462e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of alarm tone is obtained.`);
1463e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1464e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of alarm tone ${err}`);
1465e41f4b71Sopenharmony_ci});
1466e41f4b71Sopenharmony_ci```
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_ci### openAlarmTone<sup>12+</sup>
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ciopenAlarmTone(context: Context, uri: string): Promise&lt;number&gt;
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci打开闹铃文件,使用Promise方式异步返回结果。
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1477e41f4b71Sopenharmony_ci
1478e41f4b71Sopenharmony_ci**参数:**
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明                                                                                  |
1481e41f4b71Sopenharmony_ci| -------- | ---------| ---- |-------------------------------------------------------------------------------------|
1482e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。                                                                           |
1483e41f4b71Sopenharmony_ci| uri      | string   | 是   | 被设置的系统闹铃的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
1484e41f4b71Sopenharmony_ci
1485e41f4b71Sopenharmony_ci**返回值:**
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci| 类型                    | 说明             |
1488e41f4b71Sopenharmony_ci|-----------------------|----------------|
1489e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise回调返回fd。 |
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci**错误码:**
1492e41f4b71Sopenharmony_ci
1493e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1494e41f4b71Sopenharmony_ci
1495e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1496e41f4b71Sopenharmony_ci| ------- | --------------------- |
1497e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1498e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1499e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1500e41f4b71Sopenharmony_ci| 20700001 | Tone type mismatch, e.g. tone of uri is notification instead of alarm. |
1501e41f4b71Sopenharmony_ci
1502e41f4b71Sopenharmony_ci**示例:**
1503e41f4b71Sopenharmony_ci
1504e41f4b71Sopenharmony_ci```ts
1505e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1506e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1507e41f4b71Sopenharmony_ci
1508e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1509e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1512e41f4b71Sopenharmony_cisystemSoundManagerInstance.openAlarmTone(context, uri).then((value: number) => {
1513e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate the value of fd.`);
1514e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1515e41f4b71Sopenharmony_ci  console.error(`Failed to open alarm tone ${err}`);
1516e41f4b71Sopenharmony_ci});
1517e41f4b71Sopenharmony_ci```
1518e41f4b71Sopenharmony_ci
1519e41f4b71Sopenharmony_ci### close<sup>12+</sup>
1520e41f4b71Sopenharmony_ci
1521e41f4b71Sopenharmony_ciclose(fd: number): Promise&lt;void&gt;
1522e41f4b71Sopenharmony_ci
1523e41f4b71Sopenharmony_ci关闭闹铃文件,使用Promise方式异步返回结果。
1524e41f4b71Sopenharmony_ci
1525e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1526e41f4b71Sopenharmony_ci
1527e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1528e41f4b71Sopenharmony_ci
1529e41f4b71Sopenharmony_ci**参数:**
1530e41f4b71Sopenharmony_ci
1531e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                           |
1532e41f4b71Sopenharmony_ci|-----| --------| ---- |----------------------------------------------|
1533e41f4b71Sopenharmony_ci| fd  | number  | 是   | 文件描述符,通过[openAlarmTone](#openalarmtone12)获取。 |
1534e41f4b71Sopenharmony_ci
1535e41f4b71Sopenharmony_ci**返回值:**
1536e41f4b71Sopenharmony_ci
1537e41f4b71Sopenharmony_ci| 类型                  | 说明             |
1538e41f4b71Sopenharmony_ci|---------------------|----------------|
1539e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。 |
1540e41f4b71Sopenharmony_ci
1541e41f4b71Sopenharmony_ci**错误码:**
1542e41f4b71Sopenharmony_ci
1543e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1544e41f4b71Sopenharmony_ci
1545e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1546e41f4b71Sopenharmony_ci| ------- | --------------------- |
1547e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1548e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1549e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1550e41f4b71Sopenharmony_ci
1551e41f4b71Sopenharmony_ci**示例:**
1552e41f4b71Sopenharmony_ci
1553e41f4b71Sopenharmony_ci```ts
1554e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1555e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1556e41f4b71Sopenharmony_ci
1557e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1558e41f4b71Sopenharmony_cilet fd = 50; // 需更改为目标铃声的fd
1559e41f4b71Sopenharmony_ci
1560e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1561e41f4b71Sopenharmony_cisystemSoundManagerInstance.close(fd).then(() => {
1562e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the fd has been close.`);
1563e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1564e41f4b71Sopenharmony_ci  console.error(`Failed to close fd ${err}`);
1565e41f4b71Sopenharmony_ci});
1566e41f4b71Sopenharmony_ci```
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci### addCustomizedTone<sup>12+</sup>
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_ciaddCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise&lt;string&gt;
1571e41f4b71Sopenharmony_ci
1572e41f4b71Sopenharmony_ci通过铃音uri将自定义铃音添加到铃音库,使用Promise方式异步返回结果。
1573e41f4b71Sopenharmony_ci
1574e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1575e41f4b71Sopenharmony_ci
1576e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1577e41f4b71Sopenharmony_ci
1578e41f4b71Sopenharmony_ci**参数:**
1579e41f4b71Sopenharmony_ci
1580e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明            |
1581e41f4b71Sopenharmony_ci|-----|-----------| ---- |---------------|
1582e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。     |
1583e41f4b71Sopenharmony_ci| toneAttr  | ToneAttrs | 是   | 铃音属性。         |
1584e41f4b71Sopenharmony_ci| externalUri  | string    | 是   | 外部存储器中的铃音uri。 |
1585e41f4b71Sopenharmony_ci
1586e41f4b71Sopenharmony_ci**返回值:**
1587e41f4b71Sopenharmony_ci
1588e41f4b71Sopenharmony_ci| 类型                    | 说明                      |
1589e41f4b71Sopenharmony_ci|-----------------------|-------------------------|
1590e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回铃音在铃音库中的uri。 |
1591e41f4b71Sopenharmony_ci
1592e41f4b71Sopenharmony_ci**错误码:**
1593e41f4b71Sopenharmony_ci
1594e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1595e41f4b71Sopenharmony_ci
1596e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1597e41f4b71Sopenharmony_ci|---------| -------------------- |
1598e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1599e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1600e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1601e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1602e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1603e41f4b71Sopenharmony_ci
1604e41f4b71Sopenharmony_ci**示例:**
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci```ts
1607e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1608e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1609e41f4b71Sopenharmony_ci
1610e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1611e41f4b71Sopenharmony_cilet title = 'test'; // 需更改为实际名称
1612e41f4b71Sopenharmony_cilet fileName = 'displayName_test'; // 需更改为实际文件名
1613e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1614e41f4b71Sopenharmony_ci
1615e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1616e41f4b71Sopenharmony_citoneAttrs.setTitle(title);
1617e41f4b71Sopenharmony_citoneAttrs.setFileName(fileName);
1618e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_cilet path = 'file://data/test.ogg'; // 需更改为实际铃音uri
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1623e41f4b71Sopenharmony_cisystemSoundManagerInstance.addCustomizedTone(context, toneAttrs, path).then((value: string) => {
1624e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1625e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1626e41f4b71Sopenharmony_ci  console.error(`Failed to add customized tone ${err}`);
1627e41f4b71Sopenharmony_ci});
1628e41f4b71Sopenharmony_ci```
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci### addCustomizedTone<sup>12+</sup>
1631e41f4b71Sopenharmony_ci
1632e41f4b71Sopenharmony_ciaddCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number): Promise&lt;string&gt;
1633e41f4b71Sopenharmony_ci
1634e41f4b71Sopenharmony_ci通过文件描述符fd将自定义铃音添加到铃音库,使用Promise方式异步返回结果。
1635e41f4b71Sopenharmony_ci
1636e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1637e41f4b71Sopenharmony_ci
1638e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ci**参数:**
1641e41f4b71Sopenharmony_ci
1642e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                     |
1643e41f4b71Sopenharmony_ci|-----|-----------|----|------------------------------------------------------------------------|
1644e41f4b71Sopenharmony_ci| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是  | 当前应用的上下文。                                                              |
1645e41f4b71Sopenharmony_ci| toneAttr | [ToneAttrs](#toneattrs12) | 是  | 铃音属性。                                                                  |
1646e41f4b71Sopenharmony_ci| fd  | number    | 是  | 文件描述符,可通过[fs.open](../apis-core-file-kit/js-apis-file-fs.md#fsopen)获取。 |
1647e41f4b71Sopenharmony_ci| offset | number    | 否  | 读取数据的偏移量(以字节为单位)。默认情况下为0。                                              |
1648e41f4b71Sopenharmony_ci| length | number    | 否  | 读取的数据的长度(以字节为单位)。默认情况下,长度为偏移后的剩余全部字节数。                                 |
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci**返回值:**
1651e41f4b71Sopenharmony_ci
1652e41f4b71Sopenharmony_ci| 类型                    | 说明                      |
1653e41f4b71Sopenharmony_ci|-----------------------|-------------------------|
1654e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise回调返回铃音在铃音库中的uri。 |
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci**错误码:**
1657e41f4b71Sopenharmony_ci
1658e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1659e41f4b71Sopenharmony_ci
1660e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1661e41f4b71Sopenharmony_ci|---------| -------------------- |
1662e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1663e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1664e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1665e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1666e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1667e41f4b71Sopenharmony_ci
1668e41f4b71Sopenharmony_ci**示例:**
1669e41f4b71Sopenharmony_ci
1670e41f4b71Sopenharmony_ci```ts
1671e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1672e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1673e41f4b71Sopenharmony_ci
1674e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1675e41f4b71Sopenharmony_cilet title = 'test'; // 需更改为实际名称
1676e41f4b71Sopenharmony_cilet fileName = 'displayName_test'; // 需更改为实际文件名
1677e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1678e41f4b71Sopenharmony_ci
1679e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1680e41f4b71Sopenharmony_citoneAttrs.setTitle(title);
1681e41f4b71Sopenharmony_citoneAttrs.setFileName(fileName);
1682e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
1683e41f4b71Sopenharmony_ci
1684e41f4b71Sopenharmony_cilet fd = 10; // 需更改为实际铃音fd,
1685e41f4b71Sopenharmony_cilet offset = 0; // 需更改为实际所需偏移量
1686e41f4b71Sopenharmony_cilet length = 50; // 需更改为实际所需数据长度
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1689e41f4b71Sopenharmony_cisystemSoundManagerInstance.addCustomizedTone(context, toneAttrs, fd, offset, length).then((value: string) => {
1690e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1691e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1692e41f4b71Sopenharmony_ci  console.error(`Failed to add customized tone ${err}`);
1693e41f4b71Sopenharmony_ci});
1694e41f4b71Sopenharmony_ci```
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci### removeCustomizedTone<sup>12+</sup>
1697e41f4b71Sopenharmony_ci
1698e41f4b71Sopenharmony_ciremoveCustomizedTone(context: BaseContext, uri: string): Promise&lt;void&gt;
1699e41f4b71Sopenharmony_ci
1700e41f4b71Sopenharmony_ci从铃音库中删除自定义铃音,使用Promise方式异步返回结果。
1701e41f4b71Sopenharmony_ci
1702e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1703e41f4b71Sopenharmony_ci
1704e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1705e41f4b71Sopenharmony_ci
1706e41f4b71Sopenharmony_ci**参数:**
1707e41f4b71Sopenharmony_ci
1708e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                                                      |
1709e41f4b71Sopenharmony_ci|-----|-----------| ---- |---------------------------------------------------------------------------------------------------------|
1710e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。                                                                                               |
1711e41f4b71Sopenharmony_ci| uri  | string    | 是   | 铃音uri,可通过[addCustomizedTone](#addcustomizedtone12)或[getAlarmToneAttrList](#getalarmtoneattrlist12)等方法获取 |
1712e41f4b71Sopenharmony_ci
1713e41f4b71Sopenharmony_ci**返回值:**
1714e41f4b71Sopenharmony_ci
1715e41f4b71Sopenharmony_ci| 类型                  | 说明                    |
1716e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1717e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。 |
1718e41f4b71Sopenharmony_ci
1719e41f4b71Sopenharmony_ci**错误码:**
1720e41f4b71Sopenharmony_ci
1721e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1722e41f4b71Sopenharmony_ci
1723e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1724e41f4b71Sopenharmony_ci|---------| -------------------- |
1725e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1726e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1727e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1728e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1729e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci**示例:**
1732e41f4b71Sopenharmony_ci
1733e41f4b71Sopenharmony_ci```ts
1734e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1735e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1738e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // 需更改为目标铃声文件的uri
1739e41f4b71Sopenharmony_ci
1740e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1741e41f4b71Sopenharmony_cisystemSoundManagerInstance.removeCustomizedTone(context, uri).then(() => {
1742e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the customized tone has been deleted.`);
1743e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1744e41f4b71Sopenharmony_ci  console.error(`Failed to delete customized tone ${err}`);
1745e41f4b71Sopenharmony_ci});
1746e41f4b71Sopenharmony_ci```
1747e41f4b71Sopenharmony_ci
1748e41f4b71Sopenharmony_ci### getToneHapticsSettings<sup>13+</sup>
1749e41f4b71Sopenharmony_ci
1750e41f4b71Sopenharmony_cigetToneHapticsSettings(context: BaseContext, type: ToneHapticsType): Promise&lt;ToneHapticsSettings&gt;
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci获取系统铃音的振动设置,使用Promise方式异步返回结果。
1753e41f4b71Sopenharmony_ci
1754e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1755e41f4b71Sopenharmony_ci
1756e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci**参数:**
1759e41f4b71Sopenharmony_ci
1760e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                          |
1761e41f4b71Sopenharmony_ci|-----|-----------| ---- |----------------------------------------------------------------------------------|
1762e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。   |
1763e41f4b71Sopenharmony_ci| type  | [ToneHapticsType](#tonehapticstype13)    | 是   | 待获取系统铃音的振动类型。 |
1764e41f4b71Sopenharmony_ci
1765e41f4b71Sopenharmony_ci**返回值:**
1766e41f4b71Sopenharmony_ci
1767e41f4b71Sopenharmony_ci| 类型                  | 说明                    |
1768e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1769e41f4b71Sopenharmony_ci| Promise&lt;[ToneHapticsSettings](#tonehapticssettings13)&gt; | Promise回调返回铃声的振动设置。 |
1770e41f4b71Sopenharmony_ci
1771e41f4b71Sopenharmony_ci**错误码:**
1772e41f4b71Sopenharmony_ci
1773e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1774e41f4b71Sopenharmony_ci
1775e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1776e41f4b71Sopenharmony_ci|---------| -------------------- |
1777e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1778e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1779e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1780e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation. |
1781e41f4b71Sopenharmony_ci
1782e41f4b71Sopenharmony_ci**示例:**
1783e41f4b71Sopenharmony_ci
1784e41f4b71Sopenharmony_ci```ts
1785e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1786e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1787e41f4b71Sopenharmony_ci
1788e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1789e41f4b71Sopenharmony_cilet type: systemSoundManager.ToneHapticsType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1790e41f4b71Sopenharmony_ci
1791e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1792e41f4b71Sopenharmony_cisystemSoundManagerInstance.getToneHapticsSettings(context, type).then((value: systemSoundManager.ToneHapticsSettings) => {
1793e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the tone haptics settings is obtained.`);
1794e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1795e41f4b71Sopenharmony_ci  console.error(`Failed to get the tone haptics settings ${err}`);
1796e41f4b71Sopenharmony_ci});
1797e41f4b71Sopenharmony_ci```
1798e41f4b71Sopenharmony_ci
1799e41f4b71Sopenharmony_ci### setToneHapticsSettings<sup>13+</sup>
1800e41f4b71Sopenharmony_ci
1801e41f4b71Sopenharmony_cisetToneHapticsSettings(context: BaseContext, type: ToneHapticsType, settings: ToneHapticsSettings): Promise&lt;void&gt;
1802e41f4b71Sopenharmony_ci
1803e41f4b71Sopenharmony_ci设置系统铃音的振动,使用Promise方式异步返回结果。
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ci**参数:**
1810e41f4b71Sopenharmony_ci
1811e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                          |
1812e41f4b71Sopenharmony_ci|-----|-----------| ---- |----------------------------------------------------------------------------------|
1813e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。   |
1814e41f4b71Sopenharmony_ci| type  | [ToneHapticsType](#tonehapticstype13)    | 是   | 被设置的系统铃音的振动类型。 |
1815e41f4b71Sopenharmony_ci| settings  | [ToneHapticsSettings](#tonehapticssettings13)    | 是   | 被设置的系统铃音的振动设置。 |
1816e41f4b71Sopenharmony_ci
1817e41f4b71Sopenharmony_ci**返回值:**
1818e41f4b71Sopenharmony_ci
1819e41f4b71Sopenharmony_ci| 类型                  | 说明                    |
1820e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1821e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise回调返回设置成功或失败。 |
1822e41f4b71Sopenharmony_ci
1823e41f4b71Sopenharmony_ci**错误码:**
1824e41f4b71Sopenharmony_ci
1825e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1826e41f4b71Sopenharmony_ci
1827e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1828e41f4b71Sopenharmony_ci|---------| -------------------- |
1829e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1830e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1831e41f4b71Sopenharmony_ci| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1832e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1833e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation. |
1834e41f4b71Sopenharmony_ci
1835e41f4b71Sopenharmony_ci**示例:**
1836e41f4b71Sopenharmony_ci
1837e41f4b71Sopenharmony_ci```ts
1838e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1839e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1840e41f4b71Sopenharmony_ci
1841e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1842e41f4b71Sopenharmony_cilet type: systemSoundManager.ToneHapticsType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1843e41f4b71Sopenharmony_cilet toneHapticsSettings: systemSoundManager.ToneHapticsSettings = {
1844e41f4b71Sopenharmony_ci  mode: systemSoundManager.ToneHapticsMode.NON_SYNC,
1845e41f4b71Sopenharmony_ci  hapticsUri: '/data/storage/el2/base/haptics/synchronized/alarms/test.json', // 需更改为通过getToneHapticsList获取的Uri
1846e41f4b71Sopenharmony_ci}
1847e41f4b71Sopenharmony_ci
1848e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1849e41f4b71Sopenharmony_cisystemSoundManagerInstance.setToneHapticsSettings(context, type, toneHapticsSettings).then(() => {
1850e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the tone haptics.`);
1851e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1852e41f4b71Sopenharmony_ci  console.error(`Failed to set the tone haptics settings ${err}`);
1853e41f4b71Sopenharmony_ci});
1854e41f4b71Sopenharmony_ci```
1855e41f4b71Sopenharmony_ci
1856e41f4b71Sopenharmony_ci### getToneHapticsList<sup>13+</sup>
1857e41f4b71Sopenharmony_ci
1858e41f4b71Sopenharmony_cigetToneHapticsList(context: BaseContext, isSynced: boolean): Promise&lt;ToneHapticsAttrsArray&gt;
1859e41f4b71Sopenharmony_ci
1860e41f4b71Sopenharmony_ci获取同步或者非同步的系统铃音的振动属性列表,使用Promise方式异步返回结果。
1861e41f4b71Sopenharmony_ci
1862e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1865e41f4b71Sopenharmony_ci
1866e41f4b71Sopenharmony_ci**参数:**
1867e41f4b71Sopenharmony_ci
1868e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                          |
1869e41f4b71Sopenharmony_ci|-----|-----------| ---- |----------------------------------------------------------------------------------|
1870e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。   |
1871e41f4b71Sopenharmony_ci| isSynced  | boolean    | 是   | 待获取的振动是否与某个铃音同步。 |
1872e41f4b71Sopenharmony_ci
1873e41f4b71Sopenharmony_ci**返回值:**
1874e41f4b71Sopenharmony_ci
1875e41f4b71Sopenharmony_ci| 类型                  | 说明                    |
1876e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1877e41f4b71Sopenharmony_ci| Promise&lt;[ToneHapticsAttrsArray](#tonehapticsattrsarray13)&gt; | Promise回调返回同步或者非同步的系统铃音的振动属性列表。 |
1878e41f4b71Sopenharmony_ci
1879e41f4b71Sopenharmony_ci**错误码:**
1880e41f4b71Sopenharmony_ci
1881e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1882e41f4b71Sopenharmony_ci
1883e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1884e41f4b71Sopenharmony_ci|---------| -------------------- |
1885e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1886e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1887e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1888e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation. |
1889e41f4b71Sopenharmony_ci
1890e41f4b71Sopenharmony_ci**示例:**
1891e41f4b71Sopenharmony_ci
1892e41f4b71Sopenharmony_ci```ts
1893e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1894e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1895e41f4b71Sopenharmony_ci
1896e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1897e41f4b71Sopenharmony_ci
1898e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1899e41f4b71Sopenharmony_cisystemSoundManagerInstance.getToneHapticsList(context, false).then((value: systemSoundManager.ToneHapticsAttrsArray) => {
1900e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of tone haptics is obtained.`);
1901e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1902e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of tone haptics ${err}`);
1903e41f4b71Sopenharmony_ci});
1904e41f4b71Sopenharmony_ci```
1905e41f4b71Sopenharmony_ci
1906e41f4b71Sopenharmony_ci### getHapticsAttrsSyncedWithTone<sup>13+</sup>
1907e41f4b71Sopenharmony_ci
1908e41f4b71Sopenharmony_cigetHapticsAttrsSyncedWithTone(context: BaseContext, toneUri: string): Promise&lt;ToneHapticsAttrs&gt;
1909e41f4b71Sopenharmony_ci
1910e41f4b71Sopenharmony_ci获取与指定铃音同步的振动属性,使用Promise方式异步返回结果。
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ci**参数:**
1917e41f4b71Sopenharmony_ci
1918e41f4b71Sopenharmony_ci| 参数名 | 类型        | 必填 | 说明                                                                          |
1919e41f4b71Sopenharmony_ci|-----|-----------| ---- |----------------------------------------------------------------------------------|
1920e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。   |
1921e41f4b71Sopenharmony_ci| toneUri  | string    | 是   | 待获取同步振动的系统铃声Uri,可通过[getRingtoneAttrList](#getringtoneattrlist12)或[getSystemToneAttrList](#getsystemtoneattrlist12)等获取。 |
1922e41f4b71Sopenharmony_ci
1923e41f4b71Sopenharmony_ci**返回值:**
1924e41f4b71Sopenharmony_ci
1925e41f4b71Sopenharmony_ci| 类型                  | 说明                    |
1926e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1927e41f4b71Sopenharmony_ci| Promise&lt;[ToneHapticsAttrs](#tonehapticsattrs13)&gt; | Promise回调返回与指定铃音同步的振动属性。 |
1928e41f4b71Sopenharmony_ci
1929e41f4b71Sopenharmony_ci**错误码:**
1930e41f4b71Sopenharmony_ci
1931e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1932e41f4b71Sopenharmony_ci
1933e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息              |
1934e41f4b71Sopenharmony_ci|---------| -------------------- |
1935e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1936e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1937e41f4b71Sopenharmony_ci| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1938e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1939e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation. |
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci**示例:**
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_ci```ts
1944e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1945e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1946e41f4b71Sopenharmony_ci
1947e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1948e41f4b71Sopenharmony_cilet toneUri: string = '/data/storage/el2/base/RingTone/alarms/test.ogg'; // 需更改为实际铃音uri
1949e41f4b71Sopenharmony_ci
1950e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1951e41f4b71Sopenharmony_cisystemSoundManagerInstance.getHapticsAttrsSyncedWithTone(context, toneUri).then((value: systemSoundManager.ToneHapticsAttrs) => {
1952e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute of tone haptics is obtained.`);
1953e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1954e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute of tone haptics ${err}`);
1955e41f4b71Sopenharmony_ci});
1956e41f4b71Sopenharmony_ci```
1957e41f4b71Sopenharmony_ci
1958e41f4b71Sopenharmony_ci### openToneHaptics<sup>13+</sup>
1959e41f4b71Sopenharmony_ci
1960e41f4b71Sopenharmony_ciopenToneHaptics(context: Context, hapticsUri: string): Promise&lt;number&gt;
1961e41f4b71Sopenharmony_ci
1962e41f4b71Sopenharmony_ci打开系统铃音的振动,使用Promise方式异步返回结果。
1963e41f4b71Sopenharmony_ci
1964e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口。
1965e41f4b71Sopenharmony_ci
1966e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
1967e41f4b71Sopenharmony_ci
1968e41f4b71Sopenharmony_ci**参数:**
1969e41f4b71Sopenharmony_ci
1970e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明                                                                                  |
1971e41f4b71Sopenharmony_ci| -------- | ---------| ---- |-------------------------------------------------------------------------------------|
1972e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 当前应用的上下文。           |
1973e41f4b71Sopenharmony_ci| hapticsUri      | string   | 是   | 待打开系统铃音的振动的uri,资源支持可参考[media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9)。 |
1974e41f4b71Sopenharmony_ci
1975e41f4b71Sopenharmony_ci**返回值:**
1976e41f4b71Sopenharmony_ci
1977e41f4b71Sopenharmony_ci| 类型                    | 说明             |
1978e41f4b71Sopenharmony_ci|-----------------------|----------------|
1979e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise回调返回fd。 |
1980e41f4b71Sopenharmony_ci
1981e41f4b71Sopenharmony_ci**错误码:**
1982e41f4b71Sopenharmony_ci
1983e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)。
1984e41f4b71Sopenharmony_ci
1985e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
1986e41f4b71Sopenharmony_ci| ------- | --------------------- |
1987e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1988e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1989e41f4b71Sopenharmony_ci| 5400102 | Operation is not allowed, e.g. ringtone to add is not customized. |
1990e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1991e41f4b71Sopenharmony_ci| 20700003 | Unsupported operation. |
1992e41f4b71Sopenharmony_ci
1993e41f4b71Sopenharmony_ci**示例:**
1994e41f4b71Sopenharmony_ci
1995e41f4b71Sopenharmony_ci```ts
1996e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1997e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1998e41f4b71Sopenharmony_ci
1999e41f4b71Sopenharmony_cilet context: Context = getContext(this);
2000e41f4b71Sopenharmony_cilet hapticsUri = '/data/storage/el2/base/haptics/synchronized/alarms/test.json'; // 需更改为目标统铃音的振动的uri
2001e41f4b71Sopenharmony_ci
2002e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
2003e41f4b71Sopenharmony_cisystemSoundManagerInstance.openToneHaptics(context, hapticsUri).then((value: number) => {
2004e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate the value of fd.`);
2005e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
2006e41f4b71Sopenharmony_ci  console.error(`Failed to open haptics ${err}`);
2007e41f4b71Sopenharmony_ci});
2008e41f4b71Sopenharmony_ci```
2009e41f4b71Sopenharmony_ci
2010e41f4b71Sopenharmony_ci## RingtonePlayer<sup>10+</sup>
2011e41f4b71Sopenharmony_ci
2012e41f4b71Sopenharmony_citype RingtonePlayer = _RingtonePlayer;
2013e41f4b71Sopenharmony_ci
2014e41f4b71Sopenharmony_ci系统铃音播放器对象。
2015e41f4b71Sopenharmony_ci
2016e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
2017e41f4b71Sopenharmony_ci
2018e41f4b71Sopenharmony_ci| 类型              |说明     |
2019e41f4b71Sopenharmony_ci|-----------------|-------|
2020e41f4b71Sopenharmony_ci| _RingtonePlayer | 系统铃音播放器。 |
2021e41f4b71Sopenharmony_ci
2022e41f4b71Sopenharmony_ci## SystemTonePlayer<sup>11+</sup>
2023e41f4b71Sopenharmony_ci
2024e41f4b71Sopenharmony_citype SystemTonePlayer = _SystemTonePlayer;
2025e41f4b71Sopenharmony_ci
2026e41f4b71Sopenharmony_ci系统提示音播放器对象。
2027e41f4b71Sopenharmony_ci
2028e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
2029e41f4b71Sopenharmony_ci
2030e41f4b71Sopenharmony_ci| 类型              | 说明        |
2031e41f4b71Sopenharmony_ci|-----------------|-----------|
2032e41f4b71Sopenharmony_ci| _SystemTonePlayer | 系统提示音播放器。 |
2033e41f4b71Sopenharmony_ci
2034e41f4b71Sopenharmony_ci## RingtoneOptions<sup>10+</sup>
2035e41f4b71Sopenharmony_ci
2036e41f4b71Sopenharmony_citype RingtoneOptions = _RingtoneOptions;
2037e41f4b71Sopenharmony_ci
2038e41f4b71Sopenharmony_ci系统铃音播放器配置项。
2039e41f4b71Sopenharmony_ci
2040e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
2041e41f4b71Sopenharmony_ci
2042e41f4b71Sopenharmony_ci| 类型              | 说明          |
2043e41f4b71Sopenharmony_ci|-----------------|-------------|
2044e41f4b71Sopenharmony_ci| _RingtoneOptions | 系统铃音播放器配置项。 |
2045e41f4b71Sopenharmony_ci
2046e41f4b71Sopenharmony_ci## SystemToneOptions<sup>11+</sup>
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_citype SystemToneOptions = _SystemToneOptions;
2049e41f4b71Sopenharmony_ci
2050e41f4b71Sopenharmony_ci系统提示音播放器配置项。
2051e41f4b71Sopenharmony_ci
2052e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.SystemSound.Core
2053e41f4b71Sopenharmony_ci
2054e41f4b71Sopenharmony_ci| 类型              | 说明            |
2055e41f4b71Sopenharmony_ci|-----------------|---------------|
2056e41f4b71Sopenharmony_ci| _SystemToneOptions | 系统提示音音播放器配置项。 |
2057e41f4b71Sopenharmony_ci
2058e41f4b71Sopenharmony_ci
2059e41f4b71Sopenharmony_ci
2060