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

Name Type Mandatory Description
x number Yes X coordinate of the surface relative to the Web component.
y number Yes Y coordinate of the surface relative to the Web component.
width number Yes Width of the surface.
Unit: pixel
height number Yes Height 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

Name Type Mandatory Description
targetTime number Yes Target time point.
Unit: second

Example

For details about the sample code, see onCreateNativeMediaPlayer.

setVolume12+

setVolume(volume: number): void

Sets the playback volume.

Parameters

Name Type Mandatory Description
volume number Yes Playback 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

Name Type Mandatory Description
muted boolean Yes Whether 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

Name Type Mandatory Description
playbackRate number Yes Playback 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

Name Type Mandatory Description
type SuspendType Yes Suspension type of the player.

Example

For details about the sample code, see onCreateNativeMediaPlayer.