161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit AudioKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type systemSoundManager from '../@ohos.multimedia.systemSoundManager'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * System tone player object. 2561847f8eSopenharmony_ci * @typedef SystemTonePlayer 2661847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 2761847f8eSopenharmony_ci * @systemapi 2861847f8eSopenharmony_ci * @since 11 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_ciexport interface SystemTonePlayer { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * Gets the title of system tone. 3361847f8eSopenharmony_ci * @returns { Promise<string> } Promise used to return the title. 3461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 3561847f8eSopenharmony_ci * @throws { BusinessError } 5400103 - I/O error. 3661847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 3761847f8eSopenharmony_ci * @systemapi 3861847f8eSopenharmony_ci * @since 11 3961847f8eSopenharmony_ci */ 4061847f8eSopenharmony_ci getTitle(): Promise<string>; 4161847f8eSopenharmony_ci 4261847f8eSopenharmony_ci /** 4361847f8eSopenharmony_ci * Sets the volume scale of audio. 4461847f8eSopenharmony_ci * @param { number } scale - Audio volume scale, should be float in [0,1] 4561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 4661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 4761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 4861847f8eSopenharmony_ci * 2.Incorrect parameter types. 4961847f8eSopenharmony_ci * @throws { BusinessError } 5400102 - Operation not allowed. 5061847f8eSopenharmony_ci * @throws { BusinessError } 20700002 - Parameter check error. For example, value is outside [0,1]. 5161847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 5261847f8eSopenharmony_ci * @systemapi 5361847f8eSopenharmony_ci * @since 13 5461847f8eSopenharmony_ci */ 5561847f8eSopenharmony_ci setAudioVolumeScale(scale: number): void; 5661847f8eSopenharmony_ci 5761847f8eSopenharmony_ci /** 5861847f8eSopenharmony_ci * Gets the volume scale of audio. 5961847f8eSopenharmony_ci * @returns { number } Audio volume scale. 6061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 6161847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 6261847f8eSopenharmony_ci * @systemapi 6361847f8eSopenharmony_ci * @since 13 6461847f8eSopenharmony_ci */ 6561847f8eSopenharmony_ci getAudioVolumeScale(): number; 6661847f8eSopenharmony_ci 6761847f8eSopenharmony_ci /** 6861847f8eSopenharmony_ci * Get supported haptics features currently. 6961847f8eSopenharmony_ci * @returns { Promise<Array<systemSoundManager.ToneHapticsFeature>> } Promise used to return result of this call. 7061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 7161847f8eSopenharmony_ci * @throws { BusinessError } 20700003 - Unsupported operation. 7261847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 7361847f8eSopenharmony_ci * @systemapi 7461847f8eSopenharmony_ci * @since 13 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci getSupportedHapticsFeatures(): Promise<Array<systemSoundManager.ToneHapticsFeature>>; 7761847f8eSopenharmony_ci 7861847f8eSopenharmony_ci /** 7961847f8eSopenharmony_ci * Set haptic feature that is used when playing. 8061847f8eSopenharmony_ci * @param { systemSoundManager.ToneHapticsFeature } hapticsFeature - haptics Feature. 8161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 8261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 8361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 8461847f8eSopenharmony_ci * 2.Incorrect parameter types. 8561847f8eSopenharmony_ci * @throws { BusinessError } 5400102 - Operation not allowed. 8661847f8eSopenharmony_ci * @throws { BusinessError } 20700003 - Unsupported operation. 8761847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 8861847f8eSopenharmony_ci * @systemapi 8961847f8eSopenharmony_ci * @since 13 9061847f8eSopenharmony_ci */ 9161847f8eSopenharmony_ci setHapticsFeature(hapticsFeature: systemSoundManager.ToneHapticsFeature): void; 9261847f8eSopenharmony_ci 9361847f8eSopenharmony_ci /** 9461847f8eSopenharmony_ci * Get haptic feature that is used when playing. 9561847f8eSopenharmony_ci * @returns { systemSoundManager.ToneHapticsFeature } haptics feature that is used when playing. 9661847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 9761847f8eSopenharmony_ci * @throws { BusinessError } 20700003 - Unsupported operation. 9861847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 9961847f8eSopenharmony_ci * @systemapi 10061847f8eSopenharmony_ci * @since 13 10161847f8eSopenharmony_ci */ 10261847f8eSopenharmony_ci getHapticsFeature(): systemSoundManager.ToneHapticsFeature; 10361847f8eSopenharmony_ci 10461847f8eSopenharmony_ci /** 10561847f8eSopenharmony_ci * Prepare to play. 10661847f8eSopenharmony_ci * @returns { Promise<void> } Promise used to return result of prepare. 10761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 10861847f8eSopenharmony_ci * @throws { BusinessError } 5400102 - Operation not allowed. 10961847f8eSopenharmony_ci * @throws { BusinessError } 5400103 - I/O error. 11061847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 11161847f8eSopenharmony_ci * @systemapi 11261847f8eSopenharmony_ci * @since 11 11361847f8eSopenharmony_ci */ 11461847f8eSopenharmony_ci prepare(): Promise<void>; 11561847f8eSopenharmony_ci 11661847f8eSopenharmony_ci /** 11761847f8eSopenharmony_ci * Start playing the system tone. By default, the audio and haptic will not be muted. Using tone options to mute audio 11861847f8eSopenharmony_ci * or haptics. If haptics is needed, caller should have the permission of ohos.permission.VIBRATE. 11961847f8eSopenharmony_ci * @permission ohos.permission.VIBRATE 12061847f8eSopenharmony_ci * @param { SystemToneOptions } toneOptions - Tone options used for this play. 12161847f8eSopenharmony_ci * @returns { Promise<number> } Promise used to return the id of this playback. 12261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 12361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 12461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 12561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 12661847f8eSopenharmony_ci * 2.Incorrect parameter types. 12761847f8eSopenharmony_ci * @throws { BusinessError } 5400102 - Operation not allowed. 12861847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 12961847f8eSopenharmony_ci * @systemapi 13061847f8eSopenharmony_ci * @since 11 13161847f8eSopenharmony_ci */ 13261847f8eSopenharmony_ci start(toneOptions?: SystemToneOptions): Promise<number>; 13361847f8eSopenharmony_ci 13461847f8eSopenharmony_ci /** 13561847f8eSopenharmony_ci * Stop with playback id. 13661847f8eSopenharmony_ci * @param { number } id - The Playback id to stop. 13761847f8eSopenharmony_ci * @returns { Promise<void> } Promise used to return result of this stop. 13861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 13961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 14061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 14161847f8eSopenharmony_ci * 2.Incorrect parameter types. 14261847f8eSopenharmony_ci * @throws { BusinessError } 5400102 - Operation not allowed. 14361847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 14461847f8eSopenharmony_ci * @systemapi 14561847f8eSopenharmony_ci * @since 11 14661847f8eSopenharmony_ci */ 14761847f8eSopenharmony_ci stop(id: number): Promise<void>; 14861847f8eSopenharmony_ci 14961847f8eSopenharmony_ci /** 15061847f8eSopenharmony_ci * Release this system tone player. 15161847f8eSopenharmony_ci * @returns { Promise<void> } Promise used to return result of release. 15261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Caller is not a system application. 15361847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 15461847f8eSopenharmony_ci * @systemapi 15561847f8eSopenharmony_ci * @since 11 15661847f8eSopenharmony_ci */ 15761847f8eSopenharmony_ci release(): Promise<void>; 15861847f8eSopenharmony_ci} 15961847f8eSopenharmony_ci 16061847f8eSopenharmony_ci/** 16161847f8eSopenharmony_ci * System tone options used when SystemTonePlayer start playing. 16261847f8eSopenharmony_ci * @typedef SystemToneOptions 16361847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 16461847f8eSopenharmony_ci * @systemapi 16561847f8eSopenharmony_ci * @since 11 16661847f8eSopenharmony_ci */ 16761847f8eSopenharmony_ciexport interface SystemToneOptions { 16861847f8eSopenharmony_ci /** 16961847f8eSopenharmony_ci * Mute audio. 17061847f8eSopenharmony_ci * @type {?boolean} 17161847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 17261847f8eSopenharmony_ci * @systemapi 17361847f8eSopenharmony_ci * @since 11 17461847f8eSopenharmony_ci */ 17561847f8eSopenharmony_ci muteAudio?: boolean; 17661847f8eSopenharmony_ci 17761847f8eSopenharmony_ci /** 17861847f8eSopenharmony_ci * Mute haptics. 17961847f8eSopenharmony_ci * @type {?boolean} 18061847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core 18161847f8eSopenharmony_ci * @systemapi 18261847f8eSopenharmony_ci * @since 11 18361847f8eSopenharmony_ci */ 18461847f8eSopenharmony_ci muteHaptics?: boolean; 18561847f8eSopenharmony_ci}