• 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  private php: string = (router.getParams() as Record<string, string>)['php']
30  videoController: VideoController = new VideoController()
31
32  build() {
33    Stack({ alignContent: Alignment.TopStart }) {
34      Video({
35        src: this.videoSrc,
36        previewUri: this.previewUri,
37        controller: this.videoController,
38      })
39        .height("100%")
40        .width('100%')
41        .objectFit(ImageFit.Auto)
42        .controls(false)
43        .onStart(() => {
44          changeOrientation(false)
45          hideTitleBar()
46          playVibrateCustom(this.vibrateFileName, this.php)
47        })
48        .onClick(() => {
49          this.portrait = !this.portrait
50        })
51        .autoPlay(true)
52      Row() {
53        Button('<')
54          .fontSize(15)
55          .backgroundColor("#00222222")
56          .id('videoBack')
57          .onClick(() => {
58            changeOrientation(false)
59            showTitleBar()
60            vibrator.stopVibration()
61            router.back()
62          })
63        Text(this.videoName).fontSize(15).fontColor(Color.White)
64      }
65      .width("100%")
66      .height("10%")
67      .backgroundColor('#80191a32')
68      .visibility(this.portrait ? Visibility.Visible : Visibility.Hidden)
69    }.width('100%')
70    .height('100%')
71    .backgroundColor('#f2191a32')
72  }
73}
74