1e41f4b71Sopenharmony_ci# @ohos.multimedia.systemSoundManager (System Sound Management) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **systemSoundManager** module provides basic capabilities for managing system sounds, including setting and obtaining system ringtones and obtaining a player to play the system ringtones.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { systemSoundManager } from '@kit.AudioKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## Constants
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**System API**: This is a system API.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name                                     | Value  | Description     |
23e41f4b71Sopenharmony_ci|------------------------------------------|-----|---------|
24e41f4b71Sopenharmony_ci| TONE_CATEGORY_RINGTONE<sup>12+</sup>     | 1   | Ringtone.  |
25e41f4b71Sopenharmony_ci| TONE_CATEGORY_TEXT_MESSAGE<sup>12+</sup> | 2   | SMS alert tone.|
26e41f4b71Sopenharmony_ci| TONE_CATEGORY_NOTIFICATION<sup>12+</sup> | 4   | Notification alert tone.|
27e41f4b71Sopenharmony_ci| TONE_CATEGORY_ALARM<sup>12+</sup>        | 8   | Alarm alert tone.|
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## RingtoneType
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciEnumerates the ringtone types.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**System API**: This is a system API.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| Name                           | Value | Description                                                                    |
38e41f4b71Sopenharmony_ci| ------------------------------- |----|------------------------------------------------------------------------|
39e41f4b71Sopenharmony_ci| RINGTONE_TYPE_DEFAULT<sup>(deprecated)</sup>           | 0  | Default ringtone type.<br> This enumerated value is deprecated since API version 11. You are advised to use **RINGTONE_TYPE_SIM_CARD_0** instead.|
40e41f4b71Sopenharmony_ci| RINGTONE_TYPE_SIM_CARD_0<sup>11+</sup> | 0  | Ringtone of SIM card 1.                                                             |
41e41f4b71Sopenharmony_ci| RINGTONE_TYPE_MULTISIM<sup>(deprecated)</sup>          | 1  | Multi-SIM ringtone type.<br> This enumerated value is deprecated since API version 11. You are advised to use **RINGTONE_TYPE_SIM_CARD_1** instead.|
42e41f4b71Sopenharmony_ci| RINGTONE_TYPE_SIM_CARD_1<sup>11+</sup> | 1  | Ringtone of SIM card 2.                                                             |
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## SystemToneType<sup>11+</sup>
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ciEnumerates the system alert tone types.
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci**System API**: This is a system API.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci| Name                           | Value  | Description        |
53e41f4b71Sopenharmony_ci| ------------------------------- |-----|------------|
54e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_SIM_CARD_0     | 0   | SMS alert tone of SIM card 1.|
55e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_SIM_CARD_1     | 1   | SMS alert tone of SIM card 2.|
56e41f4b71Sopenharmony_ci| SYSTEM_TONE_TYPE_NOTIFICATION   | 32  | Notification alert tone.    |
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci## ToneCustomizedType<sup>12+</sup>
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ciEnumerates the tone customization types.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**System API**: This is a system API.
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci| Name                        | Value  | Description        |
68e41f4b71Sopenharmony_ci| ----------------------------|-----|------------|
69e41f4b71Sopenharmony_ci| PRE_INSTALLED<sup>12+</sup> | 0   | Preinstalled tone.|
70e41f4b71Sopenharmony_ci| CUSTOMIZED<sup>12+</sup>    | 1   | Customized tone.|
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci## ToneAttrs<sup>12+</sup>
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ciManages tone attributes. Before calling any API in **ToneAttrs<sup>12+</sup>**, you must use [createCustomizedToneAttrs](#systemsoundmanagercreatecustomizedtoneattrs12), [getDefaultRingtoneAttrs](#getdefaultringtoneattrs12), or [getRingtoneAttrList](#getringtoneattrlist12) to obtain a tone instance.
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci### getTitle<sup>12+</sup>
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_cigetTitle(): string
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ciObtains the title of this tone.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**System API**: This is a system API.
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Return value**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci| Type   | Description |
89e41f4b71Sopenharmony_ci|--------|-----|
90e41f4b71Sopenharmony_ci| string | Title.|
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**Error codes**
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci| ID  | Error Message             |
95e41f4b71Sopenharmony_ci|---------| -------------------- |
96e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**Example**
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_ciSets the title for this tone.
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**System API**: This is a system API.
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**Parameters**
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description         |
117e41f4b71Sopenharmony_ci| -------| -------| ---- | ------------|
118e41f4b71Sopenharmony_ci| title  | string | Yes  | Title.  |
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**Error codes**
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci| ID| Error Message             |
123e41f4b71Sopenharmony_ci|-------| -------------------- |
124e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
125e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Example**
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_ciObtains the file name of this tone.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**System API**: This is a system API.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**Return value**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| Type   | Description  |
148e41f4b71Sopenharmony_ci|--------|------|
149e41f4b71Sopenharmony_ci| string | File name.|
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**Error codes**
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci| ID| Error Message             |
154e41f4b71Sopenharmony_ci|---------| -------------------- |
155e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**Example**
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_ciSets the file name for this tone.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**System API**: This is a system API.
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**Parameters**
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description        |
177e41f4b71Sopenharmony_ci| ------| -------|-----| ------------|
178e41f4b71Sopenharmony_ci| name  | string | Yes  | File name.|
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**Error codes**
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci| ID| Error Message             |
183e41f4b71Sopenharmony_ci|-------| -------------------- |
184e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
185e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**Example**
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_ciObtains the URI of this tone.
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci**System API**: This is a system API.
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci**Return value**
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci| Type   | Description                                                     |
208e41f4b71Sopenharmony_ci|--------|---------------------------------------------------------|
209e41f4b71Sopenharmony_ci| string | URI, for example, **'/data/storage/el2/base/RingTone/alarms/test.ogg'**.|
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci**Error codes**
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci| ID| Error Message             |
214e41f4b71Sopenharmony_ci|---------| -------------------- |
215e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Example**
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_ciObtains the tone customization type.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**System API**: This is a system API.
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**Return value**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| Type                                        | Description     |
236e41f4b71Sopenharmony_ci|--------------------------------------------|---------|
237e41f4b71Sopenharmony_ci| [ToneCustomizedType](#tonecustomizedtype12) | Tone customization type.|
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**Error codes**
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci| ID  | Error Message             |
242e41f4b71Sopenharmony_ci|---------| -------------------- |
243e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**Example**
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_ciSets a category for this tone.
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**System API**: This is a system API.
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**Parameters**
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci| Name     | Type     | Mandatory| Description      |
264e41f4b71Sopenharmony_ci|----------| ---------| ---- |----------|
265e41f4b71Sopenharmony_ci| category | number   | Yes  | Category of the tone. For details, see [Constants](#constants). |
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci**Error codes**
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci| ID| Error Message             |
270e41f4b71Sopenharmony_ci|-------| -------------------- |
271e41f4b71Sopenharmony_ci| 202   | Caller is not a system application. |
272e41f4b71Sopenharmony_ci| 401   | The parameters check failed. |
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**Example**
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci```ts
277e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
278e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM; // Change the value to the required constant.
279e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
280e41f4b71Sopenharmony_ci```
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci### getCategory<sup>12+</sup>
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_cigetCategory(): string
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ciObtains the category of this tone.
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**System API**: This is a system API.
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Return value**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci| Type   | Description    |
295e41f4b71Sopenharmony_ci|--------|--------|
296e41f4b71Sopenharmony_ci| number | Category of the tone. For details, see [Constants](#constants).|
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci**Error codes**
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci| ID  | Error Message             |
301e41f4b71Sopenharmony_ci|---------| -------------------- |
302e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci**Example**
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_ciDefines an array of tone attributes.
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci| Type                                    | Description     |
320e41f4b71Sopenharmony_ci|----------------------------------------|---------|
321e41f4b71Sopenharmony_ci| Array&lt;[ToneAttrs](#toneattrs12)&gt; | Array of tone attributes.|
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci## systemSoundManager.createCustomizedToneAttrs<sup>12+</sup>
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_cicreateCustomizedToneAttrs(): ToneAttrs
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ciCreates customized tone attributes.
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**System API**: This is a system API.
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**Return value**
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci| Type                       | Description        |
336e41f4b71Sopenharmony_ci|---------------------------| ------------ |
337e41f4b71Sopenharmony_ci| [ToneAttrs](#toneattrs12) | Class for tone attributes.|
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Error codes**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci| ID  | Error Message             |
344e41f4b71Sopenharmony_ci|---------| -------------------- |
345e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**Example**
348e41f4b71Sopenharmony_ci```ts
349e41f4b71Sopenharmony_cilet toneAttrs: systemSoundManager.ToneAttrs = systemSoundManager.createCustomizedToneAttrs();
350e41f4b71Sopenharmony_ci```
351e41f4b71Sopenharmony_ci## ToneHapticsFeature<sup>12+</sup>
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ciEnumerates the haptics styles for system ringtones.
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**System API**: This is a system API.
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci| Name                         | Value| Description                |
360e41f4b71Sopenharmony_ci| ----------------------------- | -- | -------------------- |
361e41f4b71Sopenharmony_ci| STANDARD| 0  | Standard haptics style.|
362e41f4b71Sopenharmony_ci| GENTLE   | 1  | Gentle haptics style.|
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci## systemSoundManager.getSystemSoundManager
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_cigetSystemSoundManager(): SystemSoundManager
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ciObtains a system sound manager.
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**System API**: This is a system API.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**Return value**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci| Type                         | Description        |
377e41f4b71Sopenharmony_ci| ----------------------------- | ------------ |
378e41f4b71Sopenharmony_ci| [SystemSoundManager](#systemsoundmanager) | System sound manager obtained.|
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Example**
381e41f4b71Sopenharmony_ci```ts
382e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
383e41f4b71Sopenharmony_ci```
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci## SystemSoundManager
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ciProvides APIs to manage system sounds. Before calling any API in **SystemSoundManager**, you must use [getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager) to create a **SystemSoundManager** instance.
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci### setSystemRingtoneUri<sup>(deprecated)</sup>
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_cisetSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback&lt;void&gt;): void
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ciSets a URI for a system ringtone. This API uses an asynchronous callback to return the result.
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci> **NOTE**
396e41f4b71Sopenharmony_ci>
397e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [setRingtoneUri](#setringtoneuri11) instead.
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**System API**: This is a system API.
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**Parameters**
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci| Name  | Type                                     | Mandatory| Description                    |
406e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------ |
407e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | Application context.          |
408e41f4b71Sopenharmony_ci| uri      | string                                   | Yes  | URI of the system ringtone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
409e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.    |
410e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                | Yes  | Callback used to return the result.    |
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**Example**
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci```ts
415e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
416e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_cilet context: Context = getContext(this);
419e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
420e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
423e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemRingtoneUri(context, uri, type, (err: BusinessError) => {
424e41f4b71Sopenharmony_ci  if (err) {
425e41f4b71Sopenharmony_ci    console.error(`Failed to set system ringtone uri. ${err}`);
426e41f4b71Sopenharmony_ci    return;
427e41f4b71Sopenharmony_ci  }
428e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate a successful setting of the system ringtone uri.`);
429e41f4b71Sopenharmony_ci});
430e41f4b71Sopenharmony_ci```
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci### setSystemRingtoneUri<sup>(deprecated)</sup>
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_cisetSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise&lt;void&gt;
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ciSets a URI for a system ringtone. This API uses a promise to return the result.
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci> **NOTE**
439e41f4b71Sopenharmony_ci>
440e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [setRingtoneUri](#setringtoneuri11) instead.
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci**System API**: This is a system API.
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci**Parameters**
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci| Name  | Type                                     | Mandatory| Description                    |
449e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---- | ------------------------ |
450e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.        |
451e41f4b71Sopenharmony_ci| uri      | string                                   | Yes  | URI of the system ringtone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
452e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.  |
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**Return value**
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci| Type               | Description                           |
457e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
458e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.  |
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**Example**
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci```ts
463e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
464e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_cilet context: Context = getContext(this);
467e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
468e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
471e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemRingtoneUri(context, uri, type).then(() => {
472e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
473e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
474e41f4b71Sopenharmony_ci  console.error(`Failed to set the system ringtone uri ${err}`);
475e41f4b71Sopenharmony_ci});
476e41f4b71Sopenharmony_ci```
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci### getSystemRingtoneUri<sup>(deprecated)</sup>
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_cigetSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback&lt;string&gt;): void
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ciObtains the URI of a system ringtone. This API uses an asynchronous callback to return the result.
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci> **NOTE**
485e41f4b71Sopenharmony_ci>
486e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtoneUri](#getringtoneuri11) instead.
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**System API**: This is a system API.
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**Parameters**
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci| Name  | Type                                                                   | Mandatory| Description                    |
495e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------| ---- | ------------------------ |
496e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | Application context.        |
497e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                         | Yes  | Type of the system ringtone.   |
498e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;string&gt;                                           | Yes  | Callback used to return the URI obtained.|
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci**Example**
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci```ts
503e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
504e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_cilet context: Context = getContext(this);
507e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
510e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtoneUri(context, type, (err: BusinessError, value: string) => {
511e41f4b71Sopenharmony_ci  if (err) {
512e41f4b71Sopenharmony_ci    console.error(`Failed to get system ringtone uri. ${err}`);
513e41f4b71Sopenharmony_ci    return;
514e41f4b71Sopenharmony_ci  }
515e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate the value of the system ringtone uri is obtained ${value}.`);
516e41f4b71Sopenharmony_ci});
517e41f4b71Sopenharmony_ci```
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci### getSystemRingtoneUri<sup>(deprecated)</sup>
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_cigetSystemRingtoneUri(context: Context, type: RingtoneType): Promise&lt;string&gt;
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ciObtains the URI of a system ringtone. This API uses a promise to return the result.
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci> **NOTE**
526e41f4b71Sopenharmony_ci>
527e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtoneUri](#getringtoneuri11) instead.
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**System API**: This is a system API.
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci**Parameters**
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci| Name  | Type                                                                  | Mandatory| Description                    |
536e41f4b71Sopenharmony_ci| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
537e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.        |
538e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                        | Yes  | Type of the system ringtone.  |
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci**Return value**
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci| Type               | Description                               |
543e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
544e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI obtained.|
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci**Example**
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci```ts
549e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
550e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_cilet context: Context = getContext(this);
553e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
556e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtoneUri(context, type).then((value: string) => {
557e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
558e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
559e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone uri ${err}`);
560e41f4b71Sopenharmony_ci});
561e41f4b71Sopenharmony_ci```
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci### getSystemRingtonePlayer<sup>(deprecated)</sup>
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_cigetSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback&lt;RingtonePlayer&gt;): void
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ciObtains a player to play a system ringtone. This API uses an asynchronous callback to return the result.
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci> **NOTE**
570e41f4b71Sopenharmony_ci>
571e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtonePlayer](#getringtoneplayer11) instead.
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**System API**: This is a system API.
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci**Parameters**
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci| Name  | Type                                     | Mandatory| Description                        |
580e41f4b71Sopenharmony_ci| -------- | -----------------------------------------| ---- | --------------------------- |
581e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)  | Yes  | Application context.           |
582e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)            | Yes  | Type of the system ringtone.|
583e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Yes| Callback used to return the player obtained.|
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**Example**
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci```ts
588e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
589e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_cilet context: Context = getContext(this);
592e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
593e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
596e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtonePlayer(context, type, (err: BusinessError, value: systemSoundManager.RingtonePlayer) => {
597e41f4b71Sopenharmony_ci  if (err) {
598e41f4b71Sopenharmony_ci    console.error(`Failed to get system ringtone player. ${err}`);
599e41f4b71Sopenharmony_ci    return;
600e41f4b71Sopenharmony_ci  }
601e41f4b71Sopenharmony_ci  console.info(`Callback invoked to indicate the value of the system ringtone player is obtained.`);
602e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
603e41f4b71Sopenharmony_ci});
604e41f4b71Sopenharmony_ci```
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ci### getSystemRingtonePlayer<sup>(deprecated)</sup>
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_cigetSystemRingtonePlayer(context: Context, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ciObtains a player to play a system ringtone. This API uses a promise to return the result.
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci> **NOTE**
613e41f4b71Sopenharmony_ci>
614e41f4b71Sopenharmony_ci> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getRingtonePlayer](#getringtoneplayer11) instead.
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**System API**: This is a system API.
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**Parameters**
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci| Name  | Type                                                                 | Mandatory| Description                        |
623e41f4b71Sopenharmony_ci| -------- |---------------------------------------------------------------------| ---- | --------------------------- |
624e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.           |
625e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)                                       | Yes  | Type of the system ringtone.|
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci**Return value**
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci| Type               | Description                           |
630e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
631e41f4b71Sopenharmony_ci| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise used to return the player obtained.|
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci**Example**
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci```ts
636e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
637e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_cilet context: Context = getContext(this);
640e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
641e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
644e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
645e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
646e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
647e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
648e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone player ${err}`);
649e41f4b71Sopenharmony_ci});
650e41f4b71Sopenharmony_ci```
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci### setRingtoneUri<sup>11+</sup>
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_cisetRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise&lt;void&gt;
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ciSets a URI for a system ringtone. This API uses a promise to return the result.
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**System API**: This is a system API.
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**Parameters**
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci| Name  | Type                           | Mandatory| Description                    |
665e41f4b71Sopenharmony_ci| -------- |-------------------------------| ---- | ------------------------ |
666e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)            | Yes  | Application context.        |
667e41f4b71Sopenharmony_ci| uri      | string                        | Yes  | URI of the system ringtone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
668e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype) | Yes  | Type of the system ringtone.  |
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci**Return value**
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci| Type               | Description                           |
673e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
674e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.  |
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ci**Error codes**
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci| ID| Error Message             |
681e41f4b71Sopenharmony_ci| ------- | --------------------- |
682e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
683e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
684e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ci**Example**
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ci```ts
689e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
690e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
693e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
694e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
697e41f4b71Sopenharmony_cisystemSoundManagerInstance.setRingtoneUri(context, uri, type).then(() => {
698e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
699e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
700e41f4b71Sopenharmony_ci  console.error(`Failed to set the system ringtone uri ${err}`);
701e41f4b71Sopenharmony_ci});
702e41f4b71Sopenharmony_ci```
703e41f4b71Sopenharmony_ci
704e41f4b71Sopenharmony_ci### getRingtoneUri<sup>11+</sup>
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_cigetRingtoneUri(context: BaseContext, type: RingtoneType): Promise&lt;string&gt;
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_ciObtains the URI of a system ringtone. This API uses a promise to return the result.
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**System API**: This is a system API.
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**Parameters**
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci| Name  | Type                            | Mandatory| Description                    |
717e41f4b71Sopenharmony_ci| -------- | -------------------------------| ---- | ------------------------ |
718e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)| Yes  | Application context.        |
719e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)  | Yes  | Type of the system ringtone.  |
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci**Return value**
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci| Type               | Description                               |
724e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
725e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI obtained.|
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci**Error codes**
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci| ID| Error Message             |
732e41f4b71Sopenharmony_ci| -------- | --------------------- |
733e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
734e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
735e41f4b71Sopenharmony_ci| 5400103  | I/O error. |
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**Example**
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci```ts
740e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
741e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
744e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
747e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtoneUri(context, type).then((value: string) => {
748e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
749e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
750e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone uri ${err}`);
751e41f4b71Sopenharmony_ci});
752e41f4b71Sopenharmony_ci```
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci### getRingtonePlayer<sup>11+</sup>
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_cigetRingtonePlayer(context: BaseContext, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ciObtains a player to play a system ringtone. This API uses a promise to return the result.
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci**System API**: This is a system API.
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci**Parameters**
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci| Name  | Type                             | Mandatory| Description                        |
767e41f4b71Sopenharmony_ci| -------- | --------------------------------| ---- | --------------------------- |
768e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
769e41f4b71Sopenharmony_ci| type     | [RingtoneType](#ringtonetype)   | Yes  | Type of the system ringtone.|
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**Return value**
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci| Type               | Description                           |
774e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
775e41f4b71Sopenharmony_ci| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer-sys.md#ringtoneplayer)&gt; | Promise used to return the player obtained.|
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci**Error codes**
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci| ID| Error Message             |
782e41f4b71Sopenharmony_ci| -------- | --------------------- |
783e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
784e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci**Example**
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_ci```ts
789e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
790e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
793e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
794e41f4b71Sopenharmony_cilet systemRingtonePlayer: systemSoundManager.RingtonePlayer | undefined = undefined;
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
797e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtonePlayer(context, type).then((value: systemSoundManager.RingtonePlayer) => {
798e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
799e41f4b71Sopenharmony_ci  systemRingtonePlayer = value;
800e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
801e41f4b71Sopenharmony_ci  console.error(`Failed to get the system ringtone player ${err}`);
802e41f4b71Sopenharmony_ci});
803e41f4b71Sopenharmony_ci```
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci### setSystemToneUri<sup>11+</sup>
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_cisetSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise&lt;void&gt;
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ciSets a URI for a system alert tone. This API uses a promise to return the result.
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci**System API**: This is a system API.
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci**Parameters**
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                    |
818e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | ------------------------ |
819e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.        |
820e41f4b71Sopenharmony_ci| uri      | string                              | Yes  | URI of the system alert tone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
821e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.  |
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci**Return value**
824e41f4b71Sopenharmony_ci
825e41f4b71Sopenharmony_ci| Type               | Description                           |
826e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
827e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.  |
828e41f4b71Sopenharmony_ci
829e41f4b71Sopenharmony_ci**Error codes**
830e41f4b71Sopenharmony_ci
831e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_ci| ID| Error Message             |
834e41f4b71Sopenharmony_ci| ------- | --------------------- |
835e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
836e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
837e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
838e41f4b71Sopenharmony_ci
839e41f4b71Sopenharmony_ci**Example**
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci```ts
842e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
843e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
846e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
847e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
848e41f4b71Sopenharmony_ci
849e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
850e41f4b71Sopenharmony_cisystemSoundManagerInstance.setSystemToneUri(context, uri, type).then(() => {
851e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the system tone uri.`);
852e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
853e41f4b71Sopenharmony_ci  console.error(`Failed to set the system tone uri ${err}`);
854e41f4b71Sopenharmony_ci});
855e41f4b71Sopenharmony_ci```
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci### getSystemToneUri<sup>11+</sup>
858e41f4b71Sopenharmony_ci
859e41f4b71Sopenharmony_cigetSystemToneUri(context: BaseContext, type: SystemToneType): Promise&lt;string&gt;
860e41f4b71Sopenharmony_ci
861e41f4b71Sopenharmony_ciObtains the URI of a system alert tone. This API uses a promise to return the result.
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci**System API**: This is a system API.
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci**Parameters**
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                    |
870e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | ------------------------ |
871e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.        |
872e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.  |
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci**Return value**
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci| Type               | Description                               |
877e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------- |
878e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI obtained.|
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**Error codes**
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci| ID| Error Message             |
885e41f4b71Sopenharmony_ci| ------- | --------------------- |
886e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
887e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
888e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci**Example**
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci```ts
893e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
894e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
897e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
898e41f4b71Sopenharmony_ci
899e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
900e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemToneUri(context, type).then((value: string) => {
901e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone uri is obtained ${value}.`);
902e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
903e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone uri ${err}`);
904e41f4b71Sopenharmony_ci});
905e41f4b71Sopenharmony_ci```
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci### getSystemTonePlayer<sup>11+</sup>
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_cigetSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise&lt;SystemTonePlayer&gt;
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ciObtains a player to play a system alert tone. This API uses a promise to return the result.
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci**System API**: This is a system API.
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ci**Parameters**
918e41f4b71Sopenharmony_ci
919e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                        |
920e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
921e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
922e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11) | Yes  | Type of the system alert tone.|
923e41f4b71Sopenharmony_ci
924e41f4b71Sopenharmony_ci**Return value**
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_ci| Type                                                                                              | Description                           |
927e41f4b71Sopenharmony_ci|--------------------------------------------------------------------------------------------------| ------------------------------- |
928e41f4b71Sopenharmony_ci| Promise&lt;[SystemTonePlayer](js-apis-inner-multimedia-systemTonePlayer-sys.md#systemtoneplayer)&gt; | Promise used to return the player obtained.|
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ci**Error codes**
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci| ID| Error Message             |
935e41f4b71Sopenharmony_ci| ------- | --------------------- |
936e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
937e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci**Example**
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci```ts
942e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
943e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
944e41f4b71Sopenharmony_ci
945e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
946e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
947e41f4b71Sopenharmony_cilet systemTonePlayer: systemSoundManager.SystemTonePlayer | undefined = undefined;
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
950e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemTonePlayer(context, type).then((value: systemSoundManager.SystemTonePlayer) => {
951e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the system tone player is obtained.`);
952e41f4b71Sopenharmony_ci    systemTonePlayer = value;
953e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
954e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone player ${err}`);
955e41f4b71Sopenharmony_ci});
956e41f4b71Sopenharmony_ci```
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_ci### getDefaultRingtoneAttrs<sup>12+</sup>
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_cigetDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrs&gt;
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ciObtains the attributes of the default system ringtone. This API uses a promise to return the result.
963e41f4b71Sopenharmony_ci
964e41f4b71Sopenharmony_ci**System API**: This is a system API.
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci**Parameters**
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                        |
971e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
972e41f4b71Sopenharmony_ci| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
973e41f4b71Sopenharmony_ci| type     |[RingtoneType](#ringtonetype)        | Yes  | Type of the system ringtone. |
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ci**Return value**
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ci| Type                                      | Description                 |
978e41f4b71Sopenharmony_ci|------------------------------------------|---------------------|
979e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; |  Promise used to return the attributes of the default system ringtone.|
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci**Error codes**
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci| ID| Error Message             |
986e41f4b71Sopenharmony_ci| ------- | --------------------- |
987e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
988e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
989e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci**Example**
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci```ts
994e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
995e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
998e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
999e41f4b71Sopenharmony_ci
1000e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1001e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultRingtoneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1002e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the default ringtone is obtained.`);
1003e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1004e41f4b71Sopenharmony_ci  console.error(`Failed to get the default ring tone attrs ${err}`);
1005e41f4b71Sopenharmony_ci});
1006e41f4b71Sopenharmony_ci```
1007e41f4b71Sopenharmony_ci
1008e41f4b71Sopenharmony_ci### getRingtoneAttrList<sup>12+</sup>
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_cigetRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise&lt;ToneAttrsArray&gt;
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ciObtains the list of attributes of the default system ringtone. This API uses a promise to return the result.
1013e41f4b71Sopenharmony_ci
1014e41f4b71Sopenharmony_ci**System API**: This is a system API.
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci**Parameters**
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                        |
1021e41f4b71Sopenharmony_ci| -------- |-------------------------------------| ---- | --------------------------- |
1022e41f4b71Sopenharmony_ci| context  |[BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1023e41f4b71Sopenharmony_ci| type     |[RingtoneType](#ringtonetype)        | Yes  | Type of the system ringtone. |
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci**Return value**
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci| Type                                                | Description                   |
1028e41f4b71Sopenharmony_ci|----------------------------------------------------|-----------------------|
1029e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; |  Promise used to return an array of the attributes of the default system ringtone.|
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_ci**Error codes**
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ci| ID| Error Message             |
1036e41f4b71Sopenharmony_ci| ------- | --------------------- |
1037e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1038e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1039e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**Example**
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci```ts
1044e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1045e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1048e41f4b71Sopenharmony_cilet type: systemSoundManager.RingtoneType = systemSoundManager.RingtoneType.RINGTONE_TYPE_SIM_CARD_0;
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1051e41f4b71Sopenharmony_cisystemSoundManagerInstance.getRingtoneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1052e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of ringtone is obtained.`);
1053e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1054e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of ringtone ${err}`);
1055e41f4b71Sopenharmony_ci});
1056e41f4b71Sopenharmony_ci```
1057e41f4b71Sopenharmony_ci
1058e41f4b71Sopenharmony_ci### getDefaultSystemToneAttrs<sup>12+</sup>
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_cigetDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrs&gt;
1061e41f4b71Sopenharmony_ci
1062e41f4b71Sopenharmony_ciObtains the attributes of the default system alert tone. This API uses a promise to return the result.
1063e41f4b71Sopenharmony_ci
1064e41f4b71Sopenharmony_ci**System API**: This is a system API.
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_ci**Parameters**
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ci| Name  | Type                                                                         | Mandatory| Description                        |
1071e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1072e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1073e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11)                                         | Yes  | Type of the system alert tone.|
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_ci**Return value**
1076e41f4b71Sopenharmony_ci
1077e41f4b71Sopenharmony_ci| Type                                     | Description                  |
1078e41f4b71Sopenharmony_ci|-----------------------------------------|----------------------|
1079e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; |  Promise used to return the attributes of the default system alert tone.|
1080e41f4b71Sopenharmony_ci
1081e41f4b71Sopenharmony_ci**Error codes**
1082e41f4b71Sopenharmony_ci
1083e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1084e41f4b71Sopenharmony_ci
1085e41f4b71Sopenharmony_ci| ID| Error Message             |
1086e41f4b71Sopenharmony_ci| ------- | --------------------- |
1087e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1088e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1089e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1090e41f4b71Sopenharmony_ci
1091e41f4b71Sopenharmony_ci**Example**
1092e41f4b71Sopenharmony_ci
1093e41f4b71Sopenharmony_ci```ts
1094e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1095e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1096e41f4b71Sopenharmony_ci
1097e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1098e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1101e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultSystemToneAttrs(context, type).then((value: systemSoundManager.ToneAttrs) => {
1102e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the system ringtone is obtained.`);
1103e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1104e41f4b71Sopenharmony_ci  console.error(`Failed to get the system tone attrs ${err}`);
1105e41f4b71Sopenharmony_ci});
1106e41f4b71Sopenharmony_ci```
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci### getSystemToneAttrList<sup>12+</sup>
1109e41f4b71Sopenharmony_ci
1110e41f4b71Sopenharmony_cigetSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise&lt;ToneAttrsArray&gt;
1111e41f4b71Sopenharmony_ci
1112e41f4b71Sopenharmony_ciObtains the list of attributes of the default system alert tone. This API uses a promise to return the result.
1113e41f4b71Sopenharmony_ci
1114e41f4b71Sopenharmony_ci**System API**: This is a system API.
1115e41f4b71Sopenharmony_ci
1116e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1117e41f4b71Sopenharmony_ci
1118e41f4b71Sopenharmony_ci**Parameters**
1119e41f4b71Sopenharmony_ci
1120e41f4b71Sopenharmony_ci| Name  | Type                                                                         | Mandatory| Description                        |
1121e41f4b71Sopenharmony_ci| -------- |-----------------------------------------------------------------------------| ---- | --------------------------- |
1122e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.           |
1123e41f4b71Sopenharmony_ci| type     | [SystemToneType](#systemtonetype11)                                         | Yes  | Type of the system alert tone. |
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ci**Return value**
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_ci| Type                                               | Description                    |
1128e41f4b71Sopenharmony_ci|---------------------------------------------------|------------------------|
1129e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; |  Promise used to return an array of the attributes of the default system alert tone.|
1130e41f4b71Sopenharmony_ci
1131e41f4b71Sopenharmony_ci**Error codes**
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci| ID| Error Message             |
1136e41f4b71Sopenharmony_ci| ------- | --------------------- |
1137e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1138e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1139e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci**Example**
1142e41f4b71Sopenharmony_ci
1143e41f4b71Sopenharmony_ci```ts
1144e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1145e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1148e41f4b71Sopenharmony_cilet type: systemSoundManager.SystemToneType = systemSoundManager.SystemToneType.SYSTEM_TONE_TYPE_SIM_CARD_0;
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1151e41f4b71Sopenharmony_cisystemSoundManagerInstance.getSystemToneAttrList(context, type).then((value: systemSoundManager.ToneAttrsArray) => {
1152e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of system tone is obtained.`);
1153e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1154e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of system tone ${err}`);
1155e41f4b71Sopenharmony_ci});
1156e41f4b71Sopenharmony_ci```
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci### getDefaultAlarmToneAttrs<sup>12+</sup>
1159e41f4b71Sopenharmony_ci
1160e41f4b71Sopenharmony_cigetDefaultAlarmToneAttrs(context: BaseContext): Promise&lt;ToneAttrs&gt;
1161e41f4b71Sopenharmony_ci
1162e41f4b71Sopenharmony_ciObtains the attributes of the default alarm alert tone. This API uses a promise to return the result.
1163e41f4b71Sopenharmony_ci
1164e41f4b71Sopenharmony_ci**System API**: This is a system API.
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ci**Parameters**
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ci| Name  | Type        | Mandatory| Description       |
1171e41f4b71Sopenharmony_ci| --------|------------| ---- |-----------|
1172e41f4b71Sopenharmony_ci| context | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md) | Yes  | Application context.|
1173e41f4b71Sopenharmony_ci
1174e41f4b71Sopenharmony_ci**Return value**
1175e41f4b71Sopenharmony_ci
1176e41f4b71Sopenharmony_ci| Type                                     | Description                 |
1177e41f4b71Sopenharmony_ci|-----------------------------------------|---------------------|
1178e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrs](#toneattrs12)&gt; |  Promise used to return the attributes of the default alarm alert tone.|
1179e41f4b71Sopenharmony_ci
1180e41f4b71Sopenharmony_ci**Error codes**
1181e41f4b71Sopenharmony_ci
1182e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1183e41f4b71Sopenharmony_ci
1184e41f4b71Sopenharmony_ci| ID| Error Message             |
1185e41f4b71Sopenharmony_ci| ------- | --------------------- |
1186e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1187e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1188e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1189e41f4b71Sopenharmony_ci
1190e41f4b71Sopenharmony_ci**Example**
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_ci```ts
1193e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1194e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1199e41f4b71Sopenharmony_cisystemSoundManagerInstance.getDefaultAlarmToneAttrs(context).then((value: systemSoundManager.ToneAttrs) => {
1200e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attributes of the default alarm tone is obtained.`);
1201e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1202e41f4b71Sopenharmony_ci  console.error(`Failed to get the default alarm tone attrs ${err}`);
1203e41f4b71Sopenharmony_ci});
1204e41f4b71Sopenharmony_ci```
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci### setAlarmToneUri<sup>12+</sup>
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_cisetAlarmToneUri(context: Context, uri: string): Promise&lt;void&gt;
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ciSets a URI for an alarm alert tone. This API uses a promise to return the result.
1211e41f4b71Sopenharmony_ci
1212e41f4b71Sopenharmony_ci**System API**: This is a system API.
1213e41f4b71Sopenharmony_ci
1214e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci**Parameters**
1217e41f4b71Sopenharmony_ci
1218e41f4b71Sopenharmony_ci| Name  | Type       | Mandatory| Description  |
1219e41f4b71Sopenharmony_ci| -------- | --------- | ---- |--------------------------|
1220e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                          |
1221e41f4b71Sopenharmony_ci| uri      | string    | Yes  | URI of the alarm alert tone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
1222e41f4b71Sopenharmony_ci
1223e41f4b71Sopenharmony_ci**Return value**
1224e41f4b71Sopenharmony_ci
1225e41f4b71Sopenharmony_ci| Type               | Description                  |
1226e41f4b71Sopenharmony_ci| ------------------- |----------------------|
1227e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result. |
1228e41f4b71Sopenharmony_ci
1229e41f4b71Sopenharmony_ci**Example**
1230e41f4b71Sopenharmony_ci
1231e41f4b71Sopenharmony_ci```ts
1232e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1233e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1234e41f4b71Sopenharmony_ci
1235e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1236e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1239e41f4b71Sopenharmony_cisystemSoundManagerInstance.setAlarmToneUri(context, uri).then(() => {
1240e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate a successful setting of the alarm tone uri.`);
1241e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1242e41f4b71Sopenharmony_ci  console.error(`Failed to set the alarm tone uri ${err}`);
1243e41f4b71Sopenharmony_ci});
1244e41f4b71Sopenharmony_ci```
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_ci### getAlarmToneUri<sup>12+</sup>
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_cigetAlarmToneUri(context: Context): Promise&lt;string&gt;
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ciObtains the URI of an alarm alert tone. This API uses a promise to return the result.
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci**System API**: This is a system API.
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci**Parameters**
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci| Name  | Type     | Mandatory| Description             |
1259e41f4b71Sopenharmony_ci| -------- | --------| ---- |-----------------|
1260e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context. |
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci**Return value**
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_ci| Type                   | Description                   |
1265e41f4b71Sopenharmony_ci|-----------------------|-----------------------|
1266e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI of the alarm alert tone.|
1267e41f4b71Sopenharmony_ci
1268e41f4b71Sopenharmony_ci**Example**
1269e41f4b71Sopenharmony_ci
1270e41f4b71Sopenharmony_ci```ts
1271e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1272e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1275e41f4b71Sopenharmony_ci
1276e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1277e41f4b71Sopenharmony_cisystemSoundManagerInstance.getAlarmToneUri(context).then((value: string) => {
1278e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of alarm tone uri.`);
1279e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1280e41f4b71Sopenharmony_ci  console.error(`Failed to get the alarm tone uri ${err}`);
1281e41f4b71Sopenharmony_ci});
1282e41f4b71Sopenharmony_ci```
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci### getAlarmToneAttrList<sup>12+</sup>
1285e41f4b71Sopenharmony_ci
1286e41f4b71Sopenharmony_cigetAlarmToneAttrList(context: BaseContext): Promise&lt;ToneAttrsArray&gt;
1287e41f4b71Sopenharmony_ci
1288e41f4b71Sopenharmony_ciObtains the list of attributes of alarm alert tones. This API uses a promise to return the result.
1289e41f4b71Sopenharmony_ci
1290e41f4b71Sopenharmony_ci**System API**: This is a system API.
1291e41f4b71Sopenharmony_ci
1292e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1293e41f4b71Sopenharmony_ci
1294e41f4b71Sopenharmony_ci**Parameters**
1295e41f4b71Sopenharmony_ci
1296e41f4b71Sopenharmony_ci| Name  | Type           | Mandatory| Description                        |
1297e41f4b71Sopenharmony_ci| -------- |--------------| ---- | --------------------------- |
1298e41f4b71Sopenharmony_ci| context  | [BaseContext](../apis-ability-kit/js-apis-inner-application-baseContext.md)  | Yes  | Application context.           |
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci**Return value**
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci| Type                                                | Description                  |
1303e41f4b71Sopenharmony_ci|----------------------------------------------------|----------------------|
1304e41f4b71Sopenharmony_ci| Promise&lt;[ToneAttrsArray](#toneattrsarray12)&gt; | Promise used to return an array of the attributes of the alarm alert tones.|
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ci**Error codes**
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci| ID| Error Message             |
1311e41f4b71Sopenharmony_ci| ------- | --------------------- |
1312e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1313e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1314e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci**Example**
1317e41f4b71Sopenharmony_ci
1318e41f4b71Sopenharmony_ci```ts
1319e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1320e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_cilet context: common.BaseContext = getContext(this);
1323e41f4b71Sopenharmony_ci
1324e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1325e41f4b71Sopenharmony_cisystemSoundManagerInstance.getAlarmToneAttrList(context).then((value: systemSoundManager.ToneAttrsArray) => {
1326e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the attribute list of alarm tone is obtained.`);
1327e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1328e41f4b71Sopenharmony_ci  console.error(`Failed to get the attribute list of alarm tone ${err}`);
1329e41f4b71Sopenharmony_ci});
1330e41f4b71Sopenharmony_ci```
1331e41f4b71Sopenharmony_ci
1332e41f4b71Sopenharmony_ci### openAlarmTone<sup>12+</sup>
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_ciopenAlarmTone(context: Context, uri: string): Promise&lt;number&gt;
1335e41f4b71Sopenharmony_ci
1336e41f4b71Sopenharmony_ciEnables an alarm alert tone. This API uses a promise to return the result.
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ci**System API**: This is a system API.
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci**Parameters**
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ci| Name  | Type      | Mandatory| Description                                                                                 |
1345e41f4b71Sopenharmony_ci| -------- | ---------| ---- |-------------------------------------------------------------------------------------|
1346e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                          |
1347e41f4b71Sopenharmony_ci| uri      | string   | Yes  | URI of the alarm alert tone. For details, see [media.AVPlayer](../apis-media-kit/js-apis-media.md#avplayer9).|
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci**Return value**
1350e41f4b71Sopenharmony_ci
1351e41f4b71Sopenharmony_ci| Type                   | Description            |
1352e41f4b71Sopenharmony_ci|-----------------------|----------------|
1353e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the FD.|
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci**Error codes**
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci| ID| Error Message             |
1360e41f4b71Sopenharmony_ci| ------- | --------------------- |
1361e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1362e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1363e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1364e41f4b71Sopenharmony_ci| 20700001 | Tone type mismatch, e.g. tone of uri is notification instead of alarm. |
1365e41f4b71Sopenharmony_ci
1366e41f4b71Sopenharmony_ci**Example**
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ci```ts
1369e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1370e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1371e41f4b71Sopenharmony_ci
1372e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1373e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1374e41f4b71Sopenharmony_ci
1375e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1376e41f4b71Sopenharmony_cisystemSoundManagerInstance.openAlarmTone(context, uri).then((value: number) => {
1377e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate the value of fd.`);
1378e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1379e41f4b71Sopenharmony_ci  console.error(`Failed to open alarm tone ${err}`);
1380e41f4b71Sopenharmony_ci});
1381e41f4b71Sopenharmony_ci```
1382e41f4b71Sopenharmony_ci
1383e41f4b71Sopenharmony_ci### close<sup>12+</sup>
1384e41f4b71Sopenharmony_ci
1385e41f4b71Sopenharmony_ciclose(fd: number): Promise&lt;void&gt;
1386e41f4b71Sopenharmony_ci
1387e41f4b71Sopenharmony_ciDisables an alarm alert tone. This API uses a promise to return the result.
1388e41f4b71Sopenharmony_ci
1389e41f4b71Sopenharmony_ci**System API**: This is a system API.
1390e41f4b71Sopenharmony_ci
1391e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1392e41f4b71Sopenharmony_ci
1393e41f4b71Sopenharmony_ci**Parameters**
1394e41f4b71Sopenharmony_ci
1395e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                          |
1396e41f4b71Sopenharmony_ci|-----| --------| ---- |----------------------------------------------|
1397e41f4b71Sopenharmony_ci| fd  | number  | Yes  | File descriptor, which is obtained through [openAlarmTone](#openalarmtone12).|
1398e41f4b71Sopenharmony_ci
1399e41f4b71Sopenharmony_ci**Return value**
1400e41f4b71Sopenharmony_ci
1401e41f4b71Sopenharmony_ci| Type                 | Description            |
1402e41f4b71Sopenharmony_ci|---------------------|----------------|
1403e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.|
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_ci**Error codes**
1406e41f4b71Sopenharmony_ci
1407e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1408e41f4b71Sopenharmony_ci
1409e41f4b71Sopenharmony_ci| ID| Error Message             |
1410e41f4b71Sopenharmony_ci| ------- | --------------------- |
1411e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
1412e41f4b71Sopenharmony_ci| 401 | The parameters check failed. |
1413e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci**Example**
1416e41f4b71Sopenharmony_ci
1417e41f4b71Sopenharmony_ci```ts
1418e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1419e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1422e41f4b71Sopenharmony_cilet fd = 50; // Use the FD of the target alarm alert tone.
1423e41f4b71Sopenharmony_ci
1424e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1425e41f4b71Sopenharmony_cisystemSoundManagerInstance.close(fd).then(() => {
1426e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the fd has been close.`);
1427e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1428e41f4b71Sopenharmony_ci  console.error(`Failed to close fd ${err}`);
1429e41f4b71Sopenharmony_ci});
1430e41f4b71Sopenharmony_ci```
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci### addCustomizedTone<sup>12+</sup>
1433e41f4b71Sopenharmony_ci
1434e41f4b71Sopenharmony_ciaddCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise&lt;string&gt;
1435e41f4b71Sopenharmony_ci
1436e41f4b71Sopenharmony_ciAdds a customized tone with a given URI to the tone library. This API uses a promise to return the result.
1437e41f4b71Sopenharmony_ci
1438e41f4b71Sopenharmony_ci**System API**: This is a system API.
1439e41f4b71Sopenharmony_ci
1440e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1441e41f4b71Sopenharmony_ci
1442e41f4b71Sopenharmony_ci**Parameters**
1443e41f4b71Sopenharmony_ci
1444e41f4b71Sopenharmony_ci| Name| Type       | Mandatory| Description           |
1445e41f4b71Sopenharmony_ci|-----|-----------| ---- |---------------|
1446e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.    |
1447e41f4b71Sopenharmony_ci| toneAttr  | ToneAttrs | Yes  | Attributes of the tone.        |
1448e41f4b71Sopenharmony_ci| externalUri  | string    | Yes  | URI of the tone in the external storage device.|
1449e41f4b71Sopenharmony_ci
1450e41f4b71Sopenharmony_ci**Return value**
1451e41f4b71Sopenharmony_ci
1452e41f4b71Sopenharmony_ci| Type                   | Description                     |
1453e41f4b71Sopenharmony_ci|-----------------------|-------------------------|
1454e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI of the tone in the tone library.|
1455e41f4b71Sopenharmony_ci
1456e41f4b71Sopenharmony_ci**Error codes**
1457e41f4b71Sopenharmony_ci
1458e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1459e41f4b71Sopenharmony_ci
1460e41f4b71Sopenharmony_ci| ID  | Error Message             |
1461e41f4b71Sopenharmony_ci|---------| -------------------- |
1462e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1463e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1464e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1465e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1466e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_ci**Example**
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ci```ts
1471e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1472e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1475e41f4b71Sopenharmony_cilet title = 'test'; // Set the title of the target tone.
1476e41f4b71Sopenharmony_cilet fileName = 'displayName_test'; // Set the file name of the target tone.
1477e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1478e41f4b71Sopenharmony_ci
1479e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1480e41f4b71Sopenharmony_citoneAttrs.setTitle(title);
1481e41f4b71Sopenharmony_citoneAttrs.setFileName(fileName);
1482e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
1483e41f4b71Sopenharmony_ci
1484e41f4b71Sopenharmony_cilet path = 'file://data/test.ogg'; // Set the URI of the target tone.
1485e41f4b71Sopenharmony_ci
1486e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1487e41f4b71Sopenharmony_cisystemSoundManagerInstance.addCustomizedTone(context, toneAttrs, path).then((value: string) => {
1488e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1489e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1490e41f4b71Sopenharmony_ci  console.error(`Failed to add customized tone ${err}`);
1491e41f4b71Sopenharmony_ci});
1492e41f4b71Sopenharmony_ci```
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ci### addCustomizedTone<sup>12+</sup>
1495e41f4b71Sopenharmony_ci
1496e41f4b71Sopenharmony_ciaddCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number): Promise&lt;string&gt;
1497e41f4b71Sopenharmony_ci
1498e41f4b71Sopenharmony_ciAdds a customized tone with a given FD to the tone library. This API uses a promise to return the result.
1499e41f4b71Sopenharmony_ci
1500e41f4b71Sopenharmony_ci**System API**: This is a system API.
1501e41f4b71Sopenharmony_ci
1502e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1503e41f4b71Sopenharmony_ci
1504e41f4b71Sopenharmony_ci**Parameters**
1505e41f4b71Sopenharmony_ci
1506e41f4b71Sopenharmony_ci| Name| Type       | Mandatory| Description                                                                    |
1507e41f4b71Sopenharmony_ci|-----|-----------|----|------------------------------------------------------------------------|
1508e41f4b71Sopenharmony_ci| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Application context.                                                             |
1509e41f4b71Sopenharmony_ci| toneAttr | [ToneAttrs](#toneattrs12) | Yes | Attributes of the tone.                                                                 |
1510e41f4b71Sopenharmony_ci| fd  | number    | Yes | File descriptor, which is obtained by calling [fs.open](../apis-core-file-kit/js-apis-file-fs.md#fsopen).|
1511e41f4b71Sopenharmony_ci| offset | number    | No | Offset from which the data is read, in bytes. The default value is **0**.                                             |
1512e41f4b71Sopenharmony_ci| length | number    | No | Length of the data to read, in bytes. By default, the length is the total number of remaining bytes after the offset.                                |
1513e41f4b71Sopenharmony_ci
1514e41f4b71Sopenharmony_ci**Return value**
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci| Type                   | Description                     |
1517e41f4b71Sopenharmony_ci|-----------------------|-------------------------|
1518e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the URI of the tone in the tone library.|
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci**Error codes**
1521e41f4b71Sopenharmony_ci
1522e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ci| ID  | Error Message             |
1525e41f4b71Sopenharmony_ci|---------| -------------------- |
1526e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1527e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1528e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1529e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1530e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1531e41f4b71Sopenharmony_ci
1532e41f4b71Sopenharmony_ci**Example**
1533e41f4b71Sopenharmony_ci
1534e41f4b71Sopenharmony_ci```ts
1535e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1536e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1539e41f4b71Sopenharmony_cilet title = 'test'; // Set the title of the target tone.
1540e41f4b71Sopenharmony_cilet fileName = 'displayName_test'; // Set the file name of the target tone.
1541e41f4b71Sopenharmony_cilet categoryValue = systemSoundManager.TONE_CATEGORY_ALARM;
1542e41f4b71Sopenharmony_ci
1543e41f4b71Sopenharmony_cilet toneAttrs = systemSoundManager.createCustomizedToneAttrs();
1544e41f4b71Sopenharmony_citoneAttrs.setTitle(title);
1545e41f4b71Sopenharmony_citoneAttrs.setFileName(fileName);
1546e41f4b71Sopenharmony_citoneAttrs.setCategory(categoryValue);
1547e41f4b71Sopenharmony_ci
1548e41f4b71Sopenharmony_cilet fd = 10; // Set the FD of the target tone.
1549e41f4b71Sopenharmony_cilet offset = 0; // Set the offset.
1550e41f4b71Sopenharmony_cilet length = 50; // Set the data length.
1551e41f4b71Sopenharmony_ci
1552e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1553e41f4b71Sopenharmony_cisystemSoundManagerInstance.addCustomizedTone(context, toneAttrs, fd, offset, length).then((value: string) => {
1554e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of tone uri in ringtone library.`);
1555e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1556e41f4b71Sopenharmony_ci  console.error(`Failed to add customized tone ${err}`);
1557e41f4b71Sopenharmony_ci});
1558e41f4b71Sopenharmony_ci```
1559e41f4b71Sopenharmony_ci
1560e41f4b71Sopenharmony_ci### removeCustomizedTone<sup>12+</sup>
1561e41f4b71Sopenharmony_ci
1562e41f4b71Sopenharmony_ciremoveCustomizedTone(context: BaseContext, uri: string): Promise&lt;void&gt;
1563e41f4b71Sopenharmony_ci
1564e41f4b71Sopenharmony_ciRemoves a custom tone from the one library. This API uses a promise to return the result.
1565e41f4b71Sopenharmony_ci
1566e41f4b71Sopenharmony_ci**System API**: This is a system API.
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_ci**Parameters**
1571e41f4b71Sopenharmony_ci
1572e41f4b71Sopenharmony_ci| Name| Type       | Mandatory| Description                                                                                                     |
1573e41f4b71Sopenharmony_ci|-----|-----------| ---- |---------------------------------------------------------------------------------------------------------|
1574e41f4b71Sopenharmony_ci| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Application context.                                                                                              |
1575e41f4b71Sopenharmony_ci| uri  | string    | Yes  | Tone URI, which is obtained by using [addCustomizedTone](#addcustomizedtone12) or [getAlarmToneAttrList](#getalarmtoneattrlist12).|
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_ci**Return value**
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci| Type                 | Description                   |
1580e41f4b71Sopenharmony_ci|---------------------|-----------------------|
1581e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.|
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci**Error codes**
1584e41f4b71Sopenharmony_ci
1585e41f4b71Sopenharmony_ciFor details about the error codes, see [Media Error Codes](../apis-media-kit/errorcode-media.md).
1586e41f4b71Sopenharmony_ci
1587e41f4b71Sopenharmony_ci| ID  | Error Message             |
1588e41f4b71Sopenharmony_ci|---------| -------------------- |
1589e41f4b71Sopenharmony_ci| 201     | Permission denied. |
1590e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
1591e41f4b71Sopenharmony_ci| 401     | The parameters check failed. |
1592e41f4b71Sopenharmony_ci| 5400102     | Operation is not allowed, e.g. ringtone to add is not customized. |
1593e41f4b71Sopenharmony_ci| 5400103 | I/O error. |
1594e41f4b71Sopenharmony_ci
1595e41f4b71Sopenharmony_ci**Example**
1596e41f4b71Sopenharmony_ci
1597e41f4b71Sopenharmony_ci```ts
1598e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1599e41f4b71Sopenharmony_ciimport { common } from '@kit.AbilityKit';
1600e41f4b71Sopenharmony_ci
1601e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1602e41f4b71Sopenharmony_cilet uri = 'file://data/test.wav'; // Set the URI of the target tone file.
1603e41f4b71Sopenharmony_ci
1604e41f4b71Sopenharmony_cilet systemSoundManagerInstance: systemSoundManager.SystemSoundManager = systemSoundManager.getSystemSoundManager();
1605e41f4b71Sopenharmony_cisystemSoundManagerInstance.removeCustomizedTone(context, uri).then(() => {
1606e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the customized tone has been deleted.`);
1607e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
1608e41f4b71Sopenharmony_ci  console.error(`Failed to delete customized tone ${err}`);
1609e41f4b71Sopenharmony_ci});
1610e41f4b71Sopenharmony_ci```
1611e41f4b71Sopenharmony_ci
1612e41f4b71Sopenharmony_ci## RingtonePlayer<sup>10+</sup>
1613e41f4b71Sopenharmony_ci
1614e41f4b71Sopenharmony_citype RingtonePlayer = _RingtonePlayer;
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_ciDefines a system ringtone player.
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ci| Type             |Description    |
1621e41f4b71Sopenharmony_ci|-----------------|-------|
1622e41f4b71Sopenharmony_ci| _RingtonePlayer | System ringtone player.|
1623e41f4b71Sopenharmony_ci
1624e41f4b71Sopenharmony_ci## SystemTonePlayer<sup>11+</sup>
1625e41f4b71Sopenharmony_ci
1626e41f4b71Sopenharmony_citype SystemTonePlayer = _SystemTonePlayer;
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ciDefines a system alert tone player.
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1631e41f4b71Sopenharmony_ci
1632e41f4b71Sopenharmony_ci| Type             | Description       |
1633e41f4b71Sopenharmony_ci|-----------------|-----------|
1634e41f4b71Sopenharmony_ci| _SystemTonePlayer | System alert tone player.|
1635e41f4b71Sopenharmony_ci
1636e41f4b71Sopenharmony_ci## RingtoneOptions<sup>10+</sup>
1637e41f4b71Sopenharmony_ci
1638e41f4b71Sopenharmony_citype RingtoneOptions = _RingtoneOptions;
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ciDefines the configuration of a system ringtone player.
1641e41f4b71Sopenharmony_ci
1642e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1643e41f4b71Sopenharmony_ci
1644e41f4b71Sopenharmony_ci| Type             | Description         |
1645e41f4b71Sopenharmony_ci|-----------------|-------------|
1646e41f4b71Sopenharmony_ci| _RingtoneOptions | Configuration of a system ringtone player.|
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci## SystemToneOptions<sup>11+</sup>
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_citype SystemToneOptions = _SystemToneOptions;
1651e41f4b71Sopenharmony_ci
1652e41f4b71Sopenharmony_ciDefines the configuration of a system alert tone player.
1653e41f4b71Sopenharmony_ci
1654e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.SystemSound.Core
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci| Type             | Description           |
1657e41f4b71Sopenharmony_ci|-----------------|---------------|
1658e41f4b71Sopenharmony_ci| _SystemToneOptions | Configuration of a system alert tone player.|
1659