PlayerDetailContainer.ets
2.76 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* 详情view&播放器view的容器布局组件
*/
@Component
export struct PlayerDetailContainer {
@BuilderParam playerView: () => void
@BuilderParam playControlView: () => void
@BuilderParam detailView: () => void
@Consume isFullScreen: boolean
@Consume videoLandScape?: number // 视频朝向, 横屏视频:1;竖屏视频:2
aboutToAppear() {
console.log(`PlayerDetailContainer aboutToAppear`)
}
buildVideoHeight() {
let videoHeight: string | number = 200
if (this.videoLandScape == 2) {
videoHeight = '100%'
} else {
videoHeight = 200
}
console.log(`PlayerDetailContainer buildVideoHeight:${videoHeight} `)
return videoHeight
}
buildVideoTo() {
let videoTop: number;
if (this.videoLandScape == 2) {
videoTop = 0
} else {
videoTop = 174
}
console.log(`PlayerDetailContainer videoTop:${videoTop} `)
return videoTop
}
buildVideoBottom() {
let videoBottom: number;
if (this.videoLandScape == 2) {
videoBottom = 0
} else {
videoBottom = 320
}
console.log(`PlayerDetailContainer buildVideoBottom:${videoBottom} `)
return videoBottom
}
isShowBottomView() {
console.log(`PlayerDetailContainer videoLandScape:${this.videoLandScape} `)
let isShowBottom: boolean = false
if (this.isFullScreen) {
isShowBottom = false
} else {
isShowBottom = true
}
console.log(`PlayerDetailContainer isShowBottom:${isShowBottom} `)
return isShowBottom
}
build() {
RelativeContainer() {
Stack() {
Row() {
this.playerView()
}
.height('100%')
.width('100%')
.zIndex(0)
Row() {
this.playControlView()
}
.height('100%')
.width('100%')
.zIndex(1)
}
.width('100%')
// .aspectRatio(this.isFullScreen ? 0.1 : 16 / 9.0) // 若width值确定,当aspectRatio值越小,则height值越大
.height(this.isFullScreen ? '100%' : this.buildVideoHeight())
.margin({ top: this.isFullScreen ? 0 : this.buildVideoTo() })
// .margin({ bottom: this.isFullScreen ? 0 : this.buildVideoBottom() })
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
// middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id('stk_player_container')
if (this.isShowBottomView()) {
Row() {
this.detailView()
}
.width('100%')
// .opacity(0.3)
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
// middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id('row_bottomView')
}
}
.width('100%')
.height('100%')
}
}