• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Seek mode.
18 * @since 8
19 */
20declare enum SeekMode {
21  /**
22   * Sync to keyframes before the time point.
23   * @since 8
24   */
25  PreviousKeyframe,
26
27  /**
28   * Sync to keyframes after the time point.
29   * @since 8
30   */
31  NextKeyframe,
32
33  /**
34   * Sync to closest keyframes.
35   * @since 8
36   */
37  ClosestKeyframe,
38
39  /**
40   * Seek to frames closest the time point.
41   * @since 8
42   */
43  Accurate,
44}
45
46/**
47 * playback speed.
48 * @since 8
49 */
50declare enum PlaybackSpeed {
51  /**
52   * 0.75x speed playback.
53   * @since 8
54   */
55  Speed_Forward_0_75_X,
56
57  /**
58   * 1.00x speed playback.
59   * @since 8
60   */
61  Speed_Forward_1_00_X,
62
63  /**
64   * 1.25x speed playback.
65   * @since 8
66   */
67  Speed_Forward_1_25_X,
68
69  /**
70   * 1.75x speed playback.
71   * @since 8
72   */
73  Speed_Forward_1_75_X,
74
75  /**
76   * 2.00x speed playback.
77   * @since 8
78   */
79  Speed_Forward_2_00_X,
80}
81
82/**
83 * Defines the video options.
84 * @since 7
85 */
86declare interface VideoOptions {
87  /**
88   * src of video.
89   * @since 7
90   */
91  src?: string | Resource;
92
93  /**
94   * playback rate of video.
95   * @since 7
96   */
97  currentProgressRate?: number | string | PlaybackSpeed;
98
99  /**
100   * preview uri of video.
101   * @since 7
102   */
103  previewUri?: string | PixelMap | Resource;
104
105  /**
106   * controller of video.
107   * @since 7
108   */
109  controller?: VideoController;
110}
111
112/**
113 * Defines the video controller.
114 * @since 7
115 */
116declare class VideoController {
117  /**
118   * constructor.
119   * @since 7
120   */
121  constructor();
122
123  /**
124   * Provides events to play.
125   * @since 7
126   */
127  start();
128
129  /**
130   * Provides a pause event for playback.
131   * @since 7
132   */
133  pause();
134
135  /**
136   * Provides an event to stop playback.
137   * @since 7
138   */
139  stop();
140
141  /**
142   * Provide the progress method of video playback.
143   * @since 7
144   */
145  setCurrentTime(value: number);
146
147  /**
148   * Provides a full screen playback method.
149   * @since 7
150   */
151  requestFullscreen(value: boolean);
152
153  /**
154   * Provides a method to exit full screen playback.
155   * @since 7
156   */
157  exitFullscreen();
158
159  /**
160   * Provide the progress method of video playback.
161   * @since 8
162   */
163  setCurrentTime(value: number, seekMode: SeekMode);
164}
165
166/**
167 * Defines the video interface.
168 * @since 7
169 */
170interface VideoInterface {
171  /**
172   * Set the value.
173   * @since 7
174   */
175  (value: VideoOptions): VideoAttribute;
176}
177
178/**
179 * Defines the video attribute functions.
180 * @since 7
181 */
182declare class VideoAttribute extends CommonMethod<VideoAttribute> {
183  /**
184   * Called when judging whether the video is muted.
185   * @since 7
186   */
187  muted(value: boolean): VideoAttribute;
188
189  /**
190   * Called when judging whether the video is played automatically.
191   * @since 7
192   */
193  autoPlay(value: boolean): VideoAttribute;
194
195  /**
196   * Called when judging whether the control bar is displayed.
197   * @since 7
198   */
199  controls(value: boolean): VideoAttribute;
200
201  /**
202   * Called when judging whether the video is played circular.
203   * @since 6
204   */
205  loop(value: boolean): VideoAttribute;
206
207  /**
208   * Called when determining the zoom type of the video source.
209   * @since 7
210   */
211  objectFit(value: ImageFit): VideoAttribute;
212
213  /**
214   * Called when the video is played.
215   * @since 7
216   */
217  onStart(event: () => void): VideoAttribute;
218
219  /**
220   * Called when the video is paused.
221   * @since 7
222   */
223  onPause(event: () => void): VideoAttribute;
224
225  /**
226   * Called when the video playback ends.
227   * @since 7
228   */
229  onFinish(event: () => void): VideoAttribute;
230
231  /**
232   * Called when the video enters and exits the full screen.
233   * @since 7
234   */
235  onFullscreenChange(callback: (event?: { fullscreen: boolean }) => void): VideoAttribute;
236  /**
237   * Called when the video preparation is complete.
238   * @since 7
239   */
240  onPrepared(callback: (event?: { duration: number }) => void): VideoAttribute;
241
242  /**
243   * Called when the time information is reported when the progress bar process is operated.
244   * @since 7
245   */
246  onSeeking(callback: (event?: { time: number }) => void): VideoAttribute;
247
248  /**
249   * Called when the playback time information is reported after the operation progress bar is completed.
250   * @since 7
251   */
252  onSeeked(callback: (event?: { time: number }) => void): VideoAttribute;
253
254  /**
255   * Called when the playback progress changes.
256   * @since 7
257   */
258  onUpdate(callback: (event?: { time: number }) => void): VideoAttribute;
259
260  /**
261   * Called when playback fails.
262   * @since 7
263   */
264  onError(event: () => void): VideoAttribute;
265}
266
267/**
268 * Defines Video Component.
269 * @since 7
270 */
271declare const Video: VideoInterface;
272
273/**
274 * Defines Video Component instance.
275 * @since 7
276 */
277declare const VideoInstance: VideoAttribute;
278