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