openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerBridge

2026-08-25 浏览 (1)

Interface (NativeMediaPlayerBridge)

Instance of the API class between the web media player and the ArkWeb kernel.

The ArkWeb kernel uses an object of this interface class to control the player created by the application to take over web page media.

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.

updateRect12+

updateRect(x: number, y: number, width: number, height: number): void

Updates the surface position information.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
xnumberYesX coordinate of the surface relative to the Web component.
ynumberYesY coordinate of the surface relative to the Web component.
widthnumberYesWidth of the surface.
Unit: pixel
heightnumberYesHeight of the surface.
Unit: pixel

Example

For details about the sample code, see onCreateNativeMediaPlayer.

play12+

play(): void

Plays this video.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

pause12+

pause(): void

Pauses playback.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

seek12+

seek(targetTime: number): void

Seeks to a specific time point in the media.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
targetTimenumberYesTarget time point.
Unit: second

Example

For details about the sample code, see onCreateNativeMediaPlayer.

setVolume12+

setVolume(volume: number): void

Sets the playback volume.

Parameters

NameTypeMandatoryDescription
volumenumberYesPlayback volume.
Value range: [0, 1.0]. The value 0 indicates mute, and the value 1.0 indicates the maximum volume.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

setMuted12+

setMuted(muted: boolean): void

Sets the muted status.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
mutedbooleanYesWhether to mute the player.
The value true means to mute the player, and false means the opposite.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

setPlaybackRate12+

setPlaybackRate(playbackRate: number): void

Sets the playback rate.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
playbackRatenumberYesPlayback rate.
Value range: [0, 10.0]. The value 1 indicates the original speed of playback.

Example

For details about the sample code, see onCreateNativeMediaPlayer.

release12+

release(): void

Releases this player.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

enterFullscreen12+

enterFullscreen(): void

Enables the player to enter full screen mode.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

exitFullscreen12+

exitFullscreen(): void

Enables the player to exit full screen mode.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

resumePlayer12+

resumePlayer?(): void

Resumes the player and its status information.

System capability: SystemCapability.Web.Webview.Core

Example

For details about the sample code, see onCreateNativeMediaPlayer.

suspendPlayer12+

suspendPlayer?(type: SuspendType): void

Suspends the player and save its status information.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
typeSuspendTypeYesSuspension type of the player.

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 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

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