• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16import vibrator from '@ohos.vibrator';
17import router from '@ohos.router'
18import { changeOrientation, showTitleBar, playVibrateCustom, hideTitleBar } from './Util'
19
20@Entry
21@Component
22struct VideoPlayModule {
23  @State videoName: string = (router.getParams() as Record<string, string>)['videoName']
24  private pages: string = (router.getParams() as Record<string, string>)['pages']
25  @State videoSrc: Resource = (router.getParams() as Record<string, Resource>)['videoSrc']
26  @State previewUri: Resource = (router.getParams() as Record<string, Resource>)['previewUri']
27  private vibrateFileName: string = (router.getParams() as Record<string, string>)['vibrateFileName']
28  @State portrait: boolean = true
29  videoController: VideoController = new VideoController()
30
31  build() {
32    Stack({ alignContent: Alignment.TopStart }) {
33      Video({
34        src: this.videoSrc,
35        previewUri: this.previewUri,
36        controller: this.videoController,
37      })
38        .height("100%")
39        .width('100%')
40        .objectFit(ImageFit.Auto)
41        .controls(false)
42        .onStart(() => {
43          changeOrientation(false)
44          hideTitleBar()
45          playVibrateCustom(this.vibrateFileName)
46        })
47        .onClick(() => {
48          this.portrait = !this.portrait
49        })
50        .autoPlay(true)
51      Row() {
52        Button('<')
53          .fontSize(15)
54          .backgroundColor("#00222222")
55          .id('videoBack')
56          .onClick(() => {
57            changeOrientation(false)
58            showTitleBar()
59            vibrator.stopVibration()
60            router.back()
61          })
62        Text(this.videoName).fontSize(15).fontColor(Color.White)
63      }
64      .width("100%")
65      .height("10%")
66      .backgroundColor('#80191a32')
67      .visibility(this.portrait ? Visibility.Visible : Visibility.Hidden)
68    }.width('100%')
69    .height('100%')
70    .backgroundColor('#f2191a32')
71  }
72}
73