LiveDetailPageLogic.ets
3.37 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
import { ContentDetailDTO } from 'wdBean/Index'
const TAG = 'LiveDetailPageLogic'
/**
* 直播信息对象逻辑加工处理的工具类
*/
export class LiveDetailPageLogic {
// 直播状态
liveState: string = ''
// 横屏或竖屏 general-竖屏,news-横屏
liveLandscape: string = ''
// 直播样式 0-正常模式,1-隐藏直播 2-隐藏大家聊
liveStyle: number = -1
// 预告片图片/视频url
imgUrl: string = ''
// 垫片资源
padImageUri:string = ''
// 垫片是否开启
showPad:boolean = false
/**
* 直播详情页面,展示的直播信息对象
*/
contentDetailData: ContentDetailDTO = new ContentDetailDTO
/**
* 横屏直播
* @returns true:横屏直播;false:竖屏直播
*/
isLangScapeScreenVideo(): boolean {
return this.liveState === 'wait' || this.liveLandscape === 'news'
}
/**
* 竖屏直播
* @returns
*/
isVerticalScreenVideo(): boolean {
return this.liveLandscape === 'general'
}
/**
* 解析直播间的图片资源
*/
resolvingRoomImgSource() {
// 背景图资源
if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewUrl &&
this.contentDetailData.liveInfo.previewUrl.length > 0) {
this.imgUrl = this.contentDetailData.liveInfo.previewUrl
} else if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) {
this.imgUrl = this.contentDetailData.fullColumnImgUrls[0].url
}
// 垫图资源
if (this.contentDetailData.liveInfo){
if(this.contentDetailData.liveInfo.padImageUri.length > 0){
this.padImageUri =this.contentDetailData.liveInfo.padImageUri
}
//this.padImageUri = 'https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20240515/image/display/cdb84fe86b1440d58f3fc585841b928d.jpg'
}
console.log(TAG, ' this.imgUrl===>', this.imgUrl)
}
/**
* 解析直播详情里面的 vlive资源
* @param index
*/
resolvingRoomVliveData(index:number){
// 只有直播中的才会有垫片
if(this.liveState === 'running'){
if (this.contentDetailData.liveInfo.vlive.count > 0) {
this.showPad = this.contentDetailData.liveInfo.vlive[index].showPad
}
}
}
getLiveCoverUrl() {
if (this.contentDetailData.fullColumnImgUrls.length > 0) {
return this.contentDetailData.fullColumnImgUrls[0].url
}
return ''
}
dealOrShowToast(): boolean {
if (this.liveState == 'wait') {
if (this.contentDetailData.liveInfo
&& this.contentDetailData.liveInfo.previewUrl.length > 0
&& this.contentDetailData.liveInfo.previewType == 1) { ///预告视频
return true
}
}
if (this.liveState == 'running') {
if (this.contentDetailData.liveInfo.liveWay == 0) { ///直播视频
return true
}
}
return false
}
dealLiveStreamType(): boolean | null {
if (this.contentDetailData.liveInfo.vlive && this.contentDetailData.liveInfo.vlive.count > 0) {
const liveStreamType: number | null = this.contentDetailData.liveInfo.vlive[0].liveStreamType
if (liveStreamType == null) { ///直播流画面类型位置
return null
}
if (liveStreamType == 1) { ///后台选择的竖屏流
return true
}
if (liveStreamType == 0) { ///后台选择的横屏流
return false
}
}
return true
}
}