openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

2026-08-25 浏览 (1)

Interface (NativeMediaPlayerHandler)

Implements a NativeMediaPlayerHandler object used as a parameter of the CreateNativeMediaPlayerCallback callback. The application uses this object to report the player status to the ArkWeb engine.

NOTE

  • The initial APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this interface are supported since API version 12.

  • The sample effect is subject to the actual device.

handleStatusChanged12+

handleStatusChanged(status: PlaybackStatus): void

Called to notify the ArkWeb engine of the playback status of the player when the playback status changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
statusPlaybackStatusYesPlayer status.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleVolumeChanged12+

handleVolumeChanged(volume: number): void

Called to notify the ArkWeb engine of the volume of the player when the volume changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
volumenumberYesVolume of the player. The value range is [0, 1.0].

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleMutedChanged12+

handleMutedChanged(muted: boolean): void

Called to notify the ArkWeb engine of the muted status of the player when the muted status changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
mutedbooleanYesWhether the player is muted.
The value true indicates that the player is muted, and false indicates the opposite.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handlePlaybackRateChanged12+

handlePlaybackRateChanged(playbackRate: number): void

Called to notify the ArkWeb engine of the playback rate of the player when the playback rate changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
playbackRatenumberYesPlayback rate. The value range is [0, +∞).

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleDurationChanged12+

handleDurationChanged(duration: number): void

Called to notify the ArkWeb engine of the total duration of the media.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
durationnumberYesTotal duration of the media.
Unit: second. Value range: [0,+∞)

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleTimeUpdate12+

handleTimeUpdate(currentPlayTime: number): void

Called to notify the ArkWeb engine of the playback progress when the playback progress changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
currentPlayTimenumberYesCurrent progress.
Unit: second. Value range: [0, duration]

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleBufferedEndTimeChanged12+

handleBufferedEndTimeChanged(bufferedEndTime: number): void

Called to notify the ArkWeb engine of the buffer time when the buffer time changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
bufferedEndTimenumberYesDuration of media data in the buffer.
Unit: second. Value range: [0, duration]

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleEnded12+

handleEnded(): void

Called to notify the ArkWeb engine that the media playback ends.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleNetworkStateChanged12+

handleNetworkStateChanged(state: NetworkState): void

Called to notify the ArkWeb engine of the network status of the player when the network status changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
stateNetworkStateYesNetwork status of the player.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleReadyStateChanged12+

handleReadyStateChanged(state: ReadyState): void

Called to notify the ArkWeb engine of the cache status of the player when the cache status changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
stateReadyStateYesCache status of the player.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleFullscreenChanged12+

handleFullscreenChanged(fullscreen: boolean): void

Called to notify the ArkWeb engine of the full screen status of the player when the full screen status changes.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
fullscreenbooleanYesWhether the player is in full screen.
The value true means that the player is in full screen, and false means the opposite.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleSeeking12+

handleSeeking(): void

Called to notify the ArkWeb engine that the player enters the seek state.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleSeekFinished12+

handleSeekFinished(): void

Called to notify the ArkWeb engine that the seek operation is complete.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleError12+

handleError(error: MediaError, errorMessage: string): void

Called to notify the ArkWeb engine that an error occurs with the player.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
errorMediaErrorYesError object type.
errorMessagestringYesError message.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

handleVideoSizeChanged12+

handleVideoSizeChanged(width: number, height: number): void

Called to notify the ArkWeb engine of the video size of the player.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
widthnumberYesVideo width, in pixels. Value range: [0,+∞)
heightnumberYesVideo height, in pixels. Value range: [0,+∞)

Example

For details about the sample code, see onCreateNativeMediaPlayer.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-webview-WebviewController

openharmony 鸿蒙 arkts-apis-webview-t

openharmony 鸿蒙 arkts-apis-webview

openharmony 鸿蒙 capi-arkweb-type-h

openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler

openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager

openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler

openharmony 鸿蒙 capi-web-arkweb-webmessage8h

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

openharmony 鸿蒙 arkts-basic-components-web-WebResourceError

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/4QH7gDUP