diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index f5ec05467ebfeb5a60f52273680371ba8e24f7ed..1d097276ec5e3ddf4e312a722b45f2ba4fbb0959 100755 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -117,6 +117,9 @@ declare namespace media { */ function createAVPlayer(): Promise; + + + /** * Creates an AVRecorder instance. * @param { AsyncCallback } callback - used to return AVRecorder instance if the operation is successful; returns null otherwise. @@ -234,6 +237,7 @@ declare namespace media { */ function createVideoPlayer(): Promise; + /** * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder * Creates an VideoRecorder instance. @@ -276,6 +280,8 @@ declare namespace media { */ function createVideoRecorder(): Promise; + + /** * Creates a **SoundPool** instance. This API uses an asynchronous callback to return the result. * @@ -325,6 +331,8 @@ declare namespace media { */ function createSoundPool(maxStreams: number, audioRenderInfo: audio.AudioRendererInfo): Promise; + + /** * Creates a **SoundPool** instance. This API uses a promise to return the result. * @@ -462,6 +470,9 @@ declare namespace media { */ function getScreenCaptureMonitor(): Promise; + + + /** * Provides APIs for loading, unloading, playing, and stopping playing system sounds, setting the volume, * and setting the number of loops. @@ -549,6 +560,7 @@ declare namespace media { BACKGROUND = 2, } + /** * Creates an AVMetadataExtractor instance. * @returns { Promise } A Promise instance used to return AVMetadataExtractor instance @@ -588,6 +600,7 @@ declare namespace media { */ function createAVMetadataExtractor(callback: AsyncCallback): void; + /** * Creates an **AVImageGenerator** instance. This API uses a promise to return the result. * @returns { Promise } Promise used to return the result. If the operation is successful, @@ -610,6 +623,8 @@ declare namespace media { */ function createAVImageGenerator(callback: AsyncCallback): void; + + /** * Fetch media meta data or audio art picture from source. Before calling an AVMetadataExtractor method, * you must use createAVMetadataExtractor() to create an AVMetadataExtractor instance. @@ -675,6 +690,8 @@ declare namespace media { */ dataSrc ?: AVDataSrcDescriptor; + + /** * It will extract the resource to fetch media meta data info. * @param { AsyncCallback } callback - A callback instance used to return when fetchMetadata completed. @@ -714,6 +731,9 @@ declare namespace media { */ fetchMetadata(): Promise; + + + /** * It will extract the audio resource to fetch an album cover. * @param { AsyncCallback } callback - A callback instance used @@ -754,6 +774,8 @@ declare namespace media { */ fetchAlbumCover(): Promise; + + /** * Sets the network media source URL and configures request headers. * @param { string } url - The URL of the media resource. @@ -764,6 +786,7 @@ declare namespace media { */ setUrlSource(url: string, headers?: Record): void; + /** * It will decode the given video resource. Then fetch a picture * at @timeUs according the given @options and @param . @@ -782,6 +805,7 @@ declare namespace media { */ fetchFrameByTime(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams): Promise; + /** * Obtains the video timestamp corresponding to a video frame number. Only MP4 video files are supported. * @param { number } index - Video frame number. @@ -842,6 +866,274 @@ declare namespace media { * @since 12 */ release(): Promise; + + overload createAVImageGenerator { createAVImageGeneratorWithCallback, createAVImageGeneratorReturnsPromise } + /** + * Creates an **AVImageGenerator** instance. This API uses a promise to return the result. + * @returns { Promise } Promise used to return the result. If the operation is successful, + * an **AVImageGenerator** instance is returned; otherwise, **null** is returned. + * The API can be used to obtain a video thumbnail. + * @throws { BusinessError } 5400101 - No memory. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 20 + * @arkts 1.2 + */ + function createAVImageGeneratorReturnsPromise(): Promise; + + /** + * Creates an **AVImageGenerator** instance. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback } callback - Callback used to return the result. + * If the operation is successful, an **AVImageGenerator** instance is returned; otherwise, **null** is returned. + * The API can be used to obtain a video thumbnail. + * @throws { BusinessError } 5400101 - No memory. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 20 + * @arkts 1.2 + */ + function createAVImageGeneratorWithCallback(callback: AsyncCallback): void; + + + overload createAVMetadataExtractor { createAVMetadataExtractorReturnsPromise, createAVMetadataExtractorWithCallback } + /** + * Creates an **AVMetadataExtractor** instance. This API uses a promise to return the result. + * @returns { Promise } A Promise instance used to return AVMetadataExtractor instance + * if the operation is successful; returns null otherwise. + * @throws { BusinessError } 5400101 - No memory. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + function createAVMetadataExtractorReturnsPromise(): Promise; + /** + * Creates an **AVMetadataExtractor** instance. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is + * successful, **err** is **undefined** and **data** is the **AVMetadataExtractor** instance created; + * otherwise, **err** is an error object. + * @throws { BusinessError } 5400101 - No memory. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + function createAVMetadataExtractorWithCallback(callback: AsyncCallback): void; + + overload createAVPlayer { createAVPlayerWithCallback, createAVPlayerReturnsPromise } + /** + * Creates an **AVPlayer** instance. This API uses an asynchronous callback to return the result. + *
**NOTE:**
+ * You are advised to create a maximum of 16 **AVPlayer** instances for an application in both audio and video + * playback scenarios. + * + * The actual number of instances that can be created may be different. + * It depends on the specifications of the device chip in use. + * + * @param { AsyncCallback } callback - used to return the result. If the operation is successful, an + * **AVPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to play + * audio and video. + * @throws { BusinessError } 5400101 - No memory. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function createAVPlayerWithCallback(callback: AsyncCallback): void; + /** + * Creates an **AVPlayer** instance. This API uses a promise to return the result. + *
**NOTE:**
+ * You are advised to create a maximum of 16 **AVPlayer** instances for an application in both audio and video + * playback scenarios. + * + * The actual number of instances that can be created may be different. It depends on the specifications of + * the device chip in use. + * + * @returns { Promise } A Promise instance used to return the result. If the operation is successful, an + * **AVPlayer** instance is returned; **null** is returned otherwise. The instance can be used to play + * audio and video. + * @throws { BusinessError } 5400101 - No memory. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function createAVPlayerReturnsPromise(): Promise; + + overload createAVRecorder { createAVRecorderWithCallback, createAVRecorderReturnsPromise } + /** + * Creates an **AVRecorder** instance. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is successful, + * an **AVRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record audio + * and video. + * @throws { BusinessError } 5400101 - No memory. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + function createAVRecorderWithCallback(callback: AsyncCallback): void; + /** + * Creates an **AVRecorder** instance. This API uses a promise to return the result. + * @returns { Promise } Promise used to return the result. If the operation is successful, + * an **AVRecorder** instance is returned; otherwise, **null** is returned. + * The instance can be used to record audio and video. + * @throws { BusinessError } 5400101 - No memory. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function createAVRecorderReturnsPromise(): Promise; + + overload createSoundPool { createSoundPoolWithCallback, createSoundPoolReturnsPromise } + /** + * Creates a **SoundPool** instance. This API uses an asynchronous callback to return the result. + * + * **NOTE** + * - In versions earlier than API version 18, the bottom layer of the created **SoundPool** object is in singleton + * mode. Therefore, an application process can create only one **SoundPool** instance. + * - In API version 18 and later versions, the bottom layer of the created **SoundPool** object is in multiton mode. + * Therefore, an application process can create a maximum of 128 **SoundPool** instances. + * + * @param {number} maxStreams - Maximum number of streams that can be played by the **SoundPool** instance. + * The value is an integer ranging from 1 to 32. + * @param {audio.AudioRendererInfo} audioRenderInfo - Audio renderer parameters. When the **usage** parameter + * in **audioRenderInfo** is set to **STREAM_USAGE_UNKNOWN**, **STREAM_USAGE_MUSIC**, **STREAM_USAGE_MOVIE**, or + * **STREAM_USAGE_AUDIOBOOK**, the SoundPool uses the audio mixing mode when playing a short sound, without + * interrupting the playback of other audios. + * @param {AsyncCallback} callback - Callback used to return the result. If the operation is successful, a + * **SoundPool** instance is returned; otherwise, **null** is returned. + * The instance is used for loading and playback. + * @throws { BusinessError } 5400101 - No memory. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + function createSoundPoolWithCallback( + maxStreams: number, + audioRenderInfo: audio.AudioRendererInfo, + callback: AsyncCallback + ): void; + + /** + * Creates a **SoundPool** instance. This API uses a promise to return the result. + * + * **NOTE** + * - In versions earlier than API version 18, the bottom layer of the created **SoundPool** object is in singleton + * mode. Therefore, an application process can create only one **SoundPool** instance. + * - In API version 18 and later versions, the bottom layer of the created **SoundPool** object is in multiton mode. + * Therefore, an application process can create a maximum of 128 **SoundPool** instances. + * + * @param {number} maxStreams - Maximum number of streams that can be played by the **SoundPool** instance. + * The value is an integer ranging from 1 to 32. + * @param {audio.AudioRendererInfo} audioRenderInfo - Audio renderer parameters. + * @returns {Promise} Promise used to return the result. If the operation is successful, + * a **SoundPool** instance is returned; otherwise, **null** is returned. + * The instance is used for loading and playback. + * @throws { BusinessError } 5400101 - No memory. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + function createSoundPoolReturnsPromise(maxStreams: number, audioRenderInfo: audio.AudioRendererInfo): Promise; + + overload createVideoRecorder { createVideoRecorderWithCallback, createVideoRecorderReturnsPromise } + /** + * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder + * Creates an VideoRecorder instance. + * @param { AsyncCallback } callback - used to return AudioPlayer instance if the operation is successful; returns null otherwise. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400101 - No memory. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + function createVideoRecorderWithCallback(callback: AsyncCallback): void; + /** + * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder + * Creates an VideoRecorder instance. + * @returns { Promise } A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400101 - No memory. Return by promise. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + function createVideoRecorderReturnsPromise(): Promise; + + overload fetchAlbumCover { fetchAlbumCoverWithCallback, fetchAlbumCoverReturnsPromise } + /** + * Obtains the cover of the audio album. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback } callback - Callback used to return the album cover. + * to return when fetchAlbumCover completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + fetchAlbumCoverWithCallback(callback: AsyncCallback): void; + /** + * Obtains the cover of the audio album. This API uses a promise to return the result. + * @returns { Promise } Promise used to return the album cover. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + fetchAlbumCoverReturnsPromise(): Promise; + + overload fetchFrameByTime { fetchFrameByTimeReturnsPromise } + /** + * It will decode the given video resource. Then fetch a picture + * at @timeUs according the given @options and @param . + * @param { number } timeUs - The time expected to fetch picture from the video resource. + * The unit is microsecond(us). + * @param { AVImageQueryOptions } options - The time options about the relationship + * between the given timeUs and a key frame, see @AVImageQueryOptions . + * @param { PixelMapParams } param - The output pixel map format params, see @PixelMapParams . + * @returns { Promise } A Promise instance used to return the pixel map + * when fetchFrameByTime completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. + * @throws { BusinessError } 5400108 - Parameter check failed. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 20 + * @arkts 1.2 + */ + fetchFrameByTimeReturnsPromise(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams): Promise; + + overload fetchMetadata { fetchMetadataWithCallback, fetchMetadataReturnsPromise} + /** + * Obtains media metadata. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback } callback - Callback used to return the result, + * which is an **AVMetadata** instance. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + fetchMetadataWithCallback(callback: AsyncCallback): void; + /** + * Obtains media metadata. This API uses a promise to return the result. + * @returns { Promise } Promise used to return the result, which is an **AVMetadata** instance. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 20 + * @arkts 1.2 + */ + fetchMetadataReturnsPromise(): Promise; } /** @@ -1262,6 +1554,7 @@ declare namespace media { */ fdSrc ?: AVFileDescriptor; + /** * Obtains a video thumbnail. This API uses an asynchronous callback to return the result. * @param { number } timeUs - Time of the video for which a thumbnail is to be obtained, in μs. @@ -1291,6 +1584,9 @@ declare namespace media { */ fetchFrameByTime(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams): Promise; + + + /** * Supports extracting video thumbnails by proportional scaling * @param { number } timeUs - The time expected to fetch picture from the video resource. @@ -1324,6 +1620,38 @@ declare namespace media { * @since 12 */ release(): Promise; + + overload fetchFrameByTime { fetchFrameByTimeWithCallback, fetchFrameByTimeReturnsPromise } + /** + * Obtains a video thumbnail. This API uses an asynchronous callback to return the result. + * @param { number } timeUs - Time of the video for which a thumbnail is to be obtained, in μs. + * @param { AVImageQueryOptions } options - Relationship between the time passed in and the video frame. + * @param { PixelMapParams } param - Format parameters of the thumbnail to be obtained. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is + * successful, **err** is **undefined** and **data** is the **PixelMap** instance obtained; otherwise, + * **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 20 + * @arkts 1.2 + */ + fetchFrameByTimeWithCallback(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams, + callback: AsyncCallback): void; + + /** + * Obtains a video thumbnail. This API uses a promise to return the result. + * @param { number } timeUs - Time of the video for which a thumbnail is to be obtained, in μs. + * @param { AVImageQueryOptions } options - Relationship between the time passed in and the video frame. + * @param { PixelMapParams } param - Format parameters of the thumbnail to be obtained. + * @returns { Promise } Promise used to return the video thumbnail. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 20 + * @arkts 1.2 + */ + fetchFrameByTimeReturnsPromise(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams): Promise; } /** @@ -5300,6 +5628,7 @@ declare namespace media { */ prepare(config: AVRecorderConfig): Promise; + /** * Obtains the real-time configuration of this AVRecorder. * This API uses an asynchronous callback to return the result. @@ -5351,6 +5680,9 @@ declare namespace media { */ getAVRecorderConfig(): Promise; + + + /** * Obtains the surface required for recording. This API uses an asynchronous callback to return the result. * The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding video data. @@ -5407,6 +5739,8 @@ declare namespace media { */ getInputSurface(): Promise; + + /** * Get input meta surface for specified meta source type. it must be called between prepare completed and start. * @param { MetaSourceType } type - Meta source type. @@ -5666,6 +6000,7 @@ declare namespace media { */ pause(): Promise; + /** * Resume AVRecorder, it will to started state. * @param { AsyncCallback } callback - A callback instance used to return when resume completed. @@ -5732,6 +6067,41 @@ declare namespace media { */ resume(): Promise; + /** + * Resume AVRecorder, it will to started state. + * @param { AsyncCallback } callback - A callback instance used to return when resume completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 9 + */ + /** + * Resumes recording. This API uses an asynchronous callback to return the result. + * + * This API can be called only after the pause() API is called. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is successful, + * **err** is **undefined**; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.resume((err: BusinessError) => { + * if (err) { + * console.error('Failed to resume AVRecorder and error is ' + err.message); + * } else { + * console.info('Succeeded in resuming AVRecorder'); + * } + * }); + */ + + /** * Stop AVRecorder, it will to stopped state. * @param { AsyncCallback } callback - A callback instance used to return when stop completed. @@ -5928,6 +6298,7 @@ declare namespace media { */ release(): Promise; + /** * Obtains the information about the current audio capturer. * This API uses an asynchronous callback to return the result. @@ -5983,6 +6354,10 @@ declare namespace media { */ getCurrentAudioCapturerInfo(): Promise; + + + + /** * Obtains the maximum amplitude of the current audio capturer. * This API uses an asynchronous callback to return the result. @@ -6041,6 +6416,9 @@ declare namespace media { */ getAudioCapturerMaxAmplitude(): Promise; + + + /** * Obtains available encoders. This API uses an asynchronous callback to return the result. * @param { AsyncCallback> } callback - Callback used to return the result. @@ -6082,6 +6460,8 @@ declare namespace media { */ getAvailableEncoder(): Promise>; + + /** * Recorder state. * @syscap SystemCapability.Multimedia.Media.AVRecorder @@ -6278,39 +6658,363 @@ declare namespace media { * @since 12 */ off(type: 'photoAssetAvailable', callback?: Callback): void; - } - - /** - * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace. - * - * @enum { number } - * @syscap SystemCapability.Multimedia.Media.AudioRecorder - * @since 6 - * @deprecated since 8 - * @useinstead ohos.multimedia.media/media.CodecMimeType - */ - enum AudioEncoder { - /** - * Default audio encoding format, which is AMR-NB. - * @syscap SystemCapability.Multimedia.Media.AudioRecorder - * @since 6 - * @deprecated since 8 - */ - DEFAULT = 0, - - /** - * Indicates the AMR-NB audio encoding format. - * @syscap SystemCapability.Multimedia.Media.AudioRecorder - * @since 6 - * @deprecated since 8 - * @useinstead ohos.multimedia.media/media.CodecMimeType#AUDIO_AMR_NB - */ - AMR_NB = 1, + overload getAudioCapturerMaxAmplitude { getAudioCapturerMaxAmplitudeWithCallback, getAudioCapturerMaxAmplitudeReturnsPromise } /** - * Indicates the AMR-WB audio encoding format. - * @syscap SystemCapability.Multimedia.Media.AudioRecorder - * @since 6 + * Obtains the maximum amplitude of the current audio capturer. + * This API uses an asynchronous callback to return the result. + * + * This API can be called only after the **prepare()** API is called. + * If this API is called after **stop()** is successfully called, an error is reported. + * + * The return value is the maximum amplitude within the duration from the time the maximum amplitude + * is obtained last time to the current time. For example, if you have obtained the maximum amplitude at 1s + * and you call this API again at 2s, then the return value is the maximum amplitude + * within the duration from 1s to 2s. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is successful, + * **err** is **undefined** and **data** is the maximum amplitude obtained; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * let maxAmplitude: number; + * + * avRecorder.getAudioCapturerMaxAmplitude((err: BusinessError, amplitude: number) => { + * if (err) { + * console.error('Failed to get AudioCapturerMaxAmplitude and error is ' + err.message); + * } else { + * console.info('Succeeded in getting AudioCapturerMaxAmplitude'); + * maxAmplitude = amplitude; + * } + * }); + */ + getAudioCapturerMaxAmplitudeWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the maximum amplitude of the current audio capturer. This API uses a promise to return the result. + * + * This API can be called only after the **prepare()** API is called. + * If this API is called after **stop()** is successfully called, an error is reported. + * + * The return value is the maximum amplitude within the duration from the time the maximum amplitude + * is obtained last time to the current time. For example, if you have obtained the maximum amplitude + * at 1s and you call this API again at 2s, then the return value is the maximum amplitude + * within the duration from 1s to 2s. + * @returns { Promise } Promise used to return the maximum amplitude obtained. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * let maxAmplitude: number; + * + * avRecorder.getAudioCapturerMaxAmplitude().then((amplitude: number) => { + * console.info('Succeeded in getting AudioCapturerMaxAmplitude'); + * maxAmplitude = amplitude; + * }).catch((err: BusinessError) => { + * console.error('Failed to get AudioCapturerMaxAmplitude and catch error is ' + err.message); + * }); + */ + getAudioCapturerMaxAmplitudeReturnsPromise(): Promise; + + overload getAvailableEncoder { getAvailableEncoderWithCallback, getAvailableEncoderReturnsPromise } + /** + * Obtains available encoders. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback> } callback - Callback used to return the result. + * If the operation is successful, **err** is **undefined** and **data** is the available encoders obtained; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * let encoderInfo: media.EncoderInfo; + * + * avRecorder.getAvailableEncoder((err: BusinessError, info: media.EncoderInfo[]) => { + * if (err) { + * console.error('Failed to get AvailableEncoder and error is ' + err.message); + * } else { + * console.info('Succeeded in getting AvailableEncoder'); + * encoderInfo = info[0]; + * } + * }); + */ + getAvailableEncoderWithCallback(callback: AsyncCallback>): void; + + /** + * Obtains available encoders. This API uses an asynchronous callback to return the result. + * @returns { Promise> } Promise used to return the information about the available encoders. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * let encoderInfo: media.EncoderInfo; + * + * avRecorder.getAvailableEncoder().then((info: media.EncoderInfo[]) => { + * console.info('Succeeded in getting AvailableEncoder'); + * encoderInfo = info[0]; + * }).catch((err: BusinessError) => { + * console.error('Failed to get AvailableEncoder and catch error is ' + err.message); + * }); + */ + getAvailableEncoderReturnsPromise(): Promise>; + + overload getAVRecorderConfig { getAVRecorderConfigWithCallback, getAVRecorderConfigReturnsPromise } + /** + * Obtains the real-time configuration of this AVRecorder. + * This API uses an asynchronous callback to return the result. + * This API can be called only after prepare() is called. + * @param { AsyncCallback } callback - Callback used to return the result. + * If the operation is successful, **err** is **undefined** and **data** is the real-time configuration obtained; + * otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * let avConfig: media.AVRecorderConfig; + * + * avRecorder.getAVRecorderConfig((err: BusinessError, config: media.AVRecorderConfig) => { + * if (err) { + * console.error('Failed to get avConfig and error is ' + err.message); + * } else { + * console.info('Succeeded in getting AVRecorderConfig'); + * avConfig = config; + * } + * }); + */ + getAVRecorderConfigWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the real-time configuration of this AVRecorder. This API uses a promise to return the result. + * This API can be called only after prepare() is called. + * @returns { Promise } Promise used to return the real-time configuration. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * let avConfig: media.AVRecorderConfig; + * + * avRecorder.getAVRecorderConfig().then((config: media.AVRecorderConfig) => { + * console.info('Succeeded in getting AVRecorderConfig'); + * avConfig = config; + * }).catch((err: BusinessError) => { + * console.error('Failed to get AVRecorderConfig and catch error is ' + err.message); + * }); + */ + getAVRecorderConfigReturnsPromise(): Promise; + + overload getCurrentAudioCapturerInfo {getCurrentAudioCapturerInfoWithCallback, getCurrentAudioCapturerInfoReturnsPromise } + /** + * Obtains the information about the current audio capturer. + * This API uses an asynchronous callback to return the result. + * + * This API can be called only after the **prepare()** API is called. + * If this API is called after **stop()** is successfully called, an error is reported. + * @param { AsyncCallback } callback - Callback used to return the result. + * If the operation is successful, **err** is **undefined** and **data** is the + * **audio.AudioCapturerChangeInfo** object obtained; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400103 - I/O error. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { audio } from '@kit.AudioKit'; + * + * let currentCapturerInfo: audio.AudioCapturerChangeInfo; + * + * avRecorder.getCurrentAudioCapturerInfo((err: BusinessError, capturerInfo: audio.AudioCapturerChangeInfo) => { + * if (err) { + * console.error('Failed to get CurrentAudioCapturerInfo and error is ' + err.message); + * } else { + * console.info('Succeeded in getting CurrentAudioCapturerInfo'); + * currentCapturerInfo = capturerInfo; + * } + * }); + */ + getCurrentAudioCapturerInfoWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the information about the current audio capturer. This API uses a promise to return the result. + * + * This API can be called only after the **prepare()** API is called. + * If this API is called after **stop()** is successfully called, an error is reported. + * @returns { Promise } Promise used to return the audio capturer information. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400103 - I/O error. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { audio } from '@kit.AudioKit'; + * + * let currentCapturerInfo: audio.AudioCapturerChangeInfo; + * + * avRecorder.getCurrentAudioCapturerInfo().then((capturerInfo: audio.AudioCapturerChangeInfo) => { + * console.info('Succeeded in getting CurrentAudioCapturerInfo'); + * currentCapturerInfo = capturerInfo; + * }).catch((err: BusinessError) => { + * console.error('Failed to get CurrentAudioCapturerInfo and catch error is ' + err.message); + * }); + */ + getCurrentAudioCapturerInfoReturnsPromise(): Promise; + + overload getInputSurface { getInputSurfaceWithCallback, getInputSurfaceReturnsPromise } + /** + * Obtains the surface required for recording. This API uses an asynchronous callback to return the result. + * The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding video data. + * + * Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp + * must be based on the system startup time. + * + * This API can be called only after the prepare() API is called. + * @param { AsyncCallback } callback - Callback used to return the result. If the operation is successful, + * **err** is **undefined** and **data** is the surface ID obtained; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * let surfaceID: string; // The surfaceID is transferred to the camera API to create a videoOutput instance. + * + * avRecorder.getInputSurface((err: BusinessError, surfaceId: string) => { + * if (err) { + * console.error('Failed to do getInputSurface and error is ' + err.message); + * } else { + * console.info('Succeeded in doing getInputSurface'); + * surfaceID = surfaceId; + * } + * }); + */ + getInputSurfaceWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the surface required for recording. This API uses a promise to return the result. + * The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding video data. + * + * Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp must be based on the system startup time. + * + * This API can be called only after the prepare() API is called. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * let surfaceID: string; // The surfaceID is transferred to the camera API to create a videoOutput instance. + * + * avRecorder.getInputSurface().then((surfaceId: string) => { + * console.info('Succeeded in getting InputSurface'); + * surfaceID = surfaceId; + * }).catch((err: BusinessError) => { + * console.error('Failed to get InputSurface and catch error is ' + err.message); + * }); + */ + getInputSurfaceReturnsPromise(): Promise; + + overload resume { resumeWithCallback, resumeReturnsPromise } + /** + * Resumes recording. This API uses a promise to return the result. + * + * This API can be called only after the pause() API is called. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.resume().then(() => { + * console.info('Succeeded in resuming AVRecorder'); + * }).catch((err: BusinessError) => { + * console.error('Failed to resume AVRecorder failed and catch error is ' + err.message); + * }); + */ + resumeWithCallback(callback: AsyncCallback): void; + /** + * Resumes recording. This API uses a promise to return the result. + * + * This API can be called only after the pause() API is called. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.resume().then(() => { + * console.info('Succeeded in resuming AVRecorder'); + * }).catch((err: BusinessError) => { + * console.error('Failed to resume AVRecorder failed and catch error is ' + err.message); + * }); + */ + resumeReturnsPromise(): Promise; + } + + /** + * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace. + * + * @enum { number } + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 6 + * @deprecated since 8 + * @useinstead ohos.multimedia.media/media.CodecMimeType + */ + enum AudioEncoder { + /** + * Default audio encoding format, which is AMR-NB. + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 6 + * @deprecated since 8 + */ + DEFAULT = 0, + + /** + * Indicates the AMR-NB audio encoding format. + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 6 + * @deprecated since 8 + * @useinstead ohos.multimedia.media/media.CodecMimeType#AUDIO_AMR_NB + */ + AMR_NB = 1, + + /** + * Indicates the AMR-WB audio encoding format. + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 6 * @deprecated since 8 * @useinstead ohos.multimedia.media/media.CodecMimeType#AUDIO_AMR_WB */ @@ -6759,6 +7463,8 @@ declare namespace media { * @since 12 */ prepare(config: VideoRecorderConfig): Promise; + + /** * get input surface.it must be called between prepare completed and start. * @param { AsyncCallback } callback - Callback used to return the input surface id in string. @@ -6803,6 +7509,9 @@ declare namespace media { * @since 12 */ getInputSurface(): Promise; + + + /** * Starts video recording. * @param { AsyncCallback } callback - A callback instance used to return when start completed. @@ -6891,50 +7600,8 @@ declare namespace media { * @since 12 */ pause(): Promise; - /** - * Resumes video recording. - * @param { AsyncCallback } callback - A callback instance used to return when resume completed. - * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. - * @throws { BusinessError } 5400103 - I/O error. Return by callback. - * @throws { BusinessError } 5400105 - Service died. Return by callback. - * @syscap SystemCapability.Multimedia.Media.VideoRecorder - * @systemapi - * @since 9 - */ - /** - * Resumes video recording. - * @param { AsyncCallback } callback - A callback instance used to return when resume completed. - * @throws { BusinessError } 202 - Not System App. - * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. - * @throws { BusinessError } 5400103 - I/O error. Return by callback. - * @throws { BusinessError } 5400105 - Service died. Return by callback. - * @syscap SystemCapability.Multimedia.Media.VideoRecorder - * @systemapi - * @since 12 - */ - resume(callback: AsyncCallback): void; - /** - * Resumes video recording. - * @returns { Promise } A Promise instance used to return when resume completed. - * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. - * @throws { BusinessError } 5400103 - I/O error. Return by promise. - * @throws { BusinessError } 5400105 - Service died. Return by promise. - * @syscap SystemCapability.Multimedia.Media.VideoRecorder - * @systemapi - * @since 9 - */ - /** - * Resumes video recording. - * @returns { Promise } A Promise instance used to return when resume completed. - * @throws { BusinessError } 202 - Not System App. - * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. - * @throws { BusinessError } 5400103 - I/O error. Return by promise. - * @throws { BusinessError } 5400105 - Service died. Return by promise. - * @syscap SystemCapability.Multimedia.Media.VideoRecorder - * @systemapi - * @since 12 - */ - resume(): Promise; + + /** * Stops video recording. * @param { AsyncCallback } callback A callback instance used to return when stop completed. @@ -7096,6 +7763,62 @@ declare namespace media { * @since 9 */ readonly state: VideoRecordState; + + overload getInputSurface { getInputSurfaceWithCallback, getInputSurfaceReturnsPromise } + /** + * get input surface.it must be called between prepare completed and start. + * @param { AsyncCallback } callback - Callback used to return the input surface id in string. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400103 - I/O error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + getInputSurfaceWithCallback(callback: AsyncCallback): void; + /** + * get input surface. it must be called between prepare completed and start. + * @returns { Promise } A Promise instance used to return the input surface id in string. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400103 - I/O error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + getInputSurfaceReturnsPromise(): Promise; + + overload resume { resumeWithCallback, resumeReturnsPromise } + /** + * Resumes video recording. + * @param { AsyncCallback } callback - A callback instance used to return when resume completed. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400103 - I/O error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + resumeWithCallback(callback: AsyncCallback): void; + /** + * Resumes video recording. + * @returns { Promise } A Promise instance used to return when resume completed. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400103 - I/O error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 20 + * @arkts 1.2 + */ + resumeReturnsPromise(): Promise; } /** @@ -9864,6 +10587,8 @@ declare namespace media { */ pause(): Promise; + + /** * Resumes transcoding. This API uses a promise to return the result. * @@ -9987,6 +10712,21 @@ declare namespace media { * @since 12 */ off(type:'progressUpdate', callback?: Callback):void; + + overload resume { resumeReturnsPromise } + /** + * Resumes transcoding. This API uses a promise to return the result. + * + * This API can be called only after the [pause()]{@link AVTranscoder.pause} API is called. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + resumeReturnsPromise(): Promise; } /**