PlayerTitleComponent.ets
5 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import lottie from '@ohos/lottie'
import { ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { LiveFollowComponent, LottieView } from 'wdComponent/Index'
import { NumberFormatterUtils, WindowModel } from 'wdKit/Index'
import { window } from '@kit.ArkUI'
import { WDAliPlayerController } from 'wdPlayer/Index'
import { DisplayDirection } from 'wdConstant/Index'
import { WDShare } from 'wdShare/Index'
/**
* 沉浸式直播--- 头部标题
*/
@Preview
@Component
export struct PlayerTitleComponent {
@Consume liveRoomDataBean: LiveRoomDataBean
@Consume liveState: string
@Consume contentDetailData: ContentDetailDTO
@Consume displayDirection: DisplayDirection
@State isLarge:boolean = false
private playerController?: WDAliPlayerController
@Consume isFullScreen: boolean
aboutToAppear(): void {
if (!this.playerController) {
return
}
this.playerController.onVideoSizePlayerTitleComponentBack = (width: number, height: number) => {
if(width>height){
this.isLarge = false
}else{
this.isLarge = true
}
}
}
aboutToDisappear(): void {
if (this.contentDetailData.liveInfo?.liveState == 'running') {
///lottieView身上已经有单独不展示时处理销毁,不用单独在销毁了,会影响展现组件列表上相同名称的动画展示
// lottie.destroy('live_status_wait')
}
}
build() {
Column() {
Row() {
//返回键
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.aspectRatio(1)
.visibility((this.isLarge && this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) ? Visibility.Visible : Visibility.None)
.margin({
right: 10
})
.onClick(() => {
WindowModel.shared.setPreferredOrientation((this.isLarge && this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) ?
window.Orientation.PORTRAIT :
window.Orientation.LANDSCAPE)
WindowModel.shared.setSpecificSystemBarEnabled(true)
this.isLarge = false
this.displayDirection = DisplayDirection.VERTICAL
if(this.playerController){
if(this.playerController.onVideoSizePlayerComponentBack){
this.playerController.onVideoSizePlayerComponentBack(2,1);
}
// if(this.playerController.onVideoSizePlayerUIComponentMethod){
// this.playerController.onVideoSizePlayerUIComponentMethod(2,1);
// }
}
this.isFullScreen = false
})
Text(this.contentDetailData.newsTitle || '')
.maxLines(2)
.fontSize(16)
.fontWeight(500)
.fontColor(Color.White)
Blank().layoutWeight(1)
//分享按钮
Image($r('app.media.icon_share'))
.width(24)
.aspectRatio(1)
.visibility((this.isLarge && this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) ? Visibility.Visible : Visibility.None)
.margin({right:16})
.onClick(() => {
WDShare.shareContent(this.contentDetailData)
})
}.margin({ bottom: 10 })
Row() {
this.getLiveStatusView()
}
.margin({left: this.contentDetailData.rmhInfo?.rmhName ? 0 : 34})
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.padding({
top: 12,
left: 16
})
}
@Builder
getLiveStatusView() {
if (this.contentDetailData.rmhInfo?.rmhName) {
LiveFollowComponent({
rmhInfo: this.contentDetailData.rmhInfo
}).margin({
right: 10
})
}
if (this.liveRoomDataBean.liveId) {
Row() {
if (this.liveState == 'running') {
Stack() {
Image($r('app.media.icon_live_status_running_back'))
.width(22)
.height(18)
LottieView({
name: 'live_status_wait',
path: "lottie/live_detail_living.json",
lottieWidth: 9,
lottieHeight: 9,
autoplay: true,
loop: true,
})
.margin({ right: 2 })
}.margin({ right: 1 })
// Image($r('app.media.icon_live_status_running'))
// .width(22)
// .height(18)
// .margin({ right: 1 })
}
Text(this.liveState == 'running' ? '直播中' : '回看')
.fontSize(11)
.fontWeight(400)
.fontColor(Color.White)
if (this.liveRoomDataBean.pv > 0) {
Image($r('app.media.icon_live_player_status_end'))
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
}
.backgroundColor('#4D000000')
.borderRadius(2)
.padding(this.liveState == 'running' ? {
left: 0,
right: 4,
top: 0,
bottom: 0
} : 4)
}
}
}