PlayerTitle.ets
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import router from '@ohos.router';
import window from '@ohos.window';
import deviceInfo from '@ohos.deviceInfo';
import { WindowModel } from 'wdKit';
import { WDPlayerController } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
@Component
export struct PlayerTitle {
private playerController?: WDPlayerController;
@Consume title?: string
@Consume isFullScreen: boolean;
@State @Watch('watchSpeed') playSpeed: number = 1;
aboutToAppear() {
}
watchSpeed() {
this.playerController?.setSpeed(this.playSpeed);
}
build() {
Row() {
Image($r('app.media.ic_back'))
.width(44)
.padding(13)
.aspectRatio(1)
.onClick(() => {
if (this.isFullScreen) {
if (deviceInfo.deviceType != "phone") {
WindowModel.shared.getWindowSize().then((size) => {
if (size.width > size.height) {
router.back();
} else {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
}
})
} else {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
}
} else {
router.back();
}
})
Text(this.title)
.fontColor(Color.White)
.fontSize('14fp')
.maxLines(2)
.layoutWeight(1)
}.alignItems(VerticalAlign.Center)
}
}