46 Star 173 Fork 4.7K

OpenHarmony/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.multimedia.systemSoundManager.d.ts 47.65 KB
一键复制 编辑 原始数据 按行查看 历史
ancimoon 提交于 3个月前 . correct spell
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit AudioKit
*/
import type { AsyncCallback } from './@ohos.base';
import type Context from './application/Context';
import type BaseContext from './application/BaseContext';
import type { RingtonePlayer as _RingtonePlayer } from './multimedia/ringtonePlayer';
import type { RingtoneOptions as _RingtoneOptions } from './multimedia/ringtonePlayer';
import type { SystemTonePlayer as _SystemTonePlayer } from './multimedia/systemTonePlayer';
import type { SystemToneOptions as _SystemToneOptions } from './multimedia/systemTonePlayer';
/**
* Provides ringtone player interfaces.
*
* @namespace systemSoundManager
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
declare namespace systemSoundManager {
/**
* Error enum for system sound.
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
enum SystemSoundError {
/**
* IO error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_IO = 5400103,
/**
* No error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_OK = 20700000,
/**
* Type mismatch.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_TYPE_MISMATCH = 20700001,
/**
* Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_UNSUPPORTED_OPERATION = 20700003,
/**
* Data size exceeds the limit.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_DATA_TOO_LARGE = 20700004,
/**
* The number of files exceeds the limit.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_TOO_MANY_FILES = 20700005,
/**
* Insufficient ROM space.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_INSUFFICIENT_ROM = 20700006,
/**
* Invalid parameter.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
ERROR_INVALID_PARAM = 20700007
}
/**
* Enum for ringtone type.
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
enum RingtoneType {
/**
* Default type.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.RingtoneType#RINGTONE_TYPE_SIM_CARD_0
*/
RINGTONE_TYPE_DEFAULT = 0,
/**
* Ringtone type for sim card 0.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
RINGTONE_TYPE_SIM_CARD_0 = 0,
/**
* Multi-sim type.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.RingtoneType#RINGTONE_TYPE_SIM_CARD_1
*/
RINGTONE_TYPE_MULTISIM = 1,
/**
* Ringtone type for sim card 1.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
RINGTONE_TYPE_SIM_CARD_1 = 1,
}
/**
* Enum for system tone type.
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
enum SystemToneType {
/**
* System tone type for sim card 0.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
SYSTEM_TONE_TYPE_SIM_CARD_0 = 0,
/**
* System tone type for sim card 1.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
SYSTEM_TONE_TYPE_SIM_CARD_1 = 1,
/**
* System tone type notification.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
SYSTEM_TONE_TYPE_NOTIFICATION = 32,
}
/**
* Enum for tone customized type.
* @enum {number}
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
enum ToneCustomizedType {
/**
* Pre-installed tone type.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
PRE_INSTALLED = 0,
/**
* Customized tone type.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
CUSTOMIZED = 1,
}
/**
* Enum for media type.
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
enum MediaType {
/**
* Media type for audio.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
AUDIO = 0,
/**
* Media type for vide.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
VIDEO = 1,
}
/**
* Define the ringtone category.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
const TONE_CATEGORY_RINGTONE: number;
/**
* Define the text message tone category.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
const TONE_CATEGORY_TEXT_MESSAGE:number;
/**
* Define the notification tone category.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
const TONE_CATEGORY_NOTIFICATION:number;
/**
* Define the alarm tone category.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
const TONE_CATEGORY_ALARM:number;
/**
* Define the contact tone category.
* @constant
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
const TONE_CATEGORY_CONTACTS:16;
/**
* Tone attributes.
* @typedef ToneAttrs
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
interface ToneAttrs {
/**
* Gets title of tone.
* @returns { string } title.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getTitle(): string;
/**
* Sets title of tone.
* @param { string } title - Title of tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
setTitle(title: string): void;
/**
* Gets file name of tone.
* @returns { string } file name.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getFileName(): string;
/**
* Sets file name of tone.
* @param { string } name - file name.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
setFileName(name: string): void;
/**
* Gets uri of tone.
* @returns { string } uri.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getUri(): string;
/**
* Gets customized type of tone.
* @returns { ToneCustomizedType } Customized type of tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getCustomizedType(): ToneCustomizedType;
/**
* Sets tone category.
* @param { number } category - tone category. This parameter can be one of {@link TONE_CATEGORY_RINGTONE},
* {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}.
* In addition, this parameter can be result of OR logical operator of these constants.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
setCategory(category: number): void;
/**
* Gets tone category.
* @returns { number } Tone category. This value can be one of {@link TONE_CATEGORY_RINGTONE},
* {@link TONE_CATEGORY_TEXT_MESSAGE}, {@link TONE_CATEGORY_NOTIFICATION}, {@link TONE_CATEGORY_ALARM}.
* In addition, this value can be result of OR logical operator of these constants.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getCategory(): number;
/**
* Sets media type.
* @param { MediaType } type - Target media type.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
setMediaType(type: MediaType): void;
/**
* Gets media type. This function returns {@link MediaType#AUDIO} if the media type has not been changed
* by {@link setMediaType}.
* @returns { MediaType } Media type.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
getMediaType(): MediaType;
}
/**
* Array of tone attributes.
*
* @typedef {Array<ToneAttrs>} ToneAttrsArray
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
type ToneAttrsArray = Array<ToneAttrs>;
/**
* Create customized tone attributes.
* @returns { ToneAttrs } Tone attributes created.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
function createCustomizedToneAttrs(): ToneAttrs;
/**
* Definition of haptics feature in tone scenario.
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 13
*/
enum ToneHapticsFeature {
/**
* Standard haptics feature.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 13
*/
STANDARD = 0,
/**
* Gentle haptics feature.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 13
*/
GENTLE = 1,
}
/**
* Enum for haptics in tone scenario.
*
* @enum { number }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
enum ToneHapticsType {
/**
* Haptics in incoming call scenario for sim card 0.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
CALL_SIM_CARD_0 = 0,
/**
* Haptics in incoming call scenario for sim card 1.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
CALL_SIM_CARD_1 = 1,
/**
* Haptics in text message scenario for sim card 0.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
TEXT_MESSAGE_SIM_CARD_0 = 20,
/**
* Haptics in text message scenario for sim card 1.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
TEXT_MESSAGE_SIM_CARD_1 = 21,
/**
* Haptics in notification scenario.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
NOTIFICATION = 40,
}
/**
* Enum for haptics mode in tone scenario.
* @enum {number}
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
enum ToneHapticsMode {
/**
* None haptics mode.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
NONE = 0,
/**
* Haptics is synchronized with tone.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
SYNC = 1,
/**
* Haptics is out of synchronize with tone.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
NON_SYNC = 2,
}
/**
* Haptics settings in tone scenario.
* @typedef ToneHapticsSettings
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
interface ToneHapticsSettings {
/**
* Haptics mode.
* @type { ToneHapticsMode }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
mode: ToneHapticsMode;
/**
* Haptics uri. Users can set/get this parameter when {@link ToneHapticsSettings#mode} is
* {@link ToneHapticsMode#NON_SYC}. In other cases, this uri is useless and should be ignored.
* @type { ?string }
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
hapticsUri?: string;
}
/**
* Haptics attributes in tone scenario.
* @typedef ToneHapticsAttrs
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
interface ToneHapticsAttrs {
/**
* Get haptics uri.
* @returns { string } Haptics uri.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getUri(): string;
/**
* Get title of haptics.
* @returns { string } Haptics title.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getTitle(): string;
/**
* Get file name of haptics.
* @returns { string } Haptics title.
* @throws { BusinessError } 202 - Caller is not a system application.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getFileName(): string;
}
/**
* Type definition of tone haptics array.
*
* @typedef { Array<ToneHapticsAttrs> } ToneHapticsAttrsArray
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
type ToneHapticsAttrsArray = Array<ToneHapticsAttrs>;
/**
* Gets system sound manager for all type sound.
* @returns { SystemSoundManager } SystemSoundManager instance.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
function getSystemSoundManager(): SystemSoundManager;
/**
* System sound manager object.
* @typedef SystemSoundManager
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
interface SystemSoundManager {
/**
* Sets the ringtone uri to system.
* @param { Context } context - Current application context.
* @param { string } uri - Ringtone uri to set.
* @param { RingtoneType } type - Ringtone type to set.
* @param { AsyncCallback<void> } callback - Callback used to return the set uri result.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
*/
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void>): void;
/**
* Sets the ringtone uri to system.
* @param { Context } context - Current application context.
* @param { string } uri - Ringtone uri to set.
* @param { RingtoneType } type - Ringtone type to set.
* @returns { Promise<void> } Promise used to return the set uri result.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#setRingtoneUri
*/
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void>;
/**
* Sets the ringtone uri to system.
* @param { BaseContext } context - Current application context.
* @param { string } uri - Ringtone uri to set.
* @param { RingtoneType } type - Ringtone type to set.
* @returns { Promise<void> } Promise used to return the set uri result.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
setRingtoneUri(context: BaseContext, uri: string, type: RingtoneType): Promise<void>;
/**
* Gets the ringtone uri.
* @param { Context } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @param { AsyncCallback<string> } callback - Callback used to return the ringtone uri maintained in system.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
*/
getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string>): void;
/**
* Gets the ringtone uri.
* @param { Context } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#getRingtoneUri
*/
getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string>;
/**
* Gets the ringtone uri.
* @param { BaseContext } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<string> } Promise used to return the ringtone uri maintained in system.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
getRingtoneUri(context: BaseContext, type: RingtoneType): Promise<string>;
/**
* Gets the ringtone attribute which is in use.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<ToneAttrs> } Promise used to return the ringtone attribute in system.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
getCurrentRingtoneAttribute(type: RingtoneType): Promise<ToneAttrs>;
/**
* Gets attributes of the default ringtone.
* @param { BaseContext } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<ToneAttrs> } Promise used to return attributes of the default ringtone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getDefaultRingtoneAttrs(context: BaseContext, type: RingtoneType): Promise<ToneAttrs>;
/**
* Gets attribute list of ringtones.
* @param { BaseContext } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of ringtone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getRingtoneAttrList(context: BaseContext, type: RingtoneType): Promise<ToneAttrsArray>;
/**
* Gets the ringtone player.
* @param { Context } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @param { AsyncCallback<RingtonePlayer> } callback - Callback used to return a ringtone player instance.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
*/
getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer>): void;
/**
* Gets the ringtone player.
* @param { Context } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
* @deprecated since 11
* @useinstead systemSoundManager.SystemSoundManager#getRingtonePlayer
*/
getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer>;
/**
* Gets the ringtone player.
* @param { BaseContext } context - Current application context.
* @param { RingtoneType } type - Ringtone type to get.
* @returns { Promise<RingtonePlayer> } Promise used to return a ringtone player instance.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
getRingtonePlayer(context: BaseContext, type: RingtoneType): Promise<RingtonePlayer>;
/**
* Sets the system tone uri to system.
* @param { BaseContext } context - Current application context.
* @param { string } uri - Ringtone uri to set.
* @param { SystemToneType } type - System tone type to set.
* @returns { Promise<void> } Promise used to return the result of set system tone uri.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
setSystemToneUri(context: BaseContext, uri: string, type: SystemToneType): Promise<void>;
/**
* Gets the system tone uri.
* @param { BaseContext } context - Current application context.
* @param { SystemToneType } type - System tone type to get.
* @returns { Promise<string> } Promise used to return the system tone maintained in system.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
getSystemToneUri(context: BaseContext, type: SystemToneType): Promise<string>;
/**
* Gets attributes of the default system tone.
*
* @param { BaseContext } context - Current application context.
* @param { SystemToneType } type - system tone type to get.
* @returns { Promise<ToneAttrs> } Promise used to return attributes of the default system tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getDefaultSystemToneAttrs(context: BaseContext, type: SystemToneType): Promise<ToneAttrs>;
/**
* Gets attribute list of alarm tones.
* @param { BaseContext } context - Current application context.
* @param { SystemToneType } type - System tone type to get.
* @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getSystemToneAttrList(context: BaseContext, type: SystemToneType): Promise<ToneAttrsArray>;
/**
* Gets the system tone player.
* @param { BaseContext } context - Current application context.
* @param { SystemToneType } type - System tone type to get.
* @returns { Promise<SystemTonePlayer> } Promise used to return the SystemTonePlayer.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
getSystemTonePlayer(context: BaseContext, type: SystemToneType): Promise<SystemTonePlayer>;
/**
* Gets attributes of the default alarm tone.
*
* @param { BaseContext } context - Current application context.
* @returns { Promise<ToneAttrs> } Promise used to return attributes of the default alarm tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getDefaultAlarmToneAttrs(context: BaseContext): Promise<ToneAttrs>;
/**
* Sets uri of the current alarm tone.
*
* @param { BaseContext } context - Current application context.
* @param { string } uri - Alarm tone uri.
* @returns { Promise<void> } Promise used to return result of set alarm tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of input uri is not an alarm tone.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
setAlarmToneUri(context: BaseContext, uri: string): Promise<void>;
/**
* Gets uri of the current alarm tone.
*
* @param { BaseContext } context - Current application context.
* @returns { Promise<string> } Promise used to return uri of current alarm tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getAlarmToneUri(context: BaseContext): Promise<string>;
/**
* Gets attribute list of alarm tones.
* @param { BaseContext } context - Current application context.
* @returns { Promise<ToneAttrsArray> } Promise used to return attribute list of system tone.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
getAlarmToneAttrList(context: BaseContext): Promise<ToneAttrsArray>;
/**
* Open alarm tone file.
* @param { BaseContext } context - Current application context.
* @param { string } uri - Uri of alarm tone to open.
* @returns { Promise<number> } Promise used to return fd.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700001 - Tone type mismatch, e.g. tone of uri is notification instead of alarm.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
openAlarmTone(context: BaseContext, uri: string): Promise<number>;
/**
* Open tone list in batch.
* @param { Array<string> } uriList - List of uri to open. The length must be no more than 1024.
* @returns { Promise<Array<[string, number, SystemSoundError]>> } Promise used to return results of this operation.
* In each returned array number, the first item is uri of tone, the second item is fd, and the third item is error
* code. If the uri open failed, the fd will be -1, and the reason is indicated by the error code.
* @throws { BusinessError } 202 - Calleris not a system application.
* @throws { BusinessError } 20700007 - Parameter is invalid, e.g. the length of uriList is too long.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
openToneList(uriList: Array<string>): Promise<Array<[string, number, SystemSoundError]>>;
/**
* Close fd.
* @param { number } fd - File descriptor to close.
* @returns { Promise<void> } Promise used to return the result of close fd.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
close(fd: number): Promise<void>;
/**
* Add customized tone into ringtone library.
* @permission ohos.permission.WRITE_RINGTONE
* @param { BaseContext } context - Current application context.
* @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
* @param { string } externalUri - Tone uri in external storage.
* @returns { Promise<string> } Tone uri after adding into ringtone library.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
/**
* Add customized tone into ringtone library.
* @permission ohos.permission.WRITE_RINGTONE
* @param { BaseContext } context - Current application context.
* @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
* @param { string } externalUri - Tone uri in external storage.
* @returns { Promise<string> } Tone uri after adding into ringtone library.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700004 - Data size exceeds the limit.
* @throws { BusinessError } 20700005 - The number of files exceeds the limit.
* @throws { BusinessError } 20700006 - Insufficient ROM space.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, externalUri: string): Promise<string>;
/**
* Add customized tone into ringtone library.
* @permission ohos.permission.WRITE_RINGTONE
* @param { BaseContext } context - Current application context.
* @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
* @param { number } fd - File descriptor.
* @param { number } [offset] - The offset in the file where the data to be read, in bytes. By default, the offset
* is zero.
* @param { number } [length] - The length in bytes of the data to be read. By default, the length is the rest of
* bytes in the file from the offset.
* @returns { Promise<string> } Tone uri after adding into ringtone library.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
/**
* Add customized tone into ringtone library.
* @permission ohos.permission.WRITE_RINGTONE
* @param { BaseContext } context - Current application context.
* @param { ToneAttrs } toneAttr - Tone attributes created by {@link createCustomizedToneAttrs}.
* @param { number } fd - File descriptor.
* @param { number } [offset] - The offset in the file where the data to be read, in bytes. By default, the offset
* is zero.
* @param { number } [length] - The length in bytes of the data to be read. By default, the length is the rest of
* bytes in the file from the offset.
* @returns { Promise<string> } Tone uri after adding into ringtone library.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone to add is not customized.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700004 - Data size exceeds the limit.
* @throws { BusinessError } 20700005 - The number of files exceeds the limit.
* @throws { BusinessError } 20700006 - Insufficient ROM space.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
addCustomizedTone(context: BaseContext, toneAttr: ToneAttrs, fd: number, offset?: number, length?: number)
: Promise<string>;
/**
* Remove customized tone in ringtone library.
* @permission ohos.permission.WRITE_RINGTONE
* @param { BaseContext } context - Current application context.
* @param { string } uri - Tone uri.
* @returns { Promise<void> } Promise used to return removing result.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation is not allowed, e.g. ringtone of this uri is not customized.
* @throws { BusinessError } 5400103 - I/O error.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 12
*/
removeCustomizedTone(context: BaseContext, uri:string): Promise<void>;
/**
* Remove customized tone list in batch.
* @permission ohos.permission.WRITE_RINGTONE
* @param { Array<string> } uriList - Uri list to remove. The length must be no more than 1024.
* @returns { Promise<Array<[string, SystemSoundError]>> } Promise used to return removing result array. In each
* array memeber, the first item is the tone uri, and the second item is the error code.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 20700007 - Prameter is invalid, e.g. the length of uriList is too long.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 20
*/
removeCustomizedToneList(uriList: Array<string>): Promise<Array<[string, SystemSoundError]>>;
/**
* Get haptics settings.
* @param { BaseContext } context - Current application context.
* @param { ToneHapticsType } type - Tone haptics type.
* @returns { Promise<ToneHapticsSettings> } Promise used to return results of this call.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700003 - Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getToneHapticsSettings(context: BaseContext, type: ToneHapticsType): Promise<ToneHapticsSettings>;
/**
* Set haptics settings.
* @param { BaseContext } context - Current application context.
* @param { ToneHapticsType } type - Tone haptics type.
* @param { ToneHapticsSettings } settings - Tone haptics settings.
* @returns { Promise<void> } Promise used to return results of this call.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not valid.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700003 - Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
setToneHapticsSettings(context: BaseContext, type: ToneHapticsType, settings: ToneHapticsSettings): Promise<void>;
/**
* Get haptics list.
* @param { BaseContext } context - Current application context.
* @param { boolean } isSynced - The queried haptics is synchronized with tone or not.
* @returns { Promise<ToneHapticsAttrsArray> } Promise used to return ToneHapticsAttrsArray.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700003 - Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getToneHapticsList(context: BaseContext, isSynced: boolean): Promise<ToneHapticsAttrsArray>;
/**
* Get attributes of haptics which is synchronized with one tone. If no haptics is found, then the attributes in
* the returned ToneHapticsAttrs is empty.
* @param { BaseContext } context - Current application context.
* @param { string } toneUri - Uri of tone to query.
* @returns { Promise<ToneHapticsAttrs> } Promise used to return ToneHapticsAttrs.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not used for tones.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700003 - Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
getHapticsAttrsSyncedWithTone(context: BaseContext, toneUri: string): Promise<ToneHapticsAttrs>;
/**
* Open haptics.
* @param { BaseContext } context - Current application context.
* @param { string } hapticsUri - Uri of haptics to open.
* @returns { Promise<number> } Promise used to return fd.
* @throws { BusinessError } 202 - Caller is not a system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 5400102 - Operation not allowed. For example, the input URI is not one for haptics.
* @throws { BusinessError } 5400103 - I/O error.
* @throws { BusinessError } 20700003 - Unsupported operation.
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 14
*/
openToneHaptics(context: BaseContext, hapticsUri: string): Promise<number>;
}
/**
* Ringtone player object.
* @typedef { _RingtonePlayer } RingtonePlayer
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
type RingtonePlayer = _RingtonePlayer;
/**
* SystemTone player object.
* @typedef { _SystemTonePlayer } SystemTonePlayer
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
type SystemTonePlayer = _SystemTonePlayer;
/**
* Interface for ringtone options.
* @typedef { _RingtoneOptions } RingtoneOptions
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 10
*/
type RingtoneOptions = _RingtoneOptions;
/**
* System tone options.
* @typedef { _SystemToneOptions } SystemToneOptions
* @syscap SystemCapability.Multimedia.SystemSound.Core
* @systemapi
* @since 11
*/
type SystemToneOptions = _SystemToneOptions;
}
export default systemSoundManager;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/interface_sdk-js.git
git@gitee.com:openharmony/interface_sdk-js.git
openharmony
interface_sdk-js
interface_sdk-js
master

搜索帮助