• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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@Entry
17@Component
18struct Index {
19  @State isPlaying: boolean = false
20  videoController: VideoController = new VideoController()
21
22  build() {
23    Column() {
24      Row() {
25        Text($r('app.string.entry_MainAbility'))
26          .fontSize(20)
27          .fontColor(Color.White)
28          .textAlign(TextAlign.Center)
29      }
30      .height('6%')
31      .width('100%')
32      .padding({ left: 15 })
33      .backgroundColor('#0D9FFB')
34      .constraintSize({ minHeight: 50 })
35
36      Video({
37        src: $r('app.media.movie'),
38        currentProgressRate: PlaybackSpeed.Speed_Forward_1_00_X,
39        controller: this.videoController
40      })
41        .width('95%')
42        .height('90%')
43        .margin(5)
44        .loop(false)
45        .muted(false)
46        .autoPlay(false)
47        .controls(true)
48        .objectFit(ImageFit.Contain)
49        .onClick(() => {
50          if (this.isPlaying) {
51            this.videoController.pause()
52          } else {
53            this.videoController.start()
54          }
55        })
56        .onStart(() => {
57          this.isPlaying = true
58        })
59        .onPause(() => {
60          this.isPlaying = false
61        })
62    }
63    .width('100%')
64    .height('100%')
65  }
66}