From 0dc9f762802ab9bf3a3ddb1c04e58b20d041e94e Mon Sep 17 00:00:00 2001 From: xiangtongtong Date: Tue, 5 Aug 2025 17:11:56 +0800 Subject: [PATCH] api Signed-off-by: xiangtongtong --- api/@ohos.multimedia.media.d.ts | 350 +++++++++++++++++++++++++++++++- 1 file changed, 349 insertions(+), 1 deletion(-) diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index f5ec05467e..b83176d9a0 100755 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -3981,7 +3981,355 @@ declare namespace media { * @atomicservice * @since 18 */ - off(type:'superResolutionChanged', callback?: OnSuperResolutionChanged): void; + off(type:'superResolutionChanged', callback?: OnSuperResolutionChanged): void; + + overload on {}; + + /** + * 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 + */ + on(type: 'mediaKeySystemInfoUpdate', callback: Callback>): void; + + /** + * 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 + */ + on(type: 'mediaKeySystemInfoUpdate', callback: Callback>): 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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(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 + */ + on(type:'superResolutionChanged', callback: OnSuperResolutionChanged): void; } /** -- Gitee