diff --git a/api/@ohos.multimedia.drm.d.ts b/api/@ohos.multimedia.drm.d.ts index bcd02832a23ef9621a25fc8d13aaa530bc2f2898..996e0e3db43e2b621cdb5a6f3045cee590c89b98 100644 --- a/api/@ohos.multimedia.drm.d.ts +++ b/api/@ohos.multimedia.drm.d.ts @@ -1184,6 +1184,62 @@ declare namespace drm { */ function isMediaKeySystemSupported(name: string): boolean; + overload isMediaKeySystemSupported { + isMediaKeySystemSupportedWithNameMimeTypeLevel, isMediaKeySystemSupportedWithNameMimeType, + isMediaKeySystemSupportedWithName + } + + /** + * Judge whether a system that specifies name, mimetype and content protection level is supported. + * @param { string } name - Used to point a Digital Right Management solution. + * @param { string } mimeType - Used to specifies the media type. + * @param { ContentProtectionLevel } level - Used to specifies the ContentProtectionLevel. + * @returns { boolean } Whether these conditions will be met. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @throws { BusinessError } 24700201 - Fatal service error, for example, service died. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function isMediaKeySystemSupportedWithNameMimeTypeLevel(name: string, mimeType: string, level: ContentProtectionLevel): boolean; + + /** + * Judge whether a system that specifies name, mimetype is supported. + * @param { string } name - Used to point a Digital Right Management solution. + * @param { string } mimeType - Used to specifies the media type. + * @returns { boolean } Whether these conditions will be met. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @throws { BusinessError } 24700201 - Fatal service error, for example, service died. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function isMediaKeySystemSupportedWithNameMimeType(name: string, mimeType: string): boolean; + + /** + * Judge whether a system that specifies name is supported. + * @param { string } name - Used to point a Digital Right Management solution. + * @returns { boolean } Whether these conditions will be met. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified. 2.Parameter verification failed, + * the param name's length is zero or too big(exceeds 4096 Bytes). + * @throws { BusinessError } 24700101 - All unknown errors. + * @throws { BusinessError } 24700201 - Fatal service error, for example, service died. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function isMediaKeySystemSupportedWithName(name: string): boolean; + /** * Manages and record MediaKeySessions. Before calling an MediaKeySystem method, we must use getMediaKeySystem * to get a MediaKeySystem instance, then we can call functions. @@ -1535,6 +1591,38 @@ declare namespace drm { */ createMediaKeySession(): MediaKeySession; + overload createMediaKeySession { createMediaKeySessionWithLevel, createMediaKeySession } + + /** + * Create a MediaKeySession instance with level. + * @param { ContentProtectionLevel } level - Used to specify the content protection level. + * @returns { MediaKeySession } A MediaKeySession instance. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified. 2.The param level exceeds reasonable range, + * please use value in ContentProtectionLevel. + * @throws { BusinessError } 24700101 - All unknown errors. + * @throws { BusinessError } 24700104 - Meet max MediaKeySession num limit. + * @throws { BusinessError } 24700201 - Fatal service error, for example, service died. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + createMediaKeySessionWithLevel(level: ContentProtectionLevel): MediaKeySession; + + /** + * Create a MediaKeySession instance. + * @returns { MediaKeySession } A MediaKeySession instance. + * @throws { BusinessError } 24700101 - All unknown errors. + * @throws { BusinessError } 24700104 - Meet max MediaKeySession num limit. + * @throws { BusinessError } 24700201 - Fatal service error, for example, service died. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + createMediaKeySession(): MediaKeySession; + /** * Create a MediaKeySession instance. * @returns { MediaKeySession | undefined } A MediaKeySession instance or undefined @@ -2125,6 +2213,83 @@ declare namespace drm { */ on(type: 'keysChange', callback: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void; + overload on { onKeyRequired, onKeyExpired, onVendorDefined, onExpirationUpdate, onKeysChange } + + /** + * Register keyRequired event. + * @param { 'keyRequired' } type - Type of the drm event to listen for. + * @param { function } callback used to listen for the key required event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onKeyRequired(type: 'keyRequired', callback: (eventInfo: EventInfo) => void): void; + + /** + * Register keyExpired event. + * @param { 'keyExpired' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for the key required event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onKeyExpired(type: 'keyExpired', callback: (eventInfo: EventInfo) => void): void; + + /** + * Register vendorDefined event. + * @param { 'vendorDefined' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for the vendor defined event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onVendorDefined(type: 'vendorDefined', callback: (eventInfo: EventInfo) => void): void; + + /** + * Register expirationUpdate event. + * @param { 'expirationUpdate' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for expiration update event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onExpirationUpdate(type: 'expirationUpdate', callback: (eventInfo: EventInfo) => void): void; + + /** + * Register keysChange event. + * @param { 'keysChange' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for keys change event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onKeysChange(type: 'keysChange', callback: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void; + /** * Unregister keysChange event. * @param { 'keysChange' } type - Type of the drm event to listen for. @@ -2151,6 +2316,82 @@ declare namespace drm { */ off(type: 'keysChange', callback?: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void; + overload off { offKeyRequired, offKeyExpired, offVendorDefined, offExpirationUpdate, offKeysChange } + + /** + * Unregister keyRequired event. + * @param { 'keyRequired' } type - Type of the drm event to listen for. + * @param { function } callback used to listen for the key required event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offKeyRequired(type: 'keyRequired', callback?: (eventInfo: EventInfo) => void): void; + + /** + * Unregister keyExpired event. + * @param { 'keyExpired' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for the key required event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offKeyExpired(type: 'keyExpired', callback?: (eventInfo: EventInfo) => void): void; + + /** + * Unregister vendorDefined event. + * @param { 'vendorDefined' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for the vendor defined event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offVendorDefined(type: 'vendorDefined', callback?: (eventInfo: EventInfo) => void): void; + + /** + * Unregister expirationUpdate event. + * @param { 'expirationUpdate' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for expiration update event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offExpirationUpdate(type: 'expirationUpdate', callback?: (eventInfo: EventInfo) => void): void; + + /** + * Unregister keysChange event. + * @param { 'keysChange' } type - Type of the drm event to listen for. + * @param { function } callback - Used to listen for keys change event. + * @throws { BusinessError } 401 - The parameter check failed. Possibly because: + * 1.Mandatory parameters are left unspecified or too many parameters. 2.Incorrect parameter types. + * 3.Parameter verification failed. + * @throws { BusinessError } 24700101 - All unknown errors. + * @syscap SystemCapability.Multimedia.Drm.Core + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offKeysChange(type: 'keysChange', callback?: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void; /** * Release the resource before the session gonna be unused. * @throws { BusinessError } 24700101 - All unknown errors. diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index a20f26902b78630761d6d32bdc4f7587912f77e3..c9d238e0be86f4d0cae9173600e5eb30ebae5ade 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -1155,6 +1155,28 @@ declare namespace media { * @arkts 1.1&1.2 */ release(): Promise; + + overload release { releaseWithCallback, releaseReturnsPromise }; + /** + * Releases this **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**; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 12 + */ + releaseWithCallback(callback: AsyncCallback): void; + + /** + * Releases this **AVMetadataExtractor** instance. This API uses a promise to return the result. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @crossplatform + * @since 12 + */ + releaseReturnsPromise(): Promise; } /** @@ -1686,6 +1708,26 @@ declare namespace media { * @arkts 1.1&1.2 */ release(): Promise; + + overload release { releaseWithCallback, releaseReturnsPromise }; + /** + * Releases this **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, + * **err** is **undefined**; otherwise, **err** is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 12 + */ + releaseWithCallback(callback: AsyncCallback): void; + + /** + * Releases this **AVImageGenerator** instance. This API uses a promise to return the result. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 12 + */ + releaseReturnsPromise(): Promise; } /** @@ -4469,152 +4511,964 @@ declare namespace media { * @arkts 1.1&1.2 */ off(type:'superResolutionChanged', callback?: OnSuperResolutionChanged): void; - } - - /** - * Provides player statistic info. - * - * @typedef PlaybackInfo - * @syscap SystemCapability.Multimedia.Media.Core - * @since 12 - */ - interface PlaybackInfo { + overload prepare { prepareWithCallback,prepareReturnsPromise }; /** - * key:value pair, key see @PlaybackInfoKey. - * @syscap SystemCapability.Multimedia.Media.Core + * Prepare audio/video playback, it will request resource for playing. This API can be called only + * when the AVPlayer is in the initialized state. + * + *

If your application frequently switches between short videos, you can create multiple AVPlayer + * objects to prepare the next video in advance, thereby improving the switching performance. + * For details, see [Smooth Switchover Between Online Short Videos]{@link + * https://developer.huawei.com/consumer/en/doc/best-practices/bpta-smooth-switching}.

+ * + * @param { AsyncCallback } callback used to return the result when prepare completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400106 - Unsupported format. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice * @since 12 */ - [key:string]: Object; - } - - /** - * Provides the container definition for media description key-value pairs. - * - * @typedef { Record } - * @syscap SystemCapability.Multimedia.Media.Core - * @since 20 - * @arkts 1.2 - */ - type PlaybackInfo = Record; - - /** - * Enumerates statistics info keys for player. - * - * @enum { string } - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 - */ - enum PlaybackInfoKey { + prepareWithCallback(callback: AsyncCallback): void; /** - * IP address of current network stream. - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * Prepare audio/video playback, it will request resource for playing. This API can be called + * only when the AVPlayer is in the initialized state. + * + *

If your application frequently switches between short videos, you can create multiple AVPlayer + * objects to prepare the next video in advance, thereby improving the switching performance. + * For details, see [Smooth Switchover Between Online Short Videos]{@link + * https://developer.huawei.com/consumer/en/doc/best-practices/bpta-smooth-switching}.

+ * + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400106 - Unsupported format. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - SERVER_IP_ADDRESS = 'server_ip_address', + prepareReturnsPromise(): Promise; + overload play { playWithCallback, playReturnsPromise}; /** - * Average download rate during playing except for suspend downloading. - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * Play audio/video playback. This API can be called only when the AVPlayer is in the prepared, paused or completed state. + * @param { AsyncCallback } callback used to return the result when play completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - AVG_DOWNLOAD_RATE = 'average_download_rate', - + playWithCallback(callback: AsyncCallback): void; /** - * Current download rate of the last second except for suspend downloading. - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * Play audio/video playback. This API can be called only when the AVPlayer is in the prepared, paused or completed state. + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - DOWNLOAD_RATE = 'download_rate', + playReturnsPromise(): Promise; + overload pause { pauseWithCallback, pauseReturnsPromise } /** - * Boolean value, true for current is downloading, false for suspend downloading. - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * Pause audio/video playback. This API can be called only when the AVPlayer is in the playing state. + * @param { AsyncCallback } callback used to return the result when pause completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - IS_DOWNLOADING = 'is_downloading', - + pauseWithCallback(callback: AsyncCallback): void; /** - * Cached duration in milliseconds. - * @syscap SystemCapability.Multimedia.Media.Core - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * Pause audio/video playback. This API can be called only when the AVPlayer is in the playing state. + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - BUFFER_DURATION = 'buffer_duration', - } + pauseReturnsPromise(): Promise; - /** - * Enumerates ErrorCode types, return in BusinessError::code - * - * @enum { number } - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode - */ - enum MediaErrorCode { + overload release { releaseWithCallback, releaseReturnsPromise}; /** - * operation success. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OK + * Releases resources used for AVPlayer. This API can be called when the AVPlayer is in any state except released. + * @param { AsyncCallback } callback used to return the result when release completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - MSERR_OK = 0, - + releaseWithCallback(callback: AsyncCallback): void; /** - * malloc or new memory failed. maybe system have no memory. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_NO_MEMORY + * Releases resources used for AVPlayer. This API can be called when the AVPlayer is in any state except released. + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 12 */ - MSERR_NO_MEMORY = 1, + releaseReturnsPromise(): Promise; + overload reset { resetWithCallBack ,resetReturnPromise }; /** - * no permission for the operation. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OPERATE_NOT_PERMIT + * Reset AVPlayer, it will be set to idle state and can set src again. This API can be called only when + * the AVPlayer is in the initialized, prepared, playing, paused, completed, stopped or error state. + * @param { AsyncCallback } callback used to return the result when reset completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 */ - MSERR_OPERATION_NOT_PERMIT = 2, - + resetWithCallBack(callback: AsyncCallback): void; /** - * invalid argument. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER + * Reset AVPlayer, it will be set to idle state and can set src again. This API can be called only when + * the AVPlayer is in the initialized, prepared, playing, paused, completed, stopped or error state. + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 */ - MSERR_INVALID_VAL = 3, + resetReturnPromise(): Promise; + overload stop { stopWithCallBack , stopReturnPromise }; /** - * an I/O error occurred. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_IO + * Stop audio/video playback. This API can be called only when the AVPlayer is in the prepared, + * playing, paused or completed state. + * @param { AsyncCallback } callback used to return the result when stop completed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 */ - MSERR_IO = 4, + stopWithCallBack(callback: AsyncCallback): void; /** - * operation time out. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 - * @deprecated since 11 - * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_TIMEOUT + * Stop audio/video playback. This API can be called only when the AVPlayer is in the prepared, + * playing, paused or completed state. + * @returns { Promise } A Promise instance used to return the operation result. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 */ - MSERR_TIMEOUT = 5, + stopReturnPromise(): Promise; + overload off { + offMediaKeySystemInfoUpdate, offStateChange, offVolumeChange, offEndOfStream, offSeekDone, + offSpeedDone, offPlaybackRateDone, offBitrateDone, offTimeUpdate, offDurationUpdate, + offBufferingUpdate, offStartRenderFrame, offVideoSizeChange, offAudioInterrupt, offAvailableBitrates, + offError, offAudioOutputDeviceChangeWithInfo, offSubtitleUpdate, offTrackChange, offTrackInfoUpdate, + offAmplitudeUpdate, offSeiMessageReceived, offSuperResolutionChanged + }; /** - * unknown error. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 8 + * Unregister listens for mediaKeySystemInfoUpdate events. + * @param { 'mediaKeySystemInfoUpdate' } type - Type of the event to listen for. + * @param { Callback> } callback - Callback for event. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offMediaKeySystemInfoUpdate(type: 'mediaKeySystemInfoUpdate', callback?: Callback>): void; + /** + * Unregister listens for media playback stateChange event. + * @param { 'stateChange' } type - Type of the playback event to listen for. + * @param { OnAVPlayerStateChangeHandle } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offStateChange(type: 'stateChange', callback?: OnAVPlayerStateChangeHandle): void; + /** + * Unsubscribes from the event that checks whether the volume is successfully set. + * @param { 'volumeChange' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the effective volume. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offVolumeChange(type: 'volumeChange', callback?: Callback): void; + /** + * Unregister listens for media playback endOfStream event. + * @param { 'endOfStream' } type - Type of the playback event to listen for. + * @param { Callback } [callback] - Callback used to listen for the playback end of stream. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offEndOfStream(type: 'endOfStream', callback?: Callback): void; + /** + * Unsubscribes from the event that checks whether the seek operation takes effect. + * @param { 'seekDone' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the time position requested by the user. + * + * For video playback, SeekMode may cause the actual position to be different from that requested by the user. + * The exact position can be obtained from the currentTime attribute. The time in this callback only means + * that the requested seek operation is complete. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offSeekDone(type: 'seekDone', callback?: Callback): void; + /** + * Unsubscribes from the event that checks whether the playback speed is successfully set. + * @param { 'speedDone' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to return the result. When the call of + * setSpeed is successful, the effective speed mode is reported. For details, see {@link #PlaybackSpeed}. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offSpeedDone(type: 'speedDone', callback?: Callback): void; + /** + * Unregister listens for media playbackRateDone event. + * @param { 'playbackRateDone' } type - Type of the playback event to listen for. + * @param { OnPlaybackRateDone } callback - Callback used to listen for the playbackRateDone event. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offPlaybackRateDone(type: 'playbackRateDone', callback?: OnPlaybackRateDone): void; + /** + * Unsubscribes from the event that checks whether the bit rate is successfully set. + * @param { 'bitrateDone' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the effective bit rate. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offBitrateDone(type: 'bitrateDone', callback?: Callback): void; + /** + * Unsubscribes from playback position changes. + * @param { 'timeUpdate' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to return the current time. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offTimeUpdate(type: 'timeUpdate', callback?: Callback): void; + /** + * Unsubscribes from media asset duration changes. + * @param { 'durationUpdate' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to return the resource duration. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offDurationUpdate(type: 'durationUpdate', callback?: Callback): void; + /** + * Unsubscribes from audio and video buffer changes. + * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. + * @param { OnBufferingUpdateHandler } callback - Callback invoked when the event is triggered., + * and return BufferingInfoType and the value. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offBufferingUpdate(type: 'bufferingUpdate', callback?: OnBufferingUpdateHandler): void; + /** + * Unregister listens for start render video frame events. + * @param { 'startRenderFrame' } type - Type of the playback event to listen for. + * @param { Callback } [callback] - Callback used to listen for the playback event return . + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offStartRenderFrame(type: 'startRenderFrame', callback?: Callback): void; + /** + * Unsubscribes from video size changes. + * @param { 'videoSizeChange' } type - Type of the playback event to listen for. + * @param { OnVideoSizeChangeHandler } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offVideoSizeChange(type: 'videoSizeChange', callback?: OnVideoSizeChangeHandler): void; + /** + * Unregister listens for audio interrupt event, refer to {@link #audio.InterruptEvent} + * @param { 'audioInterrupt' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to listen for the playback event return audio interrupt info. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offAudioInterrupt(type: 'audioInterrupt', callback?: Callback): void; + /** + * Unregister listens for available bitrate list collect completed events for HLS protocol stream playback. + * This event will be reported after the {@link #prepare} called. + * @param { 'availableBitrates' } type - Type of the playback event to listen for. + * @param { Callback> } callback - Callback used to listen for the playback event return available bitrate list. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offAvailableBitrates(type: 'availableBitrates', callback?: Callback>): void; + /** + * Unsubscribes from AVPlayer errors. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * @param { ErrorCallback } callback - Callback used to return the error code ID and error message. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offError(type: 'error', callback?: ErrorCallback): void; + /** + * Unsubscribes from audio stream output device changes and reasons. This API uses an asynchronous callback + * to return the result. + * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. + * @param { Callback } callback - Callback used to return the output device + * descriptor of the current audio stream and the change reason. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. 3.Parameter verification failed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offAudioOutputDeviceChangeWithInfo(type: 'audioOutputDeviceChangeWithInfo', callback?: Callback): void; + /** + * Unsubscribes from subtitle update events. + * @param { 'subtitleUpdate' } type - Type of the event to listen for. + * @param { Callback } callback - Callback that has been registered to listen for subtitle + * update events. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offSubtitleUpdate(type: 'subtitleUpdate', callback?: Callback): void; + /** + * Unsubscribes from track change events. + * @param { 'trackChange' } type - Type of the event to listen for. + * The event is triggered when the track changes. + * @param { OnTrackChangeHandler } callback - Callback that has been registered to listen for track changes. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offTrackChange(type: 'trackChange', callback?: OnTrackChangeHandler): void; + /** + * Unsubscribes from track information update events. + * @param { 'trackInfoUpdate' } type - Type of the event to listen for. + * The event is triggered when the track information is updated. + * @param { Callback> } callback - Callback that has been registered to listen for track + * information updates. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offTrackInfoUpdate(type: 'trackInfoUpdate', callback?: Callback>): void; + /** + * Unsubscribes from update events of the maximum amplitude. + * @param { 'amplitudeUpdate' } type - Type of the event to listen for. + * The event is triggered when the amplitude changes. + * @param { Callback> } callback - Callback that has been registered to listen for amplitude updates. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since arkts {'1.1':'13','1.2':'20'} + * @arkts 1.1&1.2 + */ + offAmplitudeUpdate(type: 'amplitudeUpdate', callback?: Callback>): void; + /** + * Unsubscribes from the events indicating that an SEI message is received. + * @param { 'seiMessageReceived' } type - Type of the playback event to listen for. + * The event is triggered when an SEI message is received. + * @param { Array } [payloadTypes] - The payload types of the SEI message. + * Null means unsubscribe all payload types. + + * @param { OnSeiMessageHandle } [callback] - Callback used to listen for SEI message events and receive the + * subscribed-to payload types. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offSeiMessageReceived(type: 'seiMessageReceived', payloadTypes?: Array, callback?: OnSeiMessageHandle): void; + /** + * Unsubscribes from the event indicating that super resolution is enabled or disabled. + * @param { 'superResolutionChanged' } type - Type of the super-resolution event to listen for. + * The event is triggered when super resolution is enabled or disabled. + * @param { OnSuperResolutionChanged } callback - Callback used to listen for the super-resolution changed event. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offSuperResolutionChanged(type:'superResolutionChanged', callback?: OnSuperResolutionChanged): void; + + overload getTrackDescription { getTrackDescriptionWithCallback, getTrackDescriptionWithPromise }; + /** + * Obtains the audio and video track information. This API can be called only when the AVPlayer is in the prepared, + * playing, or paused state. To obtain information about all audio and video tracks, this API must be called after + * the data loading callback is triggered. This API uses an asynchronous callback to return the result. + * @param { AsyncCallback> } callback - Async callback return track info in MediaDescription. + * If the operation is successful, err is undefined and data is the MediaDescription array obtained; + * otherwise, err is an error object. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getTrackDescriptionWithCallback(callback: AsyncCallback>): void; + /** + * Obtains the audio and video track information. This API can be called only when the AVPlayer is in the prepared, + * playing, or paused state. This API uses a promise to return the result. + * @returns { Promise> } A Promise instance used to return the track info in MediaDescription. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + getTrackDescriptionWithPromise(): Promise>; + + overload on { + onMediaKeySystemInfoUpdate, onStateChange, onVolumeChange, onEndOfStream, onSeekDone, + onSpeedDone, onPlaybackRateDone, onBitrateDone, onTimeUpdate, onDurationUpdate, + onBufferingUpdate, onStartRenderFrame, onVideoSizeChange, onAudioInterrupt, onAvailableBitrates, + onError, onAudioOutputDeviceChangeWithInfo, onSubtitleUpdate, onTrackChange, onTrackInfoUpdate, + onAmplitudeUpdate, onSeiMessageReceived, onSuperResolutionChanged + }; + /** + * Register listens for mediaKeySystemInfoUpdate events. + * @param { 'mediaKeySystemInfoUpdate' } type - Event type, which is **'mediaKeySystemInfoUpdate'** in this case. + * This event is triggered when the copyright protection information of the media asset being played changes. + * @param { Callback> } callback - Callback invoked when the event is triggered. + * It reports a **MediaKeySystemInfo** array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onMediaKeySystemInfoUpdate(type: 'mediaKeySystemInfoUpdate', callback: Callback>): void; + + /** + * Register listens for media playback stateChange event. + * @param { 'stateChange' } type - Event type, which is **'stateChange'** in this case. + * This event can be triggered by both user operations and the system. + * @param { OnAVPlayerStateChangeHandle } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onStateChange(type: 'stateChange', callback: OnAVPlayerStateChangeHandle): void; + + /** + * Subscribes to the event to check whether the volume is successfully set. + * @param { 'volumeChange' } type - This event is triggered each time **setVolume()** is called. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the effective volume. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onVolumeChange(type: 'volumeChange', callback: Callback): void; + + /** + * Subscribes to the event that indicates the end of the stream being played. If {@link #loop} = true is set, + * the AVPlayer seeks to the beginning of the stream and plays the stream again. If loop is not set, + * the completed state is reported through the {@link #stateChange} event. + * @param { 'endOfStream' } type - Type of the playback event to listen for. This event is triggered + * when the AVPlayer finishes playing the media asset. + * @param { Callback } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onEndOfStream(type: 'endOfStream', callback: Callback): void; + + /** + * Subscribes to the event to check whether the seek operation takes effect. + * @param { 'seekDone' } type - Type of the playback event to listen for. This event is triggered each time + * **seek()** is called, except in SEEK_CONTINUOUS mode. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the time position requested by the user. + * + * For video playback, {@link #SeekMode} may cause the actual position to be different from that requested by + * the user.The exact position can be obtained from the currentTime attribute. The time in this callback + * only means that the requested seek operation is complete. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onSeekDone(type: 'seekDone', callback: Callback): void; + + /** + * Subscribes to the event to check whether the playback speed is successfully set. + * @param { 'speedDone' } type - Type of the playback event to listen for. + * This event is triggered each time **setSpeed()** is called. + * @param { Callback } callback - Callback used to return the result. When the call of + * setSpeed is successful, the effective speed mode is reported. For details, see {@link #PlaybackSpeed}. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onSpeedDone(type: 'speedDone', callback: Callback): void; + + /** + * Register listens for media playbackRateDone event. + * @param { 'playbackRateDone' } type - Type of the playback event to listen for. + * @param { OnPlaybackRateDone } callback - Callback used to listen for the playbackRateDone event. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onPlaybackRateDone(type: 'playbackRateDone', callback: OnPlaybackRateDone): void; + + /** + * Subscribes to the event to check whether the bit rate is successfully set. + * @param { 'bitrateDone' } type - Type of the playback event to listen for. + * This event is triggered each time **setBitrate()** is called. + * @param { Callback } callback - Callback invoked when the event is triggered. + * It reports the effective bit rate. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onBitrateDone(type: 'bitrateDone', callback: Callback): void; + + /** + * Subscribes to playback position changes. It is used to refresh the current position of the progress bar. + * By default, this event is reported every 100 ms. However, it is reported immediately upon + * a successful seek operation. + * @param { 'timeUpdate' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to return the current time. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onTimeUpdate(type: 'timeUpdate', callback: Callback): void; + + /** + * Subscribes to media asset duration changes. It is used to refresh the length of the progress bar. By + * default, this event is reported once in the prepared state. However, it can be repeatedly reported for + * special streams that trigger duration changes. The **'durationUpdate'** event is not supported in live mode. + * @param { 'durationUpdate' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to return the resource duration. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onDurationUpdate(type: 'durationUpdate', callback: Callback): void; + + /** + * Subscribes to audio and video buffer changes. This subscription is supported only in network + * playback scenarios. + * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. + * @param { OnBufferingUpdateHandler } callback - Callback invoked when the event is triggered, + * and return BufferingInfoType and the value. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onBufferingUpdate(type: 'bufferingUpdate', callback: OnBufferingUpdateHandler): void; + + /** + * Subscribes to the event that indicates rendering starts for the first frame. This subscription is + * supported only in video playback scenarios. This event only means that the playback service sends + * the first frame to the display module. The actual rendering effect depends on the rendering performance + * of the display service. + * @param { 'startRenderFrame' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onStartRenderFrame(type: 'startRenderFrame', callback: Callback): void; + + /** + * Subscribes to video size (width and height) changes. This subscription is supported only in video playback + * scenarios. By default, this event is reported only once in the prepared state. However, it is also reported + * upon resolution changes in the case of HLS streams. + * @param { 'videoSizeChange' } type - Type of the playback event to listen for. + * @param { OnVideoSizeChangeHandler } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onVideoSizeChange(type: 'videoSizeChange', callback: OnVideoSizeChangeHandler): void; + + /** + * Register listens for audio interrupt event, refer to {@link #audio.InterruptEvent}. + * The application needs to perform corresponding processing based on different audio interruption events. + * For details, see Handling Audio Interruption Events. + * @param { 'audioInterrupt' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to listen for the playback event return audio interrupt info. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAudioInterrupt(type: 'audioInterrupt', callback: Callback): void; + + /** + * Register listens for available bitrate list collect completed events for HLS protocol stream playback. + * This event will be reported after the {@link #prepare} called. + * @param { 'availableBitrates' } type - Type of the playback event to listen for. + * This event is triggered once after the AVPlayer switches to the prepared state. + * @param { Callback> } callback - Callback used to listen for the playback event return available bitrate list. + * It returns an array that holds the available bit rates. If the array length is 0, no bit rate can be set. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAvailableBitrates(type: 'availableBitrates', callback: Callback>): void; + + /** + * Subscribes to AVPlayer errors. This event is used only for error prompt and does not require the user to stop + * playback control. If AVPlayerState is also switched to error, call {@link #reset()} or {@link #release()} + * to exit the playback. + * @param { 'error' } type - Event type, which is **'error'** in this case. This event can be triggered by + * both user operations and the system. + * @param { ErrorCallback } callback - Callback used to listen for the playback error event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 5400101 - No memory. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400104 - Time out. + * @throws { BusinessError } 5400105 - Service died. + * @throws { BusinessError } 5400106 - Unsupported format. + * @throws { BusinessError } 5411001 - IO can not find host. + * @throws { BusinessError } 5411002 - IO connection timeout. + * @throws { BusinessError } 5411003 - IO network abnormal. + * @throws { BusinessError } 5411004 - IO network unavailable. + * @throws { BusinessError } 5411005 - IO no permission. + * @throws { BusinessError } 5411006 - IO request denied. + * @throws { BusinessError } 5411007 - IO resource not found. + * @throws { BusinessError } 5411008 - IO SSL client cert needed. + * @throws { BusinessError } 5411009 - IO SSL connect fail. + * @throws { BusinessError } 5411010 - IO SSL server cert untrusted. + * @throws { BusinessError } 5411011 - IO unsupported request. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onError(type: 'error', callback: ErrorCallback): void; + + /** + * Subscribes to audio stream output device changes and reasons. This API uses an asynchronous callback + * to return the result. + * + * When subscribing to this event, you are advised to implement the player behavior when the device is + * connected or disconnected by referring to Responding to Audio Output Device Changes. + * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. + * The event is triggered when the output device is changed. + * @param { Callback } callback - Callback used to return the output device + * descriptor of the current audio stream and the change reason. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. 3.Parameter verification failed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAudioOutputDeviceChangeWithInfo(type: 'audioOutputDeviceChangeWithInfo', callback: Callback): void; + + /** + * Subscribes to subtitle update events. When external subtitles exist, the system notifies the application + * through the subscribed-to callback. An application can subscribe to only one subtitle update event. When + * the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'subtitleUpdate' } type - Type of the event to listen for. + * The event is triggered when the external subtitle is updated. + * @param { Callback } callback - Callback invoked when the subtitle is updated. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onSubtitleUpdate(type: 'subtitleUpdate', callback: Callback): void + + /** + * Subscribes to track change events. When the track changes, the system notifies the application through + * the subscribed-to callback. An application can subscribe to only one track change event. When the + * application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'trackChange' } type - Type of the event to listen for. + * The event is triggered when the track changes. + * @param { OnTrackChangeHandler } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onTrackChange(type: 'trackChange', callback: OnTrackChangeHandler): void + + /** + * Subscribes to track information update events. When the track information is updated, the system notifies the + * application through the subscribed-to callback. An application can subscribe to only one track change event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'trackInfoUpdate' } type - Type of the event to listen for. + * The event is triggered when the track information is updated. + * @param { Callback> } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onTrackInfoUpdate(type: 'trackInfoUpdate', callback: Callback>): void + + /** + * Subscribes to update events of the maximum audio level value, which is periodically reported when audio + * resources are played. + * @param { 'amplitudeUpdate' } type - Type of the event to listen for. + * The event is triggered when the amplitude changes. + * @param { Callback> } callback - Callback invoked when the event is triggered. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 20 + * @arkts 1.2 + */ + onAmplitudeUpdate(type: 'amplitudeUpdate', callback: Callback>): void + + /** + * Subscribes to events indicating that a Supplemental Enhancement Information (SEI) message is received. This + * applies only to HTTP-FLV live streaming and is triggered when SEI messages are present in the video stream. + * You must initiate the subscription before calling {@link #prepare}. If you initiate multiple subscriptions + * to this event, the last subscription is applied. + * @param { 'seiMessageReceived' } type - Type of the playback event to listen for. + * The event is triggered when an SEI message is received. + * @param { Array } payloadTypes - Array of subscribed-to payload types of SEI messages. Currently, + * only payloadType = 5 is supported. + * @param { OnSeiMessageHandle } callback - Callback used to listen for SEI message events and receive the + * subscribed-to payload types. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onSeiMessageReceived(type: 'seiMessageReceived', payloadTypes: Array, callback: OnSeiMessageHandle): void; + + /** + * Subscribes to the event indicating that super resolution is enabled or disabled. + * @param { 'superResolutionChanged' } type - Type of the super-resolution event to listen for. + * The event is triggered when super resolution is enabled or disabled. + * @param { OnSuperResolutionChanged } callback - Callback used to listen for the super-resolution changed event. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onSuperResolutionChanged(type:'superResolutionChanged', callback: OnSuperResolutionChanged): void; + } + + /** + * Provides player statistic info. + * + * @typedef PlaybackInfo + * @syscap SystemCapability.Multimedia.Media.Core + * @since 12 + */ + interface PlaybackInfo { + /** + * key:value pair, key see @PlaybackInfoKey. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 12 + */ + [key:string]: Object; + } + + /** + * Provides the container definition for media description key-value pairs. + * + * @typedef { Record } + * @syscap SystemCapability.Multimedia.Media.Core + * @since 20 + * @arkts 1.2 + */ + type PlaybackInfo = Record; + + /** + * Enumerates statistics info keys for player. + * + * @enum { string } + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + enum PlaybackInfoKey { + /** + * IP address of current network stream. + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + SERVER_IP_ADDRESS = 'server_ip_address', + + /** + * Average download rate during playing except for suspend downloading. + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + AVG_DOWNLOAD_RATE = 'average_download_rate', + + /** + * Current download rate of the last second except for suspend downloading. + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + DOWNLOAD_RATE = 'download_rate', + + /** + * Boolean value, true for current is downloading, false for suspend downloading. + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + IS_DOWNLOADING = 'is_downloading', + + /** + * Cached duration in milliseconds. + * @syscap SystemCapability.Multimedia.Media.Core + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + BUFFER_DURATION = 'buffer_duration', + } + + /** + * Enumerates ErrorCode types, return in BusinessError::code + * + * @enum { number } + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode + */ + enum MediaErrorCode { + /** + * operation success. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OK + */ + MSERR_OK = 0, + + /** + * malloc or new memory failed. maybe system have no memory. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_NO_MEMORY + */ + MSERR_NO_MEMORY = 1, + + /** + * no permission for the operation. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OPERATE_NOT_PERMIT + */ + MSERR_OPERATION_NOT_PERMIT = 2, + + /** + * invalid argument. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER + */ + MSERR_INVALID_VAL = 3, + + /** + * an I/O error occurred. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_IO + */ + MSERR_IO = 4, + + /** + * operation time out. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 + * @deprecated since 11 + * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_TIMEOUT + */ + MSERR_TIMEOUT = 5, + + /** + * unknown error. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 8 * @deprecated since 11 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER */ @@ -6983,21 +7837,269 @@ declare namespace media { * information about the audio capturer. * This parameter is supported since API version 12. * @syscap SystemCapability.Multimedia.Media.AVRecorder - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + off(type: 'audioCapturerChange', callback?: Callback): void; + + /** + * Unsubscribes from media asset callback events. + * @param { 'photoAssetAvailable' } type - Event type, which is **'photoAssetAvailable'** in this case. + * @param { Callback } callback - Callback used to return the **PhotoAsset** object + * corresponding to the resource file created by the system. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + off(type: 'photoAssetAvailable', callback?: Callback): void; + + overload reset { resetWithCallBack ,resetReturnPromise }; + /** + * Resets audio and video recording. This API uses an asynchronous callback to return the result. + * + * For audio-only recording, you can call prepare() again for re-recording. + * For video-only recording or audio and video recording, + * you can call prepare() and getInputSurface() again for re-recording. + * @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 } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @since 20 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.reset((err: BusinessError) => { + * if (err) { + * console.error('Failed to reset AVRecorder and error is ' + err.message); + * } else { + * console.info('Succeeded in resetting AVRecorder'); + * } + * }); + * @arkts 1.2 + */ + resetWithCallBack(callback: AsyncCallback): void; + /** + * Resets audio and video recording. This API uses a promise to return the result. + * + * For audio-only recording, you can call prepare() again for re-recording. + * For video-only recording or audio and video recording, + * you can call prepare() and getInputSurface() again for re-recording. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @since 20 + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.reset().then(() => { + * console.info('Succeeded in resetting AVRecorder'); + * }).catch((err: BusinessError) => { + * console.error('Failed to reset and catch error is ' + err.message); + * }); + * @arkts 1.2 + */ + resetReturnPromise(): Promise; + + overload stop { stopWithCallBack , stopReturnPromise }; + /** + * Stops recording. This API uses an asynchronous callback to return the result. + * + * This API can be called only after the start() or pause() API is called. + * + * For audio-only recording, you can call prepare() again for re-recording. + * For video-only recording or audio and video recording, you can call prepare() and getInputSurface() again for re-recording. + * @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 arkts {'1.1':'12','1.2':'20'} + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.stop((err: BusinessError) => { + * if (err) { + * console.error('Failed to stop AVRecorder and error is ' + err.message); + * } else { + * console.info('Succeeded in stopping AVRecorder'); + * } + * }); + * @since 20 + * @arkts 1.2 + */ + stopWithCallBack(callback: AsyncCallback): void; + /** + * Stops recording. This API uses a promise to return the result. + * + * This API can be called only after the start() or pause() API is called. + * + * For audio-only recording, you can call prepare() again for re-recording. + * For video-only recording or audio and video recording, + * you can call prepare() getInputSurface() again for re-recording. + * @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 arkts {'1.1':'12','1.2':'20'} + * @example + * import { BusinessError } from '@kit.BasicServicesKit'; + * + * avRecorder.stop().then(() => { + * console.info('Succeeded in stopping AVRecorder'); + * }).catch((err: BusinessError) => { + * console.error('Failed to stop AVRecorder and catch error is ' + err.message); + * }); + * @since 20 + * @arkts 1.2 + */ + stopReturnPromise(): Promise; + + overload on { onAudioCapturerChange, onPhotoAssetAvailable, onStateChange, onError }; + /** + * Subscribes to audio capturer configuration changes. Any configuration change triggers the callback that + * returns the entire configuration information. + * + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'audioCapturerChange' } type - Event type, which is **'audioCapturerChange'** in this case. + * @param { Callback } callback - Callback used to return the entire configuration + * information about the audio capturer. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. 3.Parameter verification failed. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 + */ + onAudioCapturerChange(type: 'audioCapturerChange', callback: Callback): void; + /** + * Subscribes to media asset callback events. When FileGenerationMode is used during media file creation, + * the PhotoAsset object is called back to the application after the stop operation is complete. + * + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'photoAssetAvailable' } type - Event type, which is **'photoAssetAvailable'** in this case. + * The event is triggered when a photo asset is available. + * @param { Callback } callback - Callback used to return the + * **PhotoAsset** object corresponding to the resource file created by the system. + * @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 + */ + onPhotoAssetAvailable(type: 'photoAssetAvailable', callback: Callback): void; + /** + * Subscribes to AVRecorder state changes. An application can subscribe to only one AVRecorder state change event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'stateChange' } type - Event type, which is **'stateChange'** in this case. + * This event can be triggered by both user operations and the system. + * @param { OnAVRecorderStateChangeHandler } callback - Callback invoked when the event is triggered. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onStateChange(type: 'stateChange', callback: OnAVRecorderStateChangeHandler): void; + /** + * Subscribes to AVRecorder errors. This event is used only for error prompt and does not require the user to + * stop recording control. If the AVRecorderState is also switched to error, call reset() or release() + * to exit the recording. + * + * An application can subscribe to only one AVRecorder error event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * This event is triggered when an error occurs during recording. + * @param { ErrorCallback } callback - Callback invoked when the event is triggered. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. 3.Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 5400101 - No memory. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400103 - I/O error. + * @throws { BusinessError } 5400104 - Time out. + * @throws { BusinessError } 5400105 - Service died. + * @throws { BusinessError } 5400106 - Unsupported format. + * @throws { BusinessError } 5400107 - Audio interrupted. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onError(type: 'error', callback: ErrorCallback): void; + + overload off { offStateChange, offError, offAudioCapturerChange, offPhotoAssetAvailable }; + /** + * Unsubscribes from AVRecorder state changes. + * @param { 'stateChange' } type - Event type, which is **'stateChange'** in this case. + * This event can be triggered by both user operations and the system. + * @param { OnAVRecorderStateChangeHandler } callback - Callback invoked when the event is triggered. + * This parameter is supported since API version 12. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offStateChange(type: 'stateChange', callback?: OnAVRecorderStateChangeHandler): void; + /** + * Cancel Listens for recording error events. + * @param { 'error' } type - Type of the recording error event to listen for. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 9 + */ + /** + * Unsubscribes from AVRecorder errors. After the unsubscription, + * your application can no longer receive AVRecorder errors. + * @param { 'error' } type - Event type, which is **'error'** in this case.
This event is triggered when + * an error occurs during recording. + * @param { ErrorCallback } callback - Callback invoked when the event is triggered. + * This parameter is supported since API version 12. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + offError(type: 'error', callback?: ErrorCallback): void; + /** + * Cancel Listens for recording audioCapturerChange events. + * @param { 'audioCapturerChange' } type - Type of the audioCapturerChange event to listen for. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 11 + */ + /** + * Subscribes to audio capturer configuration changes. + * @param { 'audioCapturerChange' } type - Event type, which is **'audioCapturerChange'** in this case. + * @param { Callback } callback - Callback used to return the entire configuration + * information about the audio capturer. + * This parameter is supported since API version 12. + * @syscap SystemCapability.Multimedia.Media.AVRecorder + * @since 20 + * @arkts 1.2 */ - off(type: 'audioCapturerChange', callback?: Callback): void; - + offAudioCapturerChange(type: 'audioCapturerChange', callback?: Callback): void; /** * Unsubscribes from media asset callback events. * @param { 'photoAssetAvailable' } type - Event type, which is **'photoAssetAvailable'** in this case. * @param { Callback } callback - Callback used to return the **PhotoAsset** object * corresponding to the resource file created by the system. * @syscap SystemCapability.Multimedia.Media.AVRecorder - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 */ - off(type: 'photoAssetAvailable', callback?: Callback): void; + offPhotoAssetAvailable(type: 'photoAssetAvailable', callback?: Callback): void; } /** @@ -7386,6 +8488,28 @@ declare namespace media { * @useinstead ohos.multimedia.media/media.AVRecorder#on */ on(type: 'error', callback: ErrorCallback): void; + + overload prepare { prepareWithConfig }; + /** + * Prepares for recording. + * @permission ohos.permission.MICROPHONE + * @param { AudioRecorderConfig } config - Recording parameters. + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 6 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVRecorder#prepare + */ + /** + * Prepares for recording. + * @permission ohos.permission.MICROPHONE + * @param { AudioRecorderConfig } config - Recording parameters. + * @throws { BusinessError } 201 - permission denied. + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @since 12 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVRecorder#prepare + */ + prepareWithConfig(config: AudioRecorderConfig): void; } /** @@ -7851,6 +8975,162 @@ declare namespace media { * @arkts 1.1&1.2 */ readonly state: VideoRecordState; + + overload prepare { prepareWithConfigCallback, prepareWithConfigReturnsPromise}; + /** + * Prepares for recording. + * @permission ohos.permission.MICROPHONE + * @param { VideoRecorderConfig } config - Recording parameters. + * @param { AsyncCallback } callback - A callback instance used to return when prepare completed. + * @throws { BusinessError } 201 - Permission denied. Return by callback. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. 3.Parameter verification failed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 12 + */ + prepareWithConfigCallback(config: VideoRecorderConfig, callback: AsyncCallback): void; + /** + * Prepares for recording. + * @permission ohos.permission.MICROPHONE + * @param { VideoRecorderConfig } config - Recording parameters. + * @returns { Promise } A Promise instance used to return when prepare completed. + * @throws { BusinessError } 201 - Permission denied. Return by promise. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. 3.Parameter verification failed. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 12 + */ + prepareWithConfigReturnsPromise(config: VideoRecorderConfig): Promise; + + overload pause { pauseWithCallback,pauseReturnsPromise }; + /** + * Pauses video recording. + * @param { AsyncCallback } callback - A callback instance used to return when pause 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 + */ + pauseWithCallback(callback: AsyncCallback): void; + /** + * Pauses video recording. + * @returns { Promise } A Promise instance used to return when pause 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 + */ + pauseReturnsPromise(): Promise; + + overload release { releaseWithCallback, releaseReturnsPromise}; + /** + * Releases resources used for video recording. + * @param { AsyncCallback } callback - A callback instance used to return when release completed. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 12 + */ + releaseWithCallback(callback: AsyncCallback): void; + /** + * Releases resources used for video recording. + * @returns { Promise } A Promise instance used to return when release completed. + * @throws { BusinessError } 202 - Not System App. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi + * @since 12 + */ + releaseReturnsPromise(): Promise; + + overload reset { resetWithCallBack ,resetReturnPromise}; + /** + * 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. + * @param { AsyncCallback } callback - A callback instance used to return when reset completed. + * @throws { BusinessError } 202 - Not System App. + * @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 + */ + resetWithCallBack(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. + * @returns { Promise } A Promise instance used to return when reset completed. + * @throws { BusinessError } 202 - Not System App. + * @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 + */ + resetReturnPromise(): Promise; + + overload stop { stopWithCallBack , stopReturnPromise }; + /** + * Stops video recording. + * @param { AsyncCallback } callback A callback instance used to return when stop 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 + */ + stopWithCallBack(callback: AsyncCallback): void; + /** + * Stops video recording. + * @returns { Promise } A Promise instance used to return when stop 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 + */ + stopReturnPromise(): Promise; + + overload on { onError }; + /** + * Listens for video recording error events. + * @param { 'error' } type - Type of the video recording error event to listen for. + * @param { ErrorCallback } callback - Callback used to listen for the video recording error event. + * @throws { BusinessError } 201 - permission denied. + * @throws { BusinessError } 202 - Not System App. + * @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 + */ + onError(type: 'error', callback: ErrorCallback): void; } /** @@ -8321,84 +9601,165 @@ declare namespace media { * @deprecated since 9 * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed */ - setSpeed(speed: number, callback: AsyncCallback): void; + setSpeed(speed: number, callback: AsyncCallback): void; + /** + * set output surface. + * @param { number } speed - playback speed, see @PlaybackSpeed . + * @returns { Promise } A Promise instance used to return actually speed. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed + */ + setSpeed(speed: number): Promise; + + /** + * Listens for video playback completed events. + * @param { 'playbackCompleted' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to listen for the playback event return. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange + */ + on(type: 'playbackCompleted', callback: Callback): void; + + /** + * Listens for video playback buffering events. + * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. + * @param { function } callback - Callback used to listen for the buffering update event, + * return BufferingInfoType and the value. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate + */ + on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; + + /** + * Listens for start render video frame events. + * @param { 'startRenderFrame' } type - Type of the playback event to listen for. + * @param { Callback } callback - Callback used to listen for the playback event return. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:startRenderFrame + */ + on(type: 'startRenderFrame', callback: Callback): void; + + /** + * Listens for video size changed event. + * @param { 'videoSizeChanged' } type - Type of the playback event to listen for. + * @param { function } callback - Callback used to listen for the playback event return video size. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:videoSizeChange + */ + on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; + + /** + * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} + * @param { 'audioInterrupt' } type - Type of the playback event to listen for. + * @param { function } callback - Callback used to listen for the playback event return audio interrupt info. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 9 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt + */ + on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; + + /** + * Listens for playback error events. + * @param { 'error' } type - Type of the playback error event to listen for. + * @param { ErrorCallback } callback - Callback used to listen for the playback error event. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#event:error + */ + on(type: 'error', callback: ErrorCallback): void; + + overload prepare { prepareWithCallback, prepareReturnsPromise}; + /** + * Prepare video playback, it will request resource for playing. + * @param { AsyncCallback } callback - A callback instance used to return when prepare completed. + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @since 8 + * @deprecated since 9 + * @useinstead ohos.multimedia.media/media.AVPlayer#prepare + */ + prepareWithCallback(callback: AsyncCallback): void; /** - * set output surface. - * @param { number } speed - playback speed, see @PlaybackSpeed . - * @returns { Promise } A Promise instance used to return actually speed. + * Prepare video playback, it will request resource for playing. + * @returns { Promise } A Promise instance used to return when prepare completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed + * @useinstead ohos.multimedia.media/media.AVPlayer#prepare */ - setSpeed(speed: number): Promise; + prepareReturnsPromise(): Promise; + overload release { releaseWithCallback, releaseReturnsPromise }; /** - * Listens for video playback completed events. - * @param { 'playbackCompleted' } type - Type of the playback event to listen for. - * @param { Callback } callback - Callback used to listen for the playback event return. + * Releases resources used for video playback. + * @param { AsyncCallback } callback - A callback instance used to return when release completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange + * @useinstead ohos.multimedia.media/media.AVPlayer#release */ - on(type: 'playbackCompleted', callback: Callback): void; + releaseWithCallback(callback: AsyncCallback): void; /** - * Listens for video playback buffering events. - * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. - * @param { function } callback - Callback used to listen for the buffering update event, - * return BufferingInfoType and the value. + * Releases resources used for video playback. + * @returns { Promise } A Promise instance used to return when release completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate + * @useinstead ohos.multimedia.media/media.AVPlayer#release */ - on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; + releaseReturnsPromise(): Promise; + overload pause { pauseWithCallback,pauseReturnsPromise }; /** - * Listens for start render video frame events. - * @param { 'startRenderFrame' } type - Type of the playback event to listen for. - * @param { Callback } callback - Callback used to listen for the playback event return. + * Pauses video playback. + * @param { AsyncCallback } callback - A callback instance used to return when pause completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:startRenderFrame + * @useinstead ohos.multimedia.media/media.AVPlayer#pause */ - on(type: 'startRenderFrame', callback: Callback): void; - + pauseWithCallback(callback: AsyncCallback): void; /** - * Listens for video size changed event. - * @param { 'videoSizeChanged' } type - Type of the playback event to listen for. - * @param { function } callback - Callback used to listen for the playback event return video size. + * Pauses video playback. + * @returns { Promise } A Promise instance used to return when pause completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:videoSizeChange + * @useinstead ohos.multimedia.media/media.AVPlayer#pause */ - on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; + pauseReturnsPromise(): Promise; + overload play { playWithCallback,playReturnsPromise} /** - * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} - * @param { 'audioInterrupt' } type - Type of the playback event to listen for. - * @param { function } callback - Callback used to listen for the playback event return audio interrupt info. + * Starts video playback. + * @param { AsyncCallback } callback - A callback instance used to return when start completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer - * @since 9 + * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt + * @useinstead ohos.multimedia.media/media.AVPlayer#play */ - on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; - + playWithCallback(callback: AsyncCallback): void; /** - * Listens for playback error events. - * @param { 'error' } type - Type of the playback error event to listen for. - * @param { ErrorCallback } callback - Callback used to listen for the playback error event. + * Starts video playback. + * @returns { Promise } A Promise instance used to return when start completed. * @syscap SystemCapability.Multimedia.Media.VideoPlayer * @since 8 * @deprecated since 9 - * @useinstead ohos.multimedia.media/media.AVPlayer#event:error + * @useinstead ohos.multimedia.media/media.AVPlayer#play */ - on(type: 'error', callback: ErrorCallback): void; + playReturnsPromise(): Promise; } /** @@ -10595,6 +11956,79 @@ declare namespace media { * @arkts 1.1&1.2 */ off(type: 'error', callback?: ErrorCallback): void; + + overload on { onStateChange, onError }; + /** + * Subscribes to screen capture state changes. An application can subscribe to only one screen capture + * state change event. When the application initiates multiple subscriptions to this event, + * the last subscription is applied. + * @param { 'stateChange' } type - Event type, which is **'stateChange'** in this case. + * @param { Callback } callback - Callback invoked when the event is triggered. + * AVScreenCaptureStateCode indicates the new state. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @since 20 + * @example + * avScreenCaptureRecorder.on('stateChange', (state: media.AVScreenCaptureStateCode) => { + * console.info('avScreenCaptureRecorder stateChange to ' + state); + * }) + * @arkts 1.2 + */ + onStateChange(type: 'stateChange', callback: Callback): void; + /** + * Subscribes to AVScreenCaptureRecorder errors. You can handle the errors based on the application logic. + * An application can subscribe to only one AVScreenCaptureRecorder error event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * @param { ErrorCallback } callback - Callback invoked when the event is triggered. + * @throws { BusinessError } 201 - permission denied. + * @throws { BusinessError } 5400103 - IO error. Return by ErrorCallback. + * @throws { BusinessError } 5400105 - Service died. Return by ErrorCallback. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @since 20 + * @example + * avScreenCaptureRecorder.on('error', (err: BusinessError) => { + * console.error('avScreenCaptureRecorder error:' + err.message); + * }) + * @arkts 1.2 + */ + onError(type: 'error', callback: ErrorCallback): void; + + overload off { offStateChange, offError }; + /** + * Unsubscribes from screen capture state changes. You can specify a callback to cancel the specified subscription. + * @param { 'stateChange' } type - Event type, which is **'stateChange'** in this case. + * @param { Callback } callback - Callback used for unsubscription. + * AVScreenCaptureStateCode indicates the new state. If this parameter is not specified, + * the last subscription is canceled. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @since 20 + * @arkts 1.2 + */ + offStateChange(type: 'stateChange', callback?: Callback): void; + /** + * Unsubscribes from AVScreenCaptureRecorder errors. You can specify a callback to cancel + * the specified subscription. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * @param { ErrorCallback } callback - Callback used for unsubscription. If this parameter is not specified, + * the last subscription is canceled. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @since 20 + * @arkts 1.2 + */ + offError(type: 'error', callback?: ErrorCallback): void; + + overload release { releaseReturnsPromise }; + /** + * Releases the video transcoding resources. This API uses a promise to return the result. + * + * After the resources are released, you can no longer perform any operation on the **AVTranscoder** instance. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 12 + */ + releaseReturnsPromise(): Promise; } /** @@ -10899,6 +12333,126 @@ declare namespace media { * @arkts 1.1&1.2 */ off(type:'progressUpdate', callback?: Callback):void; + + overload on { onComplete, onError, onProgressUpdate }; + /** + * Subscribes to the event indicating that transcoding is complete. + * An application can subscribe to only one transcoding completion event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * + * When this event is reported, the current transcoding operation is complete. + * You need to call [release()]{@link AVTranscoder.release} to exit the transcoding. + * @param { 'complete' } type - Event type, which is **'complete'** in this case. + * This event is triggered by the system during transcoding. + * @param { Callback } callback - Callback that has been registered to listen for + * transcoding completion events. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + onComplete(type:'complete', callback: Callback):void; + /** + * Subscribes to AVTranscoder errors. If this event is reported, call [release()]{@link AVTranscoder.release} + * to exit the transcoding. + * + * An application can subscribe to only one AVTranscoder error event. + * When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * + * This event is triggered when an error occurs during transcoding. + * @param { ErrorCallback } callback - Callback invoked when the event is triggered. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 5400101 - No memory. + * @throws { BusinessError } 5400102 - Operation not allowed. + * @throws { BusinessError } 5400103 - I/O error. + * @throws { BusinessError } 5400104 - Time out. + * @throws { BusinessError } 5400105 - Service died. + * @throws { BusinessError } 5400106 - Unsupported format. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + onError(type:'error', callback: ErrorCallback):void; + /** + * Subscribes to transcoding progress updates. An application can subscribe to only one transcoding progress update + * event. When the application initiates multiple subscriptions to this event, the last subscription is applied. + * @param { 'progressUpdate' } type - Event type, which is **'progressUpdate'** in this case. + * This event is triggered by the system during transcoding. + * @param { Callback } callback - Callback invoked when the event is triggered. + * **progress** is a number that indicates the current transcoding progress. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + onProgressUpdate(type:'progressUpdate', callback: Callback):void; + + overload prepare { prepareWithConfigReturnsPromise }; + /** + * Sets video transcoding parameters. This API uses a promise to return the result. + * @param { AVTranscoderConfig } config - Video transcoding parameters to set. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 401 - The parameter check failed. Return by promise. + * @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. + * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 12 + */ + prepareWithConfigReturnsPromise(config: AVTranscoderConfig): Promise; + + overload pause { pauseReturnsPromise }; + /** + * Pauses transcoding. This API uses a promise to return the result. + * + * This API can be called only after the [start()]{@link AVTranscoder.start} API is called. + * You can call [resume()]{@link AVTranscoder.resume} to resume transcoding. + * @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 12 + */ + pauseReturnsPromise(): Promise; + + overload off { offComplete, offError, offProgressUpdate }; + /** + * Unsubscribes from the event indicating that transcoding is complete. + * @param { 'complete' } type - Event type, which is **'complete'** in this case. + * This event can be triggered by both user operations and the system. + * @param { Callback } callback - Callback that has been registered to listen for + * transcoding completion events. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + offComplete(type:'complete', callback?: Callback):void; + /** + * Unsubscribes from AVTranscoder errors. After the unsubscription, your application can no longer + * receive AVTranscoder errors. + * @param { 'error' } type - Event type, which is **'error'** in this case. + * + * This event is triggered when an error occurs during transcoding. + * @param { ErrorCallback } callback - Callback that has been registered to listen for AVTranscoder errors. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + offError(type:'error', callback?: ErrorCallback):void; + /** + * Unsubscribes from transcoding progress updates. + * @param { 'progressUpdate' } type - Event type, which is **'progressUpdate'** in this case. + * This event can be triggered by both user operations and the system. + * @param { Callback } callback - Called that has been registered to listen for progress updates. + * You are advised to use the default value because only the last registered callback is retained in the current + * callback mechanism. + * @syscap SystemCapability.Multimedia.Media.AVTranscoder + * @since 20 + * @arkts 1.2 + */ + offProgressUpdate(type:'progressUpdate', callback?: Callback):void; } /** @@ -10987,6 +12541,28 @@ declare namespace media { * @arkts 1.1&1.2 */ readonly isSystemScreenRecorderWorking: boolean; + + overload on { onSystemScreenRecorder }; + /** + * Subscribes to state change events of the system screen recorder. From the ScreenCaptureEvent event reported, + * you can determine whether the system screen recorder is working. + * @param { 'systemScreenRecorder' } type - Event type, which is **'systemScreenRecorder'** in this case. + * This event is triggered when the state of the system screen recorder changes. + * @param { Callback } callback - Callback invoked when the event is triggered, + * where ScreenCaptureEvent indicates the new state. + * @throws { BusinessError } 202 - Not System App. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @systemapi + * @since 20 + * @example + * // This event is reported when the state of the system screen recorder changes. + * screenCaptureMonitor.on('systemScreenRecorder', (event: media.ScreenCaptureEvent) => { + * // Set the 'systemScreenRecorder' event callback. + * console.info(`system ScreenRecorder event: ${event}`); + * }) + * @arkts 1.2 + */ + onSystemScreenRecorder(type: 'systemScreenRecorder', callback: Callback): void; } } export default media; diff --git a/api/multimedia/soundPool.d.ts b/api/multimedia/soundPool.d.ts index ddd08fc26242610684ae486820088fc3a0f70e23..3f78a9b248a61b8653b310f24780473107af3ac7 100644 --- a/api/multimedia/soundPool.d.ts +++ b/api/multimedia/soundPool.d.ts @@ -287,6 +287,115 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ load(fd: int, offset: long, length: long): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload load { loadWithCallback, loadWithPromise, loadFdWithCallback, loadFdWithPromise }; + /** + * Loads a sound. This API uses an asynchronous callback to obtain the sound ID. + * The input parameter **uri** is a string starting with fd://, which is generated based on the file descriptor (FD) + * obtained. This API cannot be used to load resources in the **rawfile** directory. + * Instead, use load(fd: number, offset: number, length: number, callback: AsyncCallback): void or + * load(fd: number, offset: number, length: number): Promise. + * + * **NOTE** + * + * After the resource handle (in the form of an FD) or path description (in the form of a URI) is transferred to + * the AVPlayer, do not use the resource handle or path description in read or write operations, + * including but not limited to transferring it to multiple AVPlayers. Competition occurs when multiple AVPlayers use + * the same resource handle or path description to read and write files at the same time, resulting in playback errors. + * + * @param {string} uri - URI of the audio file to load. Generally, the URI starts with fd://. + * @param {AsyncCallback} callback - Callback used to return the sound ID. A valid value must be + * greater than 0. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + loadWithCallback(uri: string, callback: AsyncCallback): void; + /** + * Loads a sound. This API uses a promise to obtain the sound ID. The input parameter **uri** is a starting with + * fd://, which is generated based on the FD obtained. This API cannot be used to load resources in the **rawfile** + * directory. + * Instead, use load(fd: number, offset: number, length: number, callback: AsyncCallback): void or + * load(fd: number, offset: number, length: number): Promise. + * + * **NOTE** + * + * After the resource handle (in the form of an FD) or path description (in the form of a URI) + * is transferred to the AVPlayer, do not use the resource handle or path description in read or write operations, + * including but not limited to transferring it to multiple AVPlayers. Competition occurs when multiple AVPlayers + * use the same resource handle or path description to read and write files at the same time, + * resulting in playback errors. + * + * @param {string} uri - URI of the audio file to load. Generally, the URI starts with fd://. + * @returns {Promise} Promise used to return the sound ID. A valid value must be greater than 0. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + loadWithPromise(uri: string): Promise; + /** + * Loads a sound. This API uses an asynchronous callback to obtain the sound ID. The input parameter **fd** can be + * manually input or automatically obtained by reading the embedded resource of the application. + * + * **NOTE** + * + * After the resource handle (in the form of an FD) or path description (in the form of a URI) is transferred to + * the AVPlayer, do not use the resource handle or path description in read or write operations, including but not + * limited to transferring it to multiple AVPlayers. Competition occurs when multiple AVPlayers use the same resource + * handle or path description to read and write files at the same time, resulting in playback errors. + * + * @param {int} fd - Resource handle, which is obtained by calling + * [resourceManager.getRawFd]{@link resourceManager.resourceManager.getRawFile}. + * @param {long} offset - Resource offset, which needs to be entered based on the preset resource information. + * An invalid value causes a failure to parse audio and video resources. + * @param {long} length - Resource length, which needs to be entered based on the preset resource information. + * An invalid value causes a failure to parse audio and video resources. + * @param {AsyncCallback} callback - Callback used to return the sound ID. + * A valid value must be greater than 0. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + loadFdWithCallback(fd: int, offset: long, length: long, callback: AsyncCallback): void; + /** + * Loads a sound. This API uses a promise to obtain the sound ID. The input parameter **fd** can be manually input or + * automatically obtained by reading the embedded resource of the application. + * + * **NOTE** + * + * After the resource handle (in the form of an FD) or path description (in the form of a URI) is transferred to the + * AVPlayer, do not use the resource handle or path description in read or write operations, including but not + * limited to transferring it to multiple AVPlayers. Competition occurs when multiple AVPlayers use the same resource + * handle or path description to read and write files at the same time, resulting in playback errors. + * + * @param {int} fd - Resource handle, which is obtained by calling + * [resourceManager.getRawFd]{@link resourceManager.resourceManager.getRawFile}. + * @param {long} offset - Resource offset, which needs to be entered based on the preset resource information. + * An invalid value causes a failure to parse audio and video resources. + * @param {long} length - Resource length, which needs to be entered based on the preset resource information. + * An invalid value causes a failure to parse audio and video resources. + * @returns {Promise} Promise used to return the sound ID. A valid value must be greater than 0. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + loadFdWithPromise(fd: int, offset: long, length: long): Promise; /** * Plays a sound. This API uses an asynchronous callback to obtain the audio stream ID. * @@ -333,6 +442,58 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ play(soundID: int, params?: PlayParameters): Promise; + +/** + * @since 20 + * @arkts 1.2 + */ +overload play { playWithCallback, playWithPlayParametersCallback, playWithPlayParametersPromise }; +/** + * Plays a sound. This API uses an asynchronous callback to obtain the audio stream ID. + * + * @param {int} soundID - Sound ID, which is obtained by calling **load()**. + * @param {PlayParameters} params - Playback parameters. + * @param {AsyncCallback} callback - Callback used to return the audio stream ID. + * A valid value must be greater than 0. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ +playWithCallback(soundID: int, params: PlayParameters, callback: AsyncCallback): void; +/** + * Plays a sound. This API uses an asynchronous callback to obtain the audio stream ID. + * + * @param {int} soundID - Sound ID, which is obtained by calling **load()**. + * @param {AsyncCallback} callback - Callback used to return the audio stream ID. + * A valid value must be greater than 0. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ +playWithPlayParametersCallback(soundID: int, callback: AsyncCallback): void; +/** + * Plays a sound. This API uses a promise to obtain the audio stream ID. + * + * @param {int} soundID - Sound ID, which is obtained by calling **load()**. + * @param {PlayParameters} params - Playback parameters. + * @returns {Promise} Promise used to return the audio stream ID. A valid value must be greater than 0. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @since 20 + * @arkts 1.2 + */ + playWithPlayParametersPromise(soundID: int, params?: PlayParameters): Promise; + /** * Stops playing a sound. This API uses an asynchronous callback to return the result. * @@ -361,6 +522,40 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ stop(streamID: int): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload stop { stopWithCallback, stopWithPromise }; + /** + * Stops playing a sound. This API uses an asynchronous callback to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + stopWithCallback(streamID: int, callback: AsyncCallback): void; + /** + * Stops playing a sound. This API uses a promise to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + stopWithPromise(streamID: int): Promise; /** * Sets the loop mode for an audio stream. This API uses an asynchronous callback to return the result. * @@ -401,6 +596,52 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ setLoop(streamID: int, loop: int): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload setLoop { setLoopWithCallback, setLoopWithPromise }; + /** + * Sets the loop mode for an audio stream. This API uses an asynchronous callback to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {int} loop - Number of loops. + * + * If this parameter is set to a value greater than or equal to 0, the number of times the content is actually + * played is the value of **loop** plus 1. + * + * If this parameter is set to a value less than 0, the content is played repeatedly. + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setLoopWithCallback(streamID: int, loop: int, callback: AsyncCallback): void; + /** + * Sets the loop mode for an audio stream. This API uses a promise to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {int} loop - Number of loops. + * + * If this parameter is set to a value greater than or equal to 0, the number of times the content is actually + * played is the value of **loop** plus 1. + * + * If this parameter is set to a value less than 0, the content is played repeatedly. + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setLoopWithPromise(streamID: int, loop: int): Promise; /** * Sets the priority for an audio stream. This API uses an asynchronous callback to return the result. * @@ -433,6 +674,44 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ setPriority(streamID: int, priority: int): Promise; + /** + * @since 20 + * @arkts 1.2 + */ + overload setPriority { setPriorityWithCallback, setPriorityWithPromise }; + /** + * Sets the priority for an audio stream. This API uses an asynchronous callback to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {int} priority - Priority. The value **0** means the lowest priority. The value is an integer + * greater than or equal to 0. + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setPriorityWithCallback(streamID: int, priority: int, callback: AsyncCallback): void; + /** + * Sets the priority for an audio stream. This API uses a promise to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {int} priority - Priority. The value **0** means the lowest priority. The value is an integer + * greater than or equal to 0. + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setPriorityWithPromise(streamID: int, priority: int): Promise; + /** * Sets the playback rate for an audio stream. This API uses an asynchronous callback to return the result. * @@ -463,6 +742,42 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ setRate(streamID: int, rate: audio.AudioRendererRate): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload setRate { setRateWithCallback, setRateWithPromise }; + /** + * Sets the playback rate for an audio stream. This API uses an asynchronous callback to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {audio.AudioRendererRate} rate - Playback rate. + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setRateWithCallback(streamID: int, rate: audio.AudioRendererRate, callback: AsyncCallback): void; + /** + * Sets the playback rate for an audio stream. This API uses a promise to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {audio.AudioRendererRate} rate - Playback rate. + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setRateWithPromise(streamID: int, rate: audio.AudioRendererRate): Promise; /** * Sets the volume for an audio stream. This API uses an asynchronous callback to return the result. * @@ -497,6 +812,46 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ setVolume(streamID: int, leftVolume: double, rightVolume: double): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload setVolume { setVolumeWithCallback, setVolumeWithPromise }; + /** + * Sets the volume for an audio stream. This API uses an asynchronous callback to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {double} leftVolume - Volume of the left channel. The value ranges from 0.0 to 1.0. + * @param {double} rightVolume - Volume of the right channel. The value ranges from 0.0 to 1.0. Currently, + * setting the volume for the right channel does not take effect. The volume set for the left channel is used. + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by callback. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setVolumeWithCallback(streamID: int, leftVolume: double, rightVolume: double, callback: AsyncCallback): void; + /** + * Sets the volume for an audio stream. This API uses a promise to return the result. + * + * @param {int} streamID - Audio stream ID, which is obtained by calling **play()**. + * @param {double} leftVolume - Volume of the left channel. The value ranges from 0.0 to 1.0. + * @param {double} rightVolume - Volume of the right channel. The value ranges from 0.0 to 1.0. Currently, + * setting the volume for the right channel does not take effect. The volume set for the left channel is used. + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. Return by promise. + * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + setVolumeWithPromise(streamID: int, leftVolume: double, rightVolume: double): Promise; /** * Unloads a sound. This API uses an asynchronous callback to return the result. * @@ -523,6 +878,38 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ unload(soundID: int): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload unload { unloadWithCallback, unloadWithPromise }; + /** + * Unloads a sound. This API uses an asynchronous callback to return the result. + * + * @param {int} soundID - Sound ID, which is obtained by calling **load()**. + * @param {AsyncCallback} callback - Callback used to return the result. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + unloadWithCallback(soundID: int, callback: AsyncCallback): void; + /** + * Unloads a sound. This API uses a promise to return the result. + * + * @param {int} soundID - Sound ID, which is obtained by calling **load()**. + * @returns {Promise} Promise that returns no value. + * @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.SoundPool + * @since 20 + * @arkts 1.2 + */ + unloadWithPromise(soundID: int): Promise; /** * Releases this **SoundPool** instance. This API uses an asynchronous callback to return the result. * @@ -543,6 +930,32 @@ export declare interface SoundPool { * @arkts 1.1&1.2 */ release(): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload release { releaseWithCallback, releaseWithPromise }; + /** + * Releases this **SoundPool** instance. This API uses an asynchronous callback to return the result. + * + * @param {AsyncCallback} callback - Callback used to return the result. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + releaseWithCallback(callback: AsyncCallback): void; + /** + * Releases this **SoundPool** instance. This API uses a promise to return the result. + * + * @returns {Promise} Promise that returns no value. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + releaseWithPromise(): Promise; /** * Subscribes to events indicating that a sound finishes loading. * @@ -651,5 +1064,124 @@ export declare interface SoundPool { * @since 20 */ off(type: 'errorOccurred', callback?: Callback): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload on { onLoadComplete, onPlayFinishedWithStreamId, onPlayFinished, onError, onErrorOccurred}; + /** + * @since 20 + * @arkts 1.2 + */ + overload off { offLoadComplete, offPlayFinishedWithStreamId, offPlayFinished, offError, offErrorOccurred}; + /** + * Subscribes to events indicating that a sound finishes loading. + * + * @param {'loadComplete'} type - Event type, which is **'loadComplete'** in this case. + * This event is triggered when a sound is loaded. + * @param {Callback} callback - ID of the sound that has been loaded. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + onLoadComplete(type: 'loadComplete', callback: Callback): void; + /** + * Unsubscribes from events indicating that a sound finishes loading. + * + * @param {'loadComplete'} type - Event type. The value is fixed at **'loadComplete'**. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + offLoadComplete(type: 'loadComplete'): void; + /** + * Subscribes to events indicating the completion of audio playback and returns the stream ID of the audio + * that finishes playing. + * + * When only on('playFinished') or on('playFinishedWithStreamId') is subscribed to, the registered + * callback is triggered when the audio playback is complete. + * + * When both on('playFinished') and on('playFinishedWithStreamId') are subscribed to, + * the 'playFinishedWithStreamId' callback is triggered, but the 'playFinished' callback is not triggered, + * when the audio playback is complete. + * + * @param {'playFinishedWithStreamId'} type - Event type, which is **'playFinishedWithStreamId'** in this case. + * This event is triggered when an audio stream finishes playing, and the stream ID is returned. + * @param {Callback} callback - Callback used to return the result. Stream ID of the audio that + * finishes playing. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + onPlayFinishedWithStreamId(type: 'playFinishedWithStreamId', callback: Callback): void; + /** + * Unsubscribes from events indicating that a sound finishes playing. + * + * @param {'playFinishedWithStreamId'} type - Event type. The value is fixed at **'playFinishedWithStreamId'**. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + offPlayFinishedWithStreamId(type: 'playFinishedWithStreamId'): void; + /** + * Subscribes to events indicating that a sound finishes playing. + * + * @param {'playFinished'} type - Event type, which is **'playFinished'** in this case. + * This event is triggered when a sound finishes playing. + * @param {Callback} callback - Callback used to return the result. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + onPlayFinished(type: 'playFinished', callback: Callback): void; + /** + * Unsubscribes from events indicating that a sound finishes playing. + * + * @param {'playFinished'} type - Event type. The value is fixed at **'playFinished'**. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + offPlayFinished(type: 'playFinished'): void; + /** + * Subscribes to error events of this **SoundPool** instance. This event is used only for error prompt. + * + * @param {'error'} type - Event type, which is **'error'** in this case. + * This event can be triggered by both user operations and the system. + * @param {ErrorCallback} callback - Callback used to return the error code ID and error message. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + onError(type: 'error', callback: ErrorCallback): void; + /** + * Unsubscribes from error events of this **SoundPool** instance. + * + * @param {'error'} type - Event type, which is **'error'** in this case. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + offError(type: 'error'): void; + /** + * Subscribes to errorOccurred events of this **SoundPool** instance. + * + * @param { 'errorOccurred' } type - Type of the soundpool event to listen for. + * @param { Callback } callback - Callback used to listen for soundpool errorOccurred events. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + onErrorOccurred(type: 'errorOccurred', callback: Callback): void; + /** + * Unsubscribes from errorOccurred events of this **SoundPool** instance. + * + * @param { 'errorOccurred' } type - Type of the soundpool event to listen for. + * @param { Callback } [callback] - Callback used to listen for soundpool errorOccurred events. + * @syscap SystemCapability.Multimedia.Media.SoundPool + * @since 20 + * @arkts 1.2 + */ + offErrorOccurred(type: 'errorOccurred', callback?: Callback): void; }