diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 3f7992093c7a4776c0480e55fdd497971e072545..09b598a3751aa4ef6ab07dbcde8ae688fbbaa8b2 100755 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -100,6 +100,23 @@ declare enum HitTestType { Unknown } +declare enum CacheMode { + /** + * load online and not cache. + */ + None, + + /** + * Load cache first, then online. + */ + Online, + + /** + * load cache and not online. + */ + Only +} + declare class JsResult { /** * Constructor. @@ -232,6 +249,26 @@ declare class WebResourceError { getErrorCode(): number; } +declare class WebCookie { + /** + * Constructor. + * @since 8 + */ + constructor(); + + /** + * Sets the cookie. + * @since 8 + */ + setCookie(); + + /** + * Saves the cookies. + * @since 8 + */ + saveCookie(); +} + declare class WebController { /** * Constructor. @@ -251,6 +288,12 @@ declare class WebController { */ onActive(): void; + /** + * Clear the history in the Web. + * @since 8 + */ + clearHistory(): void; + /** * Means to load a piece of code and execute JS code in the context of the currently displayed page * @since 8 @@ -409,6 +452,62 @@ declare class WebAttribute extends CommonMethod { */ javaScriptProxy(javaScriptProxy: { obj: object, name: string, methodList: Array }): WebAttribute; + /* + * Sets whether the Web should save the password. + * @param password {@code ture} means the Web can save the password; {@code false} otherwise. + * + * @since 8 + */ + password(password: boolean): WebAttribute; + + /** + * Sets the mode of cache in the Web. + * @param cacheMode The cache mode, which can be {@link CacheMode}. + * + * @since 8 + */ + cacheMode(cacheMode: CacheMode): WebAttribute; + + /** + * Sets whether the Web should save the table data. + * @param tableData {@code ture} means the Web can save the table data; {@code false} otherwise. + * + * @since 8 + */ + tableData(tableData: boolean): WebAttribute; + + /** + * Sets whether the Web access meta 'viewport' in HTML. + * @param wideViewModeAccess {@code ture} means the Web access meta 'viewport' in HTML; {@code false} otherwise. + * + * @since 8 + */ + wideViewModeAccess(wideViewModeAccess: boolean): WebAttribute; + + /** + * Sets whether the Web access overview mode. + * @param overviewModeAccess {@code ture} means the Web access overview mode; {@code false} otherwise. + * + * @since 8 + */ + overviewModeAccess(overviewModeAccess: boolean): WebAttribute; + + /** + * Sets the atio of the text zoom. + * @param textZoomAtio The atio of the text zoom. + * + * @since 8 + */ + textZoomAtio(textZoomAtio: number): WebAttribute; + + /** + * Sets whether the Web access the database. + * @param databaseAccess {@code ture} means the Web access the database; {@code false} otherwise. + * + * @since 8 + */ + databaseAccess(databaseAccess: boolean): WebAttribute; + /** * Triggered at the end of web page loading * @since 8 @@ -509,6 +608,49 @@ declare class WebAttribute extends CommonMethod { */ onDownloadStart(callback: (event?: {url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number}) => void): WebAttribute; + /** + * Triggered when the Web page refreshes accessed history. + * @param callback The triggered callback when the Web page refreshes accessed history. + * + * @since 8 + */ + onRefreshAccessedHistory(callback: (event?: { url: string, refreshed: boolean }) => void): WebAttribute; + + /** + * Triggered when the url is about to be loaded. + * @param callback The triggered callback when the url is about to be loaded. + * @return Returns {@code ture} to let the load stop; return {@code false} to let the load continue. + * + * @since 8 + */ + onUrlLoadIntercept(callback: (event?: { data: string | WebResourceRequest }) => boolean): WebAttribute; + + /** + * Triggered when the Web page receives the ssl Error. + * @param callback The triggered callback when the Web page receives the ssl Error. + * + * @since 8 + */ + onSslErrorReceive(callback: (event?: { handler: Function, error: object }) => void): WebAttribute; + + /** + * Triggered when the render process is exited. + * @param callback The triggered when the render process is exited. + * @return Returns {@code ture} to handle the situation; return {@code false} to kill the render process. + * + * @since 8 + */ + onRenderExited(callback: (event?: { detail: object }) => boolean): WebAttribute; + + /** + * Triggered when the file selector shows. + * @param callback The triggered when the file selector shows. + * @return Returns {@code ture} to handle the situation; return {@code false} to use default handling. + * + * @since 8 + */ + onFileSelectorShow(callback: (event?: { callback: Function, fileSelector: object }) => void): WebAttribute; + /** * Just use for genetate tsbundle * @ignore ide should ignore this arrtibute diff --git a/api/@ohos.application.Ability.d.ts b/api/@ohos.application.Ability.d.ts old mode 100644 new mode 100755 index 031d516b5a884946d3933853a22fc8c5318425d1..90e2439bb238354def06438ab94389f2d615a28c --- a/api/@ohos.application.Ability.d.ts +++ b/api/@ohos.application.Ability.d.ts @@ -17,6 +17,88 @@ import AbilityConstant from "./@ohos.application.AbilityConstant"; import AbilityContext from "./application/AbilityContext"; import Want from './@ohos.application.Want'; import window from './@ohos.window'; +import { Configuration } from './@ohos.application.Configuration'; +import rpc from '/@ohos.rpc'; + +/** + * The interface of a Caller. + * + * @since 9 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @StageModelOnly + */ + interface Caller { + /** + * Notify the server of Sequenceable type data. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + call(method, data: rpc.Sequenceable): Promise; + + /** + * Notify the server of Sequenceable type data and return the notification result. + * + * @since 9 + * @sysCap AAFwk + * return Sequenceable data + * @StageModelOnly + */ + callWithResult(method: string, data: rpc.Sequenceable): Promise; + + /** + * Clear service records. + * + * @since 9 + * @sysCap AAFwk + * return Sequenceable data + * @StageModelOnly + */ + release(): void; + + /** + * Register death listener notification callback. + * + * @since 9 + * @sysCap AAFwk + * return Sequenceable data + * @StageModelOnly + */ + onRelease(callback: function): void; + } + + /** + * The interface of a Callee. + * + * @since 9 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @StageModelOnly + */ + interface Callee { + + /** + * Register data listener callback. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + on(method: string, callback: function): void; + + /** + * Unregister data listener callback. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + off(method: string): void; + } /** * The class of an ability. @@ -54,6 +136,15 @@ export default class Ability { */ lastRequestWant: Want; + /** + * Call Service Stub Object. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + callee: Callee; + /** * Called back when an ability is started for initialization. * @@ -123,4 +214,27 @@ export default class Ability { * @StageModelOnly */ onContinue(wantParam : {[key: string]: any}): boolean; + + /** + * Called when the launch mode of an ability is set to singleton. + * This happens when you re-launch an ability that has been at the top of the ability stack. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @return - + * @StageModelOnly + */ + onNewWant(want: Want): void; + + /** + * Called when the system configuration is updated. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @return - + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; } diff --git a/api/@ohos.application.AbilityStage.d.ts b/api/@ohos.application.AbilityStage.d.ts index 60fbfac572a84829174580e3f311c8f409a9fa06..9f6a4a8b568a2e0a066ae19d08588b657cc1aef0 100644 --- a/api/@ohos.application.AbilityStage.d.ts +++ b/api/@ohos.application.AbilityStage.d.ts @@ -14,6 +14,7 @@ */ import AbilityStageContext from "./application/AbilityStageContext"; +import Want from './@ohos.application.Want'; /** * The class of an ability stage. @@ -42,4 +43,15 @@ export default class AbilityStage { * @StageModelOnly */ onCreate(): void; + + /** + * Called back when start specified ability. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @return - + * @StageModelOnly + */ + onAcceptWant(want: Want): string; } \ No newline at end of file diff --git a/api/@ohos.application.StartOptions.d.ts b/api/@ohos.application.StartOptions.d.ts index 17b7bcc7da735c60fcf847f6b4f32b809dd0490e..5c0b9e7d041e9e27f562824297483e010cc21b6e 100644 --- a/api/@ohos.application.StartOptions.d.ts +++ b/api/@ohos.application.StartOptions.d.ts @@ -31,4 +31,14 @@ export default class StartOptions { * @StageModelOnly */ windowMode?: number; + + /** + * displayId + * @default - + * @devices phone, tablet + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + displayId?: number; } \ No newline at end of file diff --git a/api/@ohos.application.abilityManager.d.ts b/api/@ohos.application.abilityManager.d.ts index 36bfa7f40cdd75710f5cef2aff3c67c2001cea6e..ff2426a5e7bc9e4598d977d2e6bd62e604fb6fba 100644 --- a/api/@ohos.application.abilityManager.d.ts +++ b/api/@ohos.application.abilityManager.d.ts @@ -58,7 +58,6 @@ declare namespace abilityManager { * * @since 8 * @SysCap SystemCapability.Ability.AbilityRuntime.Core - * @param config Indicates the new configuration. * @systemapi Hide this for inner system use. * @return - */ @@ -70,7 +69,7 @@ declare namespace abilityManager { * * @since 9 * @SysCap SystemCapability.Ability.AbilityRuntime.Core - * @param config Indicates the new configuration. + * @param upperLimit Get the maximum limit of the number of messages * @systemapi Hide this for inner system use. * @return - */ diff --git a/api/@ohos.application.missionManager.d.ts b/api/@ohos.application.missionManager.d.ts index fcab539dbbbf6fe4cdf6c4af68ad5bc01a1e4c66..94f172f8e5fc096eaf834b759b95bc4de2195a7c 100644 --- a/api/@ohos.application.missionManager.d.ts +++ b/api/@ohos.application.missionManager.d.ts @@ -17,6 +17,7 @@ import { AsyncCallback } from './basic'; import { MissionInfo } from './application/MissionInfo'; import { MissionListener } from './application/MissionListener'; import { MissionSnapshot } from './application/MissionSnapshot'; +import StartOptions from "./@ohos.application.StartOptions"; /** * This module provides the capability to manage abilities and obtaining system task information. @@ -125,7 +126,8 @@ declare namespace missionManager { * @return - */ function moveMissionToFront(missionId: number, callback: AsyncCallback): void; - function moveMissionToFront(missionId: number): Promise; + function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback): void; + function moveMissionToFront(missionId: number, options?: StartOptions): Promise; } export default missionManager; \ No newline at end of file diff --git a/api/@ohos.batteryinfo.d.ts b/api/@ohos.batteryinfo.d.ts index 19689de4aa078a05f23973c1e2bc59c961fa6c5e..0130092db3c05510686e40502c003f119eb1fc37 100644 --- a/api/@ohos.batteryinfo.d.ts +++ b/api/@ohos.batteryinfo.d.ts @@ -24,7 +24,7 @@ */ declare namespace batteryInfo { /** - * Battery state of charge (SoC) of the current device. + * Battery state of charge (SoC) of the current device, in percent. * @since 6 */ const batterySOC: number; @@ -48,7 +48,7 @@ declare namespace batteryInfo { const pluggedType: BatteryPluggedType; /** - * Battery voltage of the current device. + * Battery voltage of the current device, in µV. * @since 6 */ const voltage: number; @@ -60,7 +60,7 @@ declare namespace batteryInfo { const technology: string; /** - * Battery temperature of the current device. + * Battery temperature of the current device, in 0.1℃. * @since 6 */ const batteryTemperature: number; diff --git a/api/@ohos.bytrace.d.ts b/api/@ohos.bytrace.d.ts index dcc5ba1bf0bf811d192ad06bacfcab6f5903b14f..1acc5cc2a9348e4203abc8591c17073217725c79 100644 --- a/api/@ohos.bytrace.d.ts +++ b/api/@ohos.bytrace.d.ts @@ -34,9 +34,9 @@ *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name * and taskId. * - * @SysCap SystemCapability.Developtools.Bytrace - * @devices phone, tablet + * @deprecated * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace */ declare namespace bytrace { /** @@ -47,10 +47,12 @@ declare namespace bytrace { * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by * {@link #finishTrace}, the name and taskId need to be the same. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the task name. * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. - * @since 7 */ function startTrace(name: string, taskId: number, expectedTime?: number): void; @@ -60,19 +62,23 @@ declare namespace bytrace { * This method is invoked at the end of a transaction to indicate that a task has ended, whose name * is specified by {@code name}. This method must be invoked after the the startTrace. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. * @param taskId The unique id used to distinguish the tasks and must be the same whith the . * {@code taskId} of startTrace. - * @since 7 */ function finishTrace(name: string, taskId: number): void; /** * Records a trace for generating a count, such as clock pulse and the number of layers. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the name used to identify the count. * @param count Indicates the number of the count. - * @since 7 */ function traceByValue(name: string, count: number): void; } diff --git a/api/@ohos.hiTraceChain.d.ts b/api/@ohos.hiTraceChain.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd0b78fc536099fb38a62ea71b749cd2d37f53ab --- /dev/null +++ b/api/@ohos.hiTraceChain.d.ts @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2021 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. + */ + +/** + * Provides APIs to implement call chain tracing throughout a service process. + * With HiTrace, you can quickly obtain the run log for the call chain of a + * specified service process and locate faults in cross-device, cross-process, + * or cross-thread communications. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ +declare namespace hiTraceChain { + /** + * Enumerate trace flag + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceFlag { + /** + * default value + */ + DEFAULT = 0, + + /** + * trace sync and async call. default: trace sync call only. + */ + INCLUDE_ASYNC = 1, + + /** + * do not create child span. default: create child span. + */ + DONOT_CREATE_SPAN = 1 << 1, + + /** + * output tracepoint info in span. default: do not output tracepoint info. + */ + TP_INFO = 1 << 2, + + /** + * do not output begin and end info. default: output begin and end info. + */ + NO_BE_INFO = 1 << 3, + + /** + * do not add id to log. default: add id to log. + */ + DISABLE_LOG = 1 << 4, + + /** + * the trace is triggered by fault. + */ + FAILURE_TRIGGER = 1 << 5, + + /** + * output device-to-device tracepoint info in span only. default: do not output device-to-device tracepoint info. + */ + D2D_TP_INFO = 1 << 6, + } + + /** + * Enumerate trace point type + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceTracepointType { + /** + * client send + */ + CS = 0, + + /** + * client receive + */ + CR = 1, + + /** + * server send + */ + SS = 2, + + /** + * server receive + */ + SR = 3, + + /** + * general info + */ + GENERAL = 4, + } + + /** + * Enumerate trace communication mode + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceCommunicationMode { + /** + * unspecified + */ + DEFAULT = 0, + + /** + * thread-to-thread + */ + THREAD = 1, + + /** + * process-to-process + */ + PROCESS = 2, + + /** + * device-to-device + */ + DEVICE = 3, + } + + /** + * Trace id, for tracing process. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + interface HiTraceId { + chainId: bigint; /* 0n: invalid */ + spanId?: number; + parentSpanId?: number; + flags?: number; + } + + /** + * Start tracing a process impl. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {string} name Process name. + * @param {number} flags Trace function flag. + * @return {HiTraceId} Valid if first call, otherwise invalid. + */ + function begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId; + + /** + * Stop process tracing and clear trace id of current thread if the given trace + * id is valid, otherwise do nothing. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id The trace id that need to stop. + */ + function end(id: HiTraceId): void; + + /** + * Get trace id of current thread, and return a invalid trace id if no + * trace id belong to current thread + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @return {HiTraceId} Valid if current thread have a trace id, otherwise invalid. + */ + function getId(): HiTraceId; + + /** + * Set id as trace id of current thread. Do nothing if id is invalid. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Set id as trace id of current thread. + */ + function setId(id: HiTraceId): void; + + /** + * Clear trace id of current thread and set it invalid. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + function clearId(): void; + + /** + * Create a new span id according to the trace id of current thread. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @return {HiTraceId} A valid span trace id. Otherwise trace id of current thread if do not allow create span. + */ + function createSpan(): HiTraceId; + + /** + * Print hitrace info, include trace id info. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceCommunicationMode} mode Trace communication mode. + * @param {HiTraceTracepointType} type Trace info type. + * @param {HiTraceId} id Trace id that need to print. + * @param {string} msg Customized info that need to print. + */ + function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; + + /** + * Judge whether the trace id is valid or not. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to judge. + * @return {boolean} True for a valid trace id, otherwise false. + */ + function isValid(id: HiTraceId): boolean; + + /** + * Judge whether the trace id has enabled a trace flag or not. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to judge. + * @param {HiTraceFlag} flag Trace flag that need to judge. + * @return {boolean} true if the trace id has enabled the flag. + */ + function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; + + /** + * Enable the designative trace flag for the trace id. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to enable a flag. + * @param {HiTraceFlag} flag the designative trace flag that need to be enabled in the trace id. + */ + function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; +} + +export default hiTraceChain; diff --git a/api/@ohos.hiTraceMeter.d.ts b/api/@ohos.hiTraceMeter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d624ced5b9a1ef297399313d46712e1698c9c62 --- /dev/null +++ b/api/@ohos.hiTraceMeter.d.ts @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2021 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. + */ + +/** + * Provides interfaces to trace a task for performance measure, the logs can be capture by the + * bytrace cmdline available on the device. + * + *

This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. + * + *

Example: + * To trace a name verification that is expected to complete within 5 ms: + *

{@code
+ * bytrace.startTrace("checkName", 111, 5);
+ * //your process
+ * bytrace.finishTrace("checkName", 111);
+ * }
+ * To trace the number of layers, which is 3: + *
{@code
+ * bytrace.traceByValue("curLayer", 3);
+ * }
+ * + *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name + * and taskId. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ +declare namespace hiTraceMeter { + /** + * Records a trace marking it as the start of a task, can with the expected completion time between + * startTrace and finishTrace. + * + * This method is invoked at the start of a transaction to indicate that a task has started, whose name + * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by + * {@link #finishTrace}, the name and taskId need to be the same. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. + * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. + */ + function startTrace(name: string, taskId: number): void; + + /** + * Records a trace and marks it as the end of a task. + * + * This method is invoked at the end of a transaction to indicate that a task has ended, whose name + * is specified by {@code name}. This method must be invoked after the the startTrace. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. + * @param taskId The unique id used to distinguish the tasks and must be the same whith the . + * {@code taskId} of startTrace. + */ + function finishTrace(name: string, taskId: number): void; + + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the name used to identify the count. + * @param count Indicates the number of the count. + */ + function traceByValue(name: string, count: number): void; +} + +export default hiTraceMeter; \ No newline at end of file diff --git a/api/@ohos.hichecker.d.ts b/api/@ohos.hichecker.d.ts index 214c73d42d60a5cd738068e6dc7927c98f8d8f95..4aa9b254c0305a7e302a6e0ba8e1231cc06247a5 100644 --- a/api/@ohos.hichecker.d.ts +++ b/api/@ohos.hichecker.d.ts @@ -18,7 +18,7 @@ * *@import import hichecker from '@ohos.hichecker'; * @since 8 -* @Syscap SystemCapability.HiviewDFX.HiChecker +* @syscap SystemCapability.HiviewDFX.HiChecker */ declare namespace hichecker { @@ -26,35 +26,35 @@ declare namespace hichecker { /** * The caution rule print log. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ const RULE_CAUTION_PRINT_LOG: 9223372036854775808n; // 1 << 63 /** * The caution rule trigger crash. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ const RULE_CAUTION_TRIGGER_CRASH: 4611686018427387904n; // 1 << 62 /** * The thread rule check slow process. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ const RULE_THREAD_CHECK_SLOW_PROCESS: 1n; /** * The process rule check slow event. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ const RULE_CHECK_SLOW_EVENT: 4294967296n; // 1 << 32 /** * The process rule check ability connection leak. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ const RULE_CHECK_ABILITY_CONNECTION_LEAK: 8589934592n; // 1 << 33 @@ -62,7 +62,7 @@ declare namespace hichecker { * add one or more rule. * @param rule * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ function addRule(rule: bigint) : void; @@ -70,7 +70,7 @@ declare namespace hichecker { * remove one or more rule. * @param rule * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ function removeRule(rule: bigint) : void; @@ -78,7 +78,7 @@ declare namespace hichecker { * get added rule * @return all added thread rule and process rule. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ function getRule() : bigint; @@ -87,7 +87,7 @@ declare namespace hichecker { * @param rule * @return the result of whether the query rule is added. * @since 8 - * @Syscap SystemCapability.HiviewDFX.HiChecker + * @syscap SystemCapability.HiviewDFX.HiChecker */ function contains(rule: bigint) : boolean; } diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index 54d94dab6c71cec42212e1888ce1a2992b574c6e..c33f70bef3721965f684172ae32d90933aa3329b 100755 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -18,15 +18,13 @@ import { ErrorCallback, AsyncCallback, Callback } from './basic'; /** * @name media * @since 6 - * @SysCap SystemCapability.Multimedia.Media * @import import media from '@ohos.multimedia.media' - * @devices phone, tablet, tv, wearable */ declare namespace media { /** * Creates an AudioPlayer instance. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @import import media from '@ohos.multimedia.media' * @return Returns an AudioPlayer instance if the operation is successful; returns null otherwise. */ @@ -35,124 +33,290 @@ declare namespace media { /** * Creates an AudioRecorder instance. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @import import media from '@ohos.multimedia.media' * @return Returns an AudioRecorder instance if the operation is successful; returns null otherwise. */ function createAudioRecorder(): AudioRecorder; + /** + * Creates an VideoPlayer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoPlayer(callback: AsyncCallback): void; + /** + * Creates an VideoPlayer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + * @return A Promise instance used to return VideoPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoPlayer() : Promise; + + /** + * Creates an VideoRecorder instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoRecorder(callback: AsyncCallback): void; + /** + * Creates an VideoRecorder instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + * @return A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise. + */ + function createVideoRecorder(): Promise; + + /** + * Enumerates ErrorCode types, return in BusinessError::code + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaErrorCode { + /** + * operation success. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_OK = 0, + + /** + * malloc or new memory failed. maybe system have no memory. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_NO_MEMORY = 1, + + /** + * no permission for the operation. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_OPERATION_NOT_PERMIT = 2, + + /** + * invalid argument. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_INVALID_VAL = 3, + + /** + * an IO error occurred. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_IO = 4, + + /** + * operation time out. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_TIMEOUT = 5, + + /** + * unknown error. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_UNKNOWN = 6, + + /** + * media service died. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_SERVICE_DIED = 7, + + /** + * operation is not permit in current state. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_INVALID_STATE = 8, + + /** + * operation is not supported in current version. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_UNSUPPORTED = 9, + } + + /** + * Enumerates buffering info type, for network playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum BufferingInfoType { + /** + * begin to buffering + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_START = 1, + + /** + * end to buffering + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_END = 2, + + /** + * buffering percent + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_PERCENT = 3, + + /** + * cached duration in milliseconds + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CACHED_DURATION = 4, + } + /** * Describes audio playback states. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @import import media from '@ohos.multimedia.media' */ - type AudioState = 'idle' | 'playing' | 'paused' | 'stopped'; + type AudioState = 'idle' | 'playing' | 'paused' | 'stopped' | 'error'; /** - * Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer() to create an AudioPlayer instance. + * Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer() + * to create an AudioPlayer instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ interface AudioPlayer { /** * Starts audio playback. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ play(): void; /** * Pauses audio playback. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ pause(): void; /** * Stops audio playback. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ stop(): void; /** * Resets audio playback. - * @devices phone, tablet, tv, wearable * @since 7 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ reset(): void; /** * Jumps to the specified playback position. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @param timeMs Playback position to jump */ seek(timeMs: number): void; /** * Sets the volume. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). */ setVolume(vol: number): void; /** * Releases resources used for audio playback. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ release(): void; + /** + * get all track infos in MediaDescription, should be called after data loaded callback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param callback async callback return track info in MediaDescription. + */ + getTrackDescription(callback: AsyncCallback>): void; + + /** + * get all track infos in MediaDescription, should be called after data loaded callback.. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param index track index. + * @return A Promise instance used to return the track info in MediaDescription. + */ + getTrackDescription() : Promise>; + /** + * Listens for audio playback buffering events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback buffering update event to listen for. + * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value. + */ + on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; /** * Audio media URI. Mainstream audio formats are supported. - * @devices phone, tablet, tv, wearable + * local:fd://XXX, file://XXX. network:http://xxx * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ src: string; /** * Whether to loop audio playback. The value true means to loop playback. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ loop: boolean; /** * Current playback position. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ readonly currentTime: number; /** - * Playback duration. When the data source does not support seek, it returns - 1, such as a live broadcast scenario. - * @devices phone, tablet, tv, wearable + * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ readonly duration: number; /** * Playback state. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ readonly state: AudioState; /** * Listens for audio playback events. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @param type Type of the playback event to listen for. * @param callback Callback used to listen for the playback event. */ @@ -160,9 +324,8 @@ declare namespace media { /** * Listens for audio playback events. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @param type Type of the playback event to listen for. * @param callback Callback used to listen for the playback event. */ @@ -170,9 +333,8 @@ declare namespace media { /** * Listens for playback error events. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioPlayer * @param type Type of the playback error event to listen for. * @param callback Callback used to listen for the playback error event. */ @@ -180,94 +342,107 @@ declare namespace media { } /** - * Enumerates audio encoding formats. + * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @import import media from '@ohos.multimedia.media' - * @devices phone, tablet, tv, wearable + * @deprecated since 8 */ enum AudioEncoder { /** * Advanced Audio Coding Low Complexity (AAC-LC). + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ AAC_LC = 3, } /** - * Enumerates audio output formats. + * Enumerates audio output formats, it will be deprecated after API8, use @ContainerFormatType to replace. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @import import media from '@ohos.multimedia.media' - * @devices phone, tablet, tv, wearable + * @deprecated since 8 */ enum AudioOutputFormat { /** * Indicates the Moving Picture Experts Group-4 (MPEG4) media format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ MPEG_4 = 2, /** * Audio Data Transport Stream (ADTS), a transmission stream format of Advanced Audio Coding (AAC) audio. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ AAC_ADTS = 6 } + /** + * Provides the geographical location definitions for media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.Core + */ interface Location { /** * Latitude. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.Core */ latitude: number; /** * Longitude. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.Core */ longitude: number; } + /** + * Provides the audio recorder configuration definitions. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ interface AudioRecorderConfig { /** - * Audio encoding format. The default value is DEFAULT. - * @devices phone, tablet, tv, wearable + * Audio encoding format. The default value is DEFAULT, it will be deprecated after API8. + * use "audioEncoderMime" instead. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @deprecated since 8 */ audioEncoder?: AudioEncoder; /** * Audio encoding bit rate. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ audioEncodeBitRate?: number; /** * Audio sampling rate. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ audioSampleRate?: number; /** * Number of audio channels. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ numberOfChannels?: number; /** - * Audio output format. The default value is DEFAULT. - * @devices phone, tablet, tv, wearable + * Audio output format. The default value is DEFAULT, it will be deprecated after API8. + * it will be replaced with "fileFormat". * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @deprecated since 8 */ format?: AudioOutputFormat; @@ -276,85 +451,95 @@ declare namespace media { * format like: scheme + "://" + "context". * file: file://path * fd: fd://fd - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ uri: string; /** * Geographical location information. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ location?: Location; + + /** + * audio encoding format MIME. it used to replace audioEncoder. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + audioEncoderMime?: CodecMimeType; + /** + * output file format. see @ContainerFormatType , it used to replace "format". + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + fileFormat?: ContainerFormatType; } + /** + * Manages and record audio. Before calling an AudioRecorder method, you must use createAudioRecorder() + * to create an AudioRecorder instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ interface AudioRecorder { /** * Prepares for recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @param config Recording parameters. */ prepare(config: AudioRecorderConfig): void; /** * Starts audio recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ start(): void; /** * Pauses audio recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ pause(): void; /** * Resumes audio recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ resume(): void; /** * Stops audio recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ stop(): void; /** * Releases resources used for audio recording. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ release(): void; /** * Resets audio recording. - * Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset, you must call prepare() to set the recording configurations for another recording. - * @devices phone, tablet, tv, wearable + * Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset, + * you must call prepare() to set the recording configurations for another recording. * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder */ reset(): void; /** * Listens for audio recording events. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @param type Type of the audio recording event to listen for. * @param callback Callback used to listen for the audio recording event. */ @@ -362,14 +547,874 @@ declare namespace media { /** * Listens for audio recording error events. - * @devices phone, tablet, tv, wearable * @since 6 - * @SysCap SystemCapability.Multimedia.Media + * @syscap SystemCapability.Multimedia.Media.AudioRecorder * @param type Type of the audio recording error event to listen for. * @param callback Callback used to listen for the audio recording error event. */ on(type: 'error', callback: ErrorCallback): void; } -} -export default media; \ No newline at end of file + /** + * Describes video recorder states. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; + + /** + * Manages and record video. Before calling an VideoRecorder method, you must use createVideoRecorder() + * to create an VideoRecorder instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorder { + /** + * Prepares for recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param config Recording parameters. + * @param callback A callback instance used to return when prepare completed. + */ + prepare(config: VideoRecorderConfig, callback: AsyncCallback): void; + /** + * Prepares for recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param config Recording parameters. + * @return A Promise instance used to return when prepare completed. + */ + prepare(config: VideoRecorderConfig): Promise; + /** + * get input surface.it must be called between prepare completed and start. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback Callback used to return the input surface id in string. + */ + getInputSurface(callback: AsyncCallback): void; + /** + * get input surface. it must be called between prepare completed and start. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return the input surface id in string. + */ + getInputSurface(): Promise; + /** + * Starts video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when start completed. + */ + start(callback: AsyncCallback): void; + /** + * Starts video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when start completed. + */ + start(): Promise; + /** + * Pauses video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when pause completed. + */ + pause(callback: AsyncCallback): void; + /** + * Pauses video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when pause completed. + */ + pause(): Promise; + /** + * Resumes video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when resume completed. + */ + resume(callback: AsyncCallback): void; + /** + * Resumes video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when resume completed. + */ + resume(): Promise; + /** + * Stops video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when stop completed. + */ + stop(callback: AsyncCallback): void; + /** + * Stops video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when stop completed. + */ + stop(): Promise; + /** + * Releases resources used for video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when release completed. + */ + release(callback: AsyncCallback): void; + /** + * Releases resources used for video recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when release completed. + */ + release(): Promise; + /** + * Resets video recording. + * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, + * you must call prepare() to set the recording configurations for another recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when reset completed. + */ + reset(callback: AsyncCallback): void; + /** + * Resets video recording. + * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, + * you must call prepare() to set the recording configurations for another recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when reset completed. + */ + reset(): Promise; + /** + * Listens for video recording error events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param type Type of the video recording error event to listen for. + * @param callback Callback used to listen for the video recording error event. + */ + on(type: 'error', callback: ErrorCallback): void; + + /** + * video recorder state. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly state: VideoRecordState; + } + + /** + * Describes video playback states. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + type VideoPlayState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; + + /** + * Enumerates playback speed. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + enum PlaybackSpeed { + /** + * playback at 0.75x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_0_75_X = 0, + /** + * playback at normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_00_X = 1, + /** + * playback at 1.25x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_25_X = 2, + /** + * playback at 1.75x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_75_X = 3, + /** + * playback at 2.0x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_2_00_X = 4, + } + + /** + * Manages and plays video. Before calling an video method, you must use createVideoPlayer() to create an VideoPlayer + * instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + */ + interface VideoPlayer { + /** + * set display surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param surfaceId surface id, video player will use this id get a surface instance. + * @return A Promise instance used to return when release output buffer completed. + */ + setDisplaySurface(surfaceId: string, callback: AsyncCallback): void; + /** + * set display surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param surfaceId surface id, video player will use this id get a surface instance. + * @return A Promise instance used to return when release output buffer completed. + */ + setDisplaySurface(surfaceId: string): Promise; + /** + * prepare video playback, it will request resource for playing. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when prepare completed. + */ + prepare(callback: AsyncCallback): void; + /** + * prepare video playback, it will request resource for playing. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when prepare completed. + */ + prepare(): Promise; + /** + * Starts video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when start completed. + */ + play(callback: AsyncCallback): void; + /** + * Starts video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when start completed. + */ + play(): Promise; + /** + * Pauses video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when pause completed. + */ + pause(callback: AsyncCallback): void; + /** + * Pauses video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when pause completed. + */ + pause(): Promise; + /** + * Stops video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when stop completed. + */ + stop(callback: AsyncCallback): void; + /** + * Stops video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when stop completed. + */ + stop(): Promise; + /** + * Resets video playback, it will release the resource. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when reset completed. + */ + reset(callback: AsyncCallback): void; + /** + * Resets video playback, it will release the resource. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when reset completed. + */ + reset(): Promise; + /** + * Jumps to the specified playback position by default SeekMode(SEEK_CLOSEST), + * the performance may be not the best. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param callback A callback instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, callback: AsyncCallback): void; + /** + * Jumps to the specified playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param mode seek mode, see @SeekMode . + * @param callback A callback instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, mode:SeekMode, callback: AsyncCallback): void; + /** + * Jumps to the specified playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param mode seek mode, see @SeekMode . + * @return A Promise instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, mode?:SeekMode): Promise; + /** + * Sets the volume. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). + * @param callback A callback instance used to return when set volume completed. + */ + setVolume(vol: number, callback: AsyncCallback): void; + /** + * Sets the volume. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). + * @return A Promise instance used to return when set volume completed. + */ + setVolume(vol: number): Promise; + /** + * Releases resources used for video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when release completed. + */ + release(callback: AsyncCallback): void; + /** + * Releases resources used for video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when release completed. + */ + release(): Promise; + /** + * get all track infos in MediaDescription, should be called after data loaded callback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback async callback return track info in MediaDescription. + */ + getTrackDescription(callback: AsyncCallback>): void; + + /** + * get all track infos in MediaDescription, should be called after data loaded callback.. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param index track index. + * @return A Promise instance used to return the track info in MediaDescription. + */ + getTrackDescription() : Promise>; + + /** + * media url. Mainstream video formats are supported. + * local:fd://XXX, file://XXX. network:http://xxx + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + url: string; + + /** + * Whether to loop video playback. The value true means to loop playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + loop: boolean; + + /** + * Current playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly currentTime: number; + + /** + * Playback duration, if -1 means cannot seek. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly duration: number; + + /** + * Playback state. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly state: VideoPlayState; + + /** + * video width, valid after prepared. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly width: number; + + /** + * video height, valid after prepared. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly height: number; + + /** + * set payback speed. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param speed playback speed, see @PlaybackSpeed . + * @param callback Callback used to return actually speed. + */ + setSpeed(speed:number, callback: AsyncCallback): void; + /** + * set output surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param speed playback speed, see @PlaybackSpeed . + * @return A Promise instance used to return actually speed. + */ + setSpeed(speed:number): Promise; + + /** + * Listens for video playback completed events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return . + */ + on(type: 'playbackCompleted', callback: Callback): void; + + /** + * Listens for video playback buffering events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback buffering update event to listen for. + * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value. + */ + on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; + + /** + * Listens for start render video frame events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return . + */ + on(type: 'startRenderFrame', callback: Callback): void; + + /** + * Listens for video size changed event. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return video size. + */ + on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; + + /** + * Listens for playback error events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback error event to listen for. + * @param callback Callback used to listen for the playback error event. + */ + on(type: 'error', callback: ErrorCallback): void; + } + + /** + * Enumerates container format type(The abbreviation for 'container format type' is CFT). + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum ContainerFormatType { + /** + * A video container format type mp4. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CFT_MPEG_4 = "mp4", + + /** + * A audio container format type m4a. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CFT_MPEG_4A = "m4a", + } + + /** + * Enumerates media data type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaType { + /** + * track is audio. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MEDIA_TYPE_AUD = 0, + /** + * track is video. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MEDIA_TYPE_VID = 1, + } + + /** + * Enumerates media description key. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaDescriptionKey { + /** + * key for track index, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_TRACK_INDEX = "track_index", + + /** + * key for track type, value type is number, see @MediaType. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_TRACK_TYPE = "track_type", + + /** + * key for codec mime type, value type is string. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_CODEC_MIME = "codec_mime", + + /** + * key for duration, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_DURATION = "duration", + + /** + * key for bitrate, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_BITRATE = "bitrate", + + /** + * key for video width, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_WIDTH = "width", + + /** + * key for video height, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_HEIGHT = "height", + + /** + * key for video frame rate, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_FRAME_RATE = "frame_rate", + + /** + * key for audio channel count, value type is number + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_AUD_CHANNEL_COUNT = "channel_count", + + /** + * key for audio sample rate, value type is number + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_AUD_SAMPLE_RATE = "sample_rate", + } + + /** + * Provides the video recorder profile definitions. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorderProfile { + /** + * Indicates the audio bit rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioBitrate: number; + + /** + * Indicates the number of audio channels. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioChannels: number; + + /** + * Indicates the audio encoding format. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioCodec: CodecMimeType; + + /** + * Indicates the audio sampling rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioSampleRate: number; + + /** + * Indicates the output file format. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly fileFormat: ContainerFormatType; + + /** + * Indicates the video bit rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoBitrate: number; + + /** + * Indicates the video encoding format. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoCodec: CodecMimeType; + + /** + * Indicates the video width. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameWidth: number; + + /** + * Indicates the video height. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameHeight: number; + + /** + * Indicates the video frame rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameRate: number; + } + + /** + * Enumerates audio source type for recorder. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + */ + enum AudioSourceType { + /** + * default audio source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + AUDIO_SOURCE_TYPE_DEFAULT = 0, + /** + * source type mic. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + AUDIO_SOURCE_TYPE_MIC = 1, + } + + /** + * Enumerates video source type for recorder. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + */ + enum VideoSourceType { + /** + * surface raw data. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + VIDEO_SOURCE_TYPE_SURFACE_YUV = 0, + /** + * surface ES data. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + VIDEO_SOURCE_TYPE_SURFACE_ES = 1, + } + + /** + * Provides the video recorder configuration definitions. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorderConfig { + /** + * audio source type, details see @AudioSourceType . + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + audioSourceType: AudioSourceType; + /** + * video source type, details see @VideoSourceType . + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + videoSourceType: VideoSourceType; + /** + * video recorder profile, can get by "getVideoRecorderProfile", details see @VideoRecorderProfile . + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + profile:VideoRecorderProfile; + /** + * video output uri.support two kind of uri now. + * format like: scheme + "://" + "context". + * file: file://path + * fd: fd://fd + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + url: string; + /** + * Sets the video rotation angle in output file, and for the file to playback. mp4 support. + * the range of rotation angle should be {0, 90, 180, 270}, default is 0. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + rotation?: number; + /** + * geographical location information. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + location?: Location; + } + + /** + * Provides the container definition for media description key-value pairs. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + interface MediaDescription { + /** + * key:value pair, key see @MediaDescriptionKey . + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + [key : string]: Object; + } + + /** + * Enumerates seek mode. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum SeekMode { + /** + * seek to the next sync frame of the given timestamp + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + SEEK_NEXT_SYNC = 0, + /** + * seek to the previous sync frame of the given timestamp + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + SEEK_PREV_SYNC = 1, + } + + /** + * Enumerates Codec MIME types. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum CodecMimeType { + /** + * H.263 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_H263 = 'video/h263', + /** + * H.264 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_AVC = 'video/avc', + /** + * MPEG2 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_MPEG2 = 'video/mpeg2', + /** + * MPEG4 codec MIME type + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_MPEG4 = 'video/mp4v-es', + + /** + * VP8 codec MIME type + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_VP8 = 'video/x-vnd.on2.vp8', + + /** + * AAC codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_AAC = 'audio/mp4a-latm', + + /** + * vorbis codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_VORBIS = 'audio/vorbis', + + /** + * flac codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_FLAC = 'audio/flac', + } +} +export default media; diff --git a/api/@ohos.multimedia.mediaLibrary.d.ts b/api/@ohos.multimedia.mediaLibrary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72b7e28cf1251fc9e7230082403277c54ca0a1ab --- /dev/null +++ b/api/@ohos.multimedia.mediaLibrary.d.ts @@ -0,0 +1,1147 @@ +/* + * Copyright (C) 2022 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. + */ + +import { AsyncCallback } from './basic'; +import Context from './@ohos.ability'; +import image from './@ohos.multimedia.image'; + +/** + * @name mediaLibrary + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import media from '@ohos.multimedia.mediaLibrary' + */ +declare namespace mediaLibrary { + /** + * Obtains a MediaLibrary instance. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + * @FAModelOnly + * @return Returns a MediaLibrary instance if the operation is successful; returns null otherwise. + */ + function getMediaLibrary(): MediaLibrary; + /** + * Returns an instance of MediaLibrary + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @StageModelOnly + * @param Hap context information + * @return Instance of MediaLibrary + */ + function getMediaLibrary(context: Context): MediaLibrary; + + /** + * Enumeration types for different kind of Media Files + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum MediaType { + /** + * File media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + FILE = 0, + /** + * Image media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + IMAGE, + /** + * Video media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + VIDEO, + /** + * Audio media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + AUDIO + } + + /** + * Describes media resource options. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface MediaAssetOption { + /** + * URI of the media source. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + src: string; + /** + * Multipurpose Internet Mail Extensions (MIME) type of the media. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + mimeType: string; + /** + * Relative path for storing media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + relativePath?: string; + } + + /** + * Describes media selection options. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface MediaSelectOption { + /** + * Media type, which can be image, video, or media (indicating both image and video). + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + type: 'image' | 'video' | 'media'; + /** + * Maximum number of media items that can be selected + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + count: number; + } + + /** + * Provides methods to encapsulate file attributes. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface FileAsset { + /** + * File ID. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly id: number; + /** + * URI of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly uri: string; + /** + * MIME type, for example, video/mp4, audio/mp4, or audio/amr-wb. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly mimeType: string; + /** + * Media type, for example, IMAGE, VIDEO, FILE, AUDIO + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly mediaType: MediaType; + /** + * Display name (with a file name extension) of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + displayName: string; + /** + * File name title (without the file name extension). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + title: string; + /** + * Relative Path of the file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + relativePath: string; + /** + * Parent folder's file_id of the file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly parent: number; + /** + * Data size of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly size: number; + /** + * Date (timestamp) when the file was added. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateAdded: number; + /** + * Date (timestamp) when the file was modified. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateModified: number; + /** + * Date (timestamp) when the file was taken. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateTaken: number; + /** + * Artist of the audio file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly artist: string; + /** + * audioAlbum of the audio file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly audioAlbum: string; + /** + * Display width of the file. This is valid only for videos and images. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly width: number; + /** + * Display height of the file. This is valid only for videos and images. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly height: number; + /** + * Rotation angle of the file, in degrees. + * The rotation angle can be 0, 90, 180, or 270 degrees. This is valid only for videos. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + orientation: number; + /** + * duration of the audio and video file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly duration: number; + /** + * ID of the album where the file is located. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumId: number; + /** + * URI of the album where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumUri: string; + /** + * Name of the album where the file is located. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumName: string; + + /** + * If it is a directory where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback, Callback return the result of isDerectory. + */ + isDirectory(callback: AsyncCallback): void; + /** + * If it is a directory where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + isDirectory():Promise; + /** + * Modify meta data where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback, no value will be returned. + */ + commitModify(callback: AsyncCallback): void; + /** + * Modify meta data where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + commitModify(): Promise; + /** + * Open the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param mode, mode for open, for example: rw, r, w. + * @param callback, Callback return the fd of the file. + */ + open(mode: string, callback: AsyncCallback): void; + /** + * Open the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param mode, mode for open, for example: rw, r, w. + */ + open(mode: string): Promise; + /** + * Close the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param fd, fd of the file which had been opened + * @param callback, no value will be returned. + */ + close(fd: number, callback: AsyncCallback): void; + /** + * Close the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param fd, fd of the file which had been opened + */ + close(fd: number): Promise; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the thumbnail's pixelmap. + */ + getThumbnail(callback: AsyncCallback): void; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param size, thumbnail's size + * @param callback Callback used to return the thumbnail's pixelmap. + */ + getThumbnail(size: Size, callback: AsyncCallback): void; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param size, thumbnail's size + */ + getThumbnail(size?: Size): Promise; + /** + * Set favorite for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param isFavorite ture is favorite file, false is not favorite file + * @param callback Callback used to return, No value is returned. + */ + favorite(isFavorite: boolean, callback: AsyncCallback): void; + /** + * Set favorite for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param isFavorite ture is favorite file, false is not favorite file + */ + favorite(isFavorite: boolean): Promise; + /** + * If the file is favorite when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return true or false. + */ + isFavorite(callback: AsyncCallback): void; + /** + * If the file is favorite when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + isFavorite():Promise; + /** + * Set trash for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param isTrash true is trashed file, false is not trashed file + * @param callback Callback used to return, No value is returned. + */ + trash(isTrash: boolean, callback: AsyncCallback): void; + /** + * Set trash for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param isTrash true is trashed file, false is not trashed file + */ + trash(isTrash: boolean,): Promise; + /** + * If the file is in trash when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return true or false. + */ + isTrash(callback: AsyncCallback): void; + /** + * If the file is in trash when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + isTrash():Promise; + } + + /** + * Describes MediaFetchOptions's selection + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum FileKey { + /** + * File ID + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ID = "file_id", + /** + * Relative Path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + RELATIVE_PATH = "relative_path", + /** + * File name + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DISPLAY_NAME = "display_name", + /** + * Parent folder file id + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + PARENT = "parent", + /** + * Mime type of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + MIME_TYPE = "mime_type", + /** + * Media type of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + MEDIA_TYPE = "media_type", + /** + * Size of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + SIZE = "size", + /** + * Date of the file creation + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_ADDED = "date_added", + /** + * Modify date of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_MODIFIED = "date_modified", + /** + * Date taken of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_TAKEN = "date_taken", + /** + * Title of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + TITLE = "title", + /** + * Artist of the audio file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ARTIST = "artist", + /** + * Audio album of the audio file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + AUDIOALBUM = "audio_album", + /** + * Duration of the audio and video file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DURATION = "duration", + /** + * Width of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + WIDTH = "width", + /** + * Height of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + HEIGHT = "height", + /** + * Orientation of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ORIENTATION = "orientation", + /** + * Album id of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ALBUM_ID = "bucket_id", + /** + * Album name of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ALBUM_NAME = "bucket_display_name", + } + + /** + * Fetch parameters applicable on images, videos, audios, albums and other media + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + interface MediaFetchOptions { + /** + * Fields to retrieve, for example, selections: "media_type =? OR media_type =?". + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + selections: string; + /** + * Conditions for retrieval, for example, selectionArgs: [IMAGE, VIDEO]. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + selectionArgs: Array; + /** + * Sorting criterion of the retrieval results, for example, order: "datetaken DESC,_display_name DESC, _id DESC". + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + order?: string; + /** + * uri for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + uri?: string; + /** + * networkId for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + networkId?: string; + /** + * extendArgs for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + extendArgs?: string; + } + + /** + * Implements file retrieval. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface FetchFileResult { + /** + * Obtains the total number of files in the file retrieval result. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return Total number of files. + */ + getCount(): number; + /** + * Checks whether the result set points to the last row. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return Whether the file is the last one. + * You need to check whether the file is the last one before calling getNextObject, + * which returns the next file only when True is returned for this method. + */ + isAfterLast(): boolean; + /** + * Releases the FetchFileResult instance and invalidates it. Other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + close(): void; + /** + * Obtains the first FileAsset in the file retrieval result. This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getFirstObject(callback: AsyncCallback): void; + /** + * Obtains the first FileAsset in the file retrieval result. This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getFirstObject(): Promise; + /** + * Obtains the next FileAsset in the file retrieval result. + * This method uses a callback to return the file. + * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row. + * This method returns the next file only when True is returned for isAfterLast(). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getNextObject(callback: AsyncCallback): void; + /** + * Obtains the next FileAsset in the file retrieval result. + * This method uses a promise to return the file. + * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row. + * This method returns the next file only when True is returned for isAfterLast(). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getNextObject(): Promise; + /** + * Obtains the last FileAsset in the file retrieval result. This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getLastObject(callback: AsyncCallback): void; + /** + * Obtains the last FileAsset in the file retrieval result. This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getLastObject(): Promise; + /** + * Obtains the FileAsset with the specified index in the file retrieval result. + * This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param index Index of the file to obtain. + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getPositionObject(index: number, callback: AsyncCallback): void; + /** + * Obtains the FileAsset with the specified index in the file retrieval result. + * This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param index Index of the file to obtain. + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getPositionObject(index: number): Promise; + /** + * Obtains all FileAssets in the file retrieval result. + * This method uses a callback to return the result. After this method is called, + * close() is automatically called to release the FetchFileResult instance and invalidate it. + * In this case, other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return a FileAsset array. + */ + getAllObject(callback: AsyncCallback>): void; + /** + * Obtains all FileAssets in the file retrieval result. + * This method uses a promise to return the result. that store the selected media resources. + * close() is automatically called to release the FetchFileResult instance and invalidate it. + * In this case, other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return a FileAsset array. + */ + getAllObject(): Promise>; + } + + /** + * Defines the album. + * + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 7 + */ + interface Album { + /** + * Album ID. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumId: number; + /** + * Album name. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + albumName: string; + /** + * Album uri. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumUri: string; + /** + * Date (timestamp) when the album was last modified. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateModified: number; + /** + * File count for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly count: number; + /** + * Relative path for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly relativePath: string; + /** + * coverUri for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly coverUri: string; + + /** + * Modify the meta data for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback, no value will be returned. + */ + commitModify(callback: AsyncCallback): void; + /** + * Modify the meta data for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + commitModify(): Promise; + /** + * SObtains files in an album. This method uses an asynchronous callback to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(callback: AsyncCallback): void; + /** + * SObtains files in an album. This method uses an asynchronous callback to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media retrieval options. + * @param callback Callback used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; + /** + * Obtains files in an album. This method uses a promise to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media retrieval options. + * @return A Promise instance used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(options?: MediaFetchOptions): Promise; + } + + /** + * Enumeration public directory that predefined + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum DirectoryType { + /** + * predefined public directory for files token by Camera. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_CAMERA = 0, + /** + * predefined public directory for VIDEO files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_VIDEO, + /** + * predefined public directory for IMAGE files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_IMAGE, + /** + * predefined public directory for AUDIO files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_AUDIO, + /** + * predefined public directory for DOCUMENTS files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_DOCUMENTS, + /** + * predefined public directory for DOWNLOAD files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_DOWNLOAD + } + + /** + * Defines the MediaLibrary class and provides functions to access the data in media storage. + * + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 6 + */ + interface MediaLibrary { + /** + * get system predefined root dir, use to create file asset by relative path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type, public directory predefined in DirectoryType. + * @param callback, Callback return the FetchFileResult. + */ + getPublicDirectory(type: DirectoryType, callback: AsyncCallback): void; + /** + * get system predefined root dir, use to create file asset by relative path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type, public directory predefined in DirectoryType. + * @param return A promise instance used to return the public directory in the format of string + */ + getPublicDirectory(type: DirectoryType): Promise; + /** + * query all assets just for count & first cover + * if need all data, getAllObject from FetchFileResult + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param options, Media retrieval options. + * @param callback, Callback return the FetchFileResult. + */ + getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; + /** + * query all assets just for count & first cover + * if need all data, getAllObject from FetchFileResult + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param options, Media retrieval options. + * @return A promise instance used to return the files in the format of a FetchFileResult instance + */ + getFileAssets(options: MediaFetchOptions): Promise; + /** + * Trun on mornitor the data changes by media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type, mediaType + * @param callback no value returned + */ + on(type: 'Device'|'Album'|'Image'|'Audio'|'Video'|'File'| 'Remote file', callback: () => {}): void; + /** + * Trun off Mornitor the data changes by media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type, mediaType + * @param callback no value returned + */ + off(type: 'Device'|'Album'|'Image'|'Audio'|'Video'|'File'| 'Remote file', callback?: () => {}): void; + /** + * Create File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param mediaType, mediaType for example:IMAGE, VIDEO, AUDIO, FILE + * @param displayName, file name + * @param relativePath, relative path + * @param callback Callback used to return the FileAsset + */ + createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback): void; + /** + * Create File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param mediaType, mediaType for example:IMAGE, VIDEO, AUDIO, FILE + * @param displayName, file name + * @param relativePath, relative path + * @return A Promise instance used to return the FileAsset + */ + createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise; + /** + * Delete File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param uri, FileAsset's URI + * @param callback no value returned + */ + deleteAsset(uri: string, callback: AsyncCallback): void; + /** + * Delete File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param uri, FileAsset's URI + * @return A Promise instance, no value returned + */ + deleteAsset(uri: string): Promise; + /** + * Obtains albums based on the media retrieval options. This method uses an asynchronous callback to return. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media retrieval options. + * @param callback Callback used to return an album array. + */ + getAlbums(options: MediaFetchOptions, callback: AsyncCallback>): void; + /** + * Obtains albums based on the media retrieval options. This method uses a promise to return the albums. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media retrieval options. + * @return A Promise instance used to return an album array. + */ + getAlbums(options: MediaFetchOptions): Promise>; + /** + * Stores media resources. This method uses an asynchronous callback to return the URI that stores + * the media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media resource option. + * @param callback Callback used to return the URI that stores the media resources. + */ + storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback): void; + /** + * Stores media resources. This method uses a promise to return the URI that stores the media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media resource option. + * @return Promise used to return the URI that stores the media resources. + */ + storeMediaAsset(option: MediaAssetOption): Promise; + /** + * Starts image preview, with the first image to preview specified. This method uses an asynchronous callback + * to receive the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param index Sequence number of the first image to preview. + * @param callback Callback used for image preview. No value is returned. + */ + startImagePreview(images: Array, index: number, callback: AsyncCallback): void; + /** + * Starts image preview. This method uses an asynchronous callback to receive the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param callback Callback used for image preview. No value is returned. + */ + startImagePreview(images: Array, callback: AsyncCallback): void; + /** + * Starts image preview, with the first image to preview specified. + * This method uses a promise to return the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param index Sequence number of the first image to preview. + * @return Promise used to return whether the operation is successful. + */ + startImagePreview(images: Array, index?: number): Promise; + /** + * Starts media selection. This method uses an asynchronous callback to + * return the list of URIs that store the selected media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media selection option. + * @param callback Callback used to return the list of URIs that store the selected media resources. + */ + startMediaSelect(option: MediaSelectOption, callback: AsyncCallback>): void; + /** + * Starts media selection. This method uses a promise to return the list of URIs + * that store the selected media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media selection option. + * @return Promise used to return the list of URIs that store the selected media resources. + */ + startMediaSelect(option: MediaSelectOption): Promise>; + /** + * Get Active Peer device information + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @param callback, Callback return the list of the active peer devices' information + */ + getActivePeers(callback: AsyncCallback>): void; + /** + * Get Active Peer device information + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @return Promise used to return the list of the active peer devices' information + */ + getActivePeers(): Promise>; + /** + * Get all the peer devices' information + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @param callback, Callback return the list of the all the peer devices' information + */ + getAllPeers(callback: AsyncCallback>): void; + /** + * Get all the peer devices' information + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @return Promise used to return the list of the all the peer devices' information + */ + getAllPeers(): Promise>; + /** + * Release MediaLibrary instance + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback, no value returned + */ + release(callback: AsyncCallback): void; + /** + * Release MediaLibrary instance + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + release(): Promise; + } + + /** + * thumbnail's size which have width and heigh + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 8 + */ + interface Size { + /** + * Width of image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + width: number; + /** + * Height of image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + height: number; + } + + /** + * peer devices' information + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @since 8 + */ + interface PeerInfo { + /** + * Peer device name + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + readonly deviceName: string; + /** + * Peer device network id + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + readonly networkId: string; + /** + * Peer device type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + readonly deviceType: DeviceType; + /** + * Peer device online status + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + readonly isOnline: boolean; + } + + /** + * peer device type + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + * @since 8 + */ + enum DeviceType { + /** + * Unknow device type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_UNKNOWN = 0, + /** + * Laptop device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_LAPTOP, + /** + * Phone device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_PHONE, + /** + * Tablet device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_TABLET, + /** + * Watch device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_WATCH, + /** + * Car device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_CAR, + /** + * TV device + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore + * @systemapi + */ + TYPE_TV + } +} + +export default mediaLibrary; diff --git a/api/application/AbilityContext.d.ts b/api/application/AbilityContext.d.ts old mode 100644 new mode 100755 index 68cf988156f95cbe8dfb64c386cc1c6f38174294..442c46a5d07d4cb904e775c2375a2ff8223c8c7b --- a/api/application/AbilityContext.d.ts +++ b/api/application/AbilityContext.d.ts @@ -22,6 +22,8 @@ import Context from "./Context"; import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.application.StartOptions"; import PermissionRequestResult from "./PermissionRequestResult"; +import { Configuration } from '../@ohos.application.Configuration'; +import Caller from '../@ohos.application.Ability'; /** * The context of an ability. It allows access to ability-specific resources. @@ -50,6 +52,15 @@ export default class AbilityContext extends Context { */ currentHapModuleInfo: HapModuleInfo; + /** + * Indicates configuration information. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + config: Configuration; + /** * Starts a new ability. * @@ -63,6 +74,18 @@ export default class AbilityContext extends Context { startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; startAbility(want: Want, options?: StartOptions): Promise; + /** + * Get the caller object of the startup capability + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param parameter Indicates the ability to start. + * @return Caller + * @StageModelOnly + */ + startAbilityByCall(want: Want): Promise; + /** * Starts a new ability with account. * diff --git a/api/application/ServiceExtensionContext.d.ts b/api/application/ServiceExtensionContext.d.ts index 41017e10426a72c161a87666c5fa67309928eb01..ce5e61f0654409a57810d33d2bb64108bf4c0509 100644 --- a/api/application/ServiceExtensionContext.d.ts +++ b/api/application/ServiceExtensionContext.d.ts @@ -18,6 +18,7 @@ import { ConnectOptions } from "../ability/connectOptions"; import ExtensionContext from "./ExtensionContext"; import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.application.StartOptions"; +import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"; /** * The context of service extension. It allows access to @@ -30,6 +31,14 @@ import StartOptions from "../@ohos.application.StartOptions"; * @StageModelOnly */ export default class ServiceExtensionContext extends ExtensionContext { + /** + * Service extension information. + * + * @since 9 + * @sysCap AAFwk + */ + extensionAbilityInfo: ExtensionAbilityInfo; + /** * Service extension uses this method to start a specific ability. *