• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (NativeMediaPlayerBridge)
2
3
4
5Implements a **CreateNativeMediaPlayerCallback** object to control the player created by the application for taking over the web page media playback. This object is a return value type of the [CreateNativeMediaPlayerCallback](./arkts-apis-webview-t.md#createnativemediaplayercallback12) callback.
6
7> **NOTE**
8>
9> - 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.
10>
11> - The initial APIs of this interface are supported since API version 12.
12>
13> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
14
15## updateRect<sup>12+<sup>
16
17updateRect(x: number, y: number, width: number, height: number): void
18
19Updates the surface position information.
20
21**System capability**: SystemCapability.Web.Webview.Core
22
23**Parameters**
24
25| Name| Type| Mandatory| Description|
26|--------|------|------|------|
27| x | number | Yes| X coordinate of the surface relative to the **Web** component.|
28| y | number | Yes| Y coordinate of the surface relative to the **Web** component.|
29| width  | number | Yes| Width of the surface.|
30| height | number | Yes| Height of the surface.|
31
32**Example**
33
34For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
35
36## play<sup>12+<sup>
37
38play(): void
39
40Plays this video.
41
42**System capability**: SystemCapability.Web.Webview.Core
43
44**Example**
45
46For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
47
48## pause<sup>12+<sup>
49
50pause(): void
51
52Pauses playback.
53
54**System capability**: SystemCapability.Web.Webview.Core
55
56**Example**
57
58For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
59
60## seek<sup>12+<sup>
61
62seek(targetTime: number): void
63
64Seeks to a specific time point in the media.
65
66**System capability**: SystemCapability.Web.Webview.Core
67
68**Parameters**
69
70| Name| Type| Mandatory| Description|
71|--------|------|------|------|
72| targetTime | number | Yes| Target time point.<br>Unit: second|
73
74**Example**
75
76For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
77
78## setVolume<sup>12+<sup>
79
80setVolume(volume: number): void
81
82Sets the playback volume.
83
84**Parameters**
85
86| Name| Type| Mandatory| Description|
87|--------|------|------|------|
88| volume | number | Yes| Playback volume.<br>Value range: [0, 1.0]. The value **0** indicates mute, and the value **1.0** indicates the maximum volume.|
89
90**System capability**: SystemCapability.Web.Webview.Core
91
92**Example**
93
94For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
95
96## setMuted<sup>12+<sup>
97
98setMuted(muted: boolean): void
99
100Sets the muted status.
101
102**System capability**: SystemCapability.Web.Webview.Core
103
104**Parameters**
105
106| Name| Type| Mandatory| Description|
107|--------|------|------|------|
108| muted | boolean | Yes| Whether to mute the player.<br>The value **true** means to mute the player, and **false** means the opposite.|
109
110**Example**
111
112For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
113
114## setPlaybackRate<sup>12+<sup>
115
116setPlaybackRate(playbackRate: number): void
117
118Sets the playback rate.
119
120**System capability**: SystemCapability.Web.Webview.Core
121
122**Parameters**
123
124| Name| Type| Mandatory| Description|
125|--------|------|------|------|
126| playbackRate | number | Yes| Playback rate.<br>Value range: [0, 10.0]. The value **1** indicates the original speed of playback.|
127
128**Example**
129
130For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
131
132## release<sup>12+<sup>
133
134release(): void
135
136Releases this player.
137
138**System capability**: SystemCapability.Web.Webview.Core
139
140**Example**
141
142For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
143
144## enterFullscreen<sup>12+<sup>
145
146enterFullscreen(): void
147
148Enables the player to enter full screen mode.
149
150**System capability**: SystemCapability.Web.Webview.Core
151
152**Example**
153
154For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
155
156## exitFullscreen<sup>12+<sup>
157
158exitFullscreen(): void
159
160Enables the player to exit full screen mode.
161
162**System capability**: SystemCapability.Web.Webview.Core
163
164**Example**
165
166For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
167
168## resumePlayer<sup>12+<sup>
169
170resumePlayer?(): void
171
172Resumes the player and its status information.
173
174**System capability**: SystemCapability.Web.Webview.Core
175
176**Example**
177
178For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
179
180## suspendPlayer<sup>12+<sup>
181
182suspendPlayer?(type: SuspendType): void
183
184Suspends the player and save its status information.
185
186**System capability**: SystemCapability.Web.Webview.Core
187
188**Parameters**
189
190| Name| Type| Mandatory| Description|
191|--------|------|------|------|
192| type | [SuspendType](./arkts-apis-webview-e.md#suspendtype12) | Yes| Suspension type of the player.|
193
194**Example**
195
196For details about the sample code, see [onCreateNativeMediaPlayer](./arkts-apis-webview-WebviewController.md#oncreatenativemediaplayer12).
197