zhenghy

直播缺省页

@@ -4,6 +4,8 @@ export { CompUtils } from "./src/main/ets/utils/CompUtils" @@ -4,6 +4,8 @@ export { CompUtils } from "./src/main/ets/utils/CompUtils"
4 4
5 export { EmptyComponent } from "./src/main/ets/components/view/EmptyComponent" 5 export { EmptyComponent } from "./src/main/ets/components/view/EmptyComponent"
6 6
  7 +export { LiveEmptyComponent } from './src/main/ets/components/view/LiveEmptyComponent'
  8 +
7 export { ErrorComponent } from "./src/main/ets/components/view/ErrorComponent" 9 export { ErrorComponent } from "./src/main/ets/components/view/ErrorComponent"
8 10
9 export { LoadingComponent } from "./src/main/ets/components/view/LoadingComponent" 11 export { LoadingComponent } from "./src/main/ets/components/view/LoadingComponent"
@@ -75,3 +77,5 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv @@ -75,3 +77,5 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv
75 77
76 export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent" 78 export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent"
77 79
  80 +export { WDLiveViewDefaultType } from "./src/main/ets/components/view/LiveEmptyComponent"
  81 +
@@ -6,8 +6,8 @@ const TAG = 'LiveEmptyComponent'; @@ -6,8 +6,8 @@ const TAG = 'LiveEmptyComponent';
6 /** 6 /**
7 * WDViewDefaultType 缺省页 7 * WDViewDefaultType 缺省页
8 */ 8 */
9 -export const enum WDViewDefaultType {  
10 - /// 1.默认 9 +export const enum WDLiveViewDefaultType {
  10 + /// 1.默认
11 WDViewDefaultType_Default, 11 WDViewDefaultType_Default,
12 /// 16.直播结束 12 /// 16.直播结束
13 WDViewDefaultType_NoLiveEnd, 13 WDViewDefaultType_NoLiveEnd,
@@ -24,7 +24,7 @@ export struct LiveEmptyComponent { @@ -24,7 +24,7 @@ export struct LiveEmptyComponent {
24 // private emptySize: SizeOptions = {}; 24 // private emptySize: SizeOptions = {};
25 @State emptyWidth: string | number = CommonConstants.FULL_PARENT; 25 @State emptyWidth: string | number = CommonConstants.FULL_PARENT;
26 @State emptyHeight: string | number = CommonConstants.FULL_PARENT; 26 @State emptyHeight: string | number = CommonConstants.FULL_PARENT;
27 - @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default; // 缺省图类型,传枚举 27 + @State emptyType: number = WDLiveViewDefaultType.WDViewDefaultType_Default; // 缺省图类型,传枚举
28 @State emptyButton: boolean = false 28 @State emptyButton: boolean = false
29 @State timeNum: number = 10 29 @State timeNum: number = 10
30 /** 30 /**
@@ -154,19 +154,20 @@ export struct LiveEmptyComponent { @@ -154,19 +154,20 @@ export struct LiveEmptyComponent {
154 buildNoDataTip(): string { 154 buildNoDataTip(): string {
155 Logger.info(TAG, "buildNoDataTip"); 155 Logger.info(TAG, "buildNoDataTip");
156 let contentString: string = '暂无内容' 156 let contentString: string = '暂无内容'
157 - if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { 157 + if (this.emptyType === WDLiveViewDefaultType.WDViewDefaultType_NoLiveEnd) {
158 contentString = '直播已结束' // 前方拥堵,请耐心等待 158 contentString = '直播已结束' // 前方拥堵,请耐心等待
159 - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) { 159 + } else if (this.emptyType === WDLiveViewDefaultType.WDViewDefaultType_NoLiveSuspend) {
160 contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待 160 contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待
161 } 161 }
162 return contentString 162 return contentString
163 } 163 }
  164 +
164 buildNoDataTipImage(): Resource | string { 165 buildNoDataTipImage(): Resource | string {
165 Logger.info(TAG, "buildNoDataTip"); 166 Logger.info(TAG, "buildNoDataTip");
166 let imageString: Resource | string = $r('app.media.icon_no_content') 167 let imageString: Resource | string = $r('app.media.icon_no_content')
167 - if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) { 168 + if (this.emptyType === WDLiveViewDefaultType.WDViewDefaultType_NoLiveEnd) {
168 imageString = $r('app.media.icon_no_end') 169 imageString = $r('app.media.icon_no_end')
169 - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) { 170 + } else if (this.emptyType === WDLiveViewDefaultType.WDViewDefaultType_NoLiveSuspend) {
170 imageString = $r('app.media.icon_no_liver') 171 imageString = $r('app.media.icon_no_liver')
171 } 172 }
172 return imageString 173 return imageString
@@ -6,6 +6,7 @@ import { PlayerComponent } from '../widgets/vertical/PlayerComponent'; @@ -6,6 +6,7 @@ import { PlayerComponent } from '../widgets/vertical/PlayerComponent';
6 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent'; 6 import { PlayerInfoComponent } from '../widgets/vertical/PlayerInfoComponent';
7 import { WDPlayerController } from 'wdPlayer/Index'; 7 import { WDPlayerController } from 'wdPlayer/Index';
8 import { DisplayDirection } from 'wdConstant/Index'; 8 import { DisplayDirection } from 'wdConstant/Index';
  9 +import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index';
9 10
10 const storage = LocalStorage.getShared(); 11 const storage = LocalStorage.getShared();
11 const TAG = 'DetailPlayVLivePage' 12 const TAG = 'DetailPlayVLivePage'
@@ -22,6 +23,7 @@ export struct DetailPlayVLivePage { @@ -22,6 +23,7 @@ export struct DetailPlayVLivePage {
22 @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean 23 @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean
23 @Provide isShowControl: boolean = false 24 @Provide isShowControl: boolean = false
24 @Provide liveState: string = '' 25 @Provide liveState: string = ''
  26 + @Provide playUrl: string = ''
25 @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL //横竖屏,默认竖屏 27 @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL //横竖屏,默认竖屏
26 @State relId: string = '' 28 @State relId: string = ''
27 @State contentId: string = '' 29 @State contentId: string = ''
@@ -50,30 +52,45 @@ export struct DetailPlayVLivePage { @@ -50,30 +52,45 @@ export struct DetailPlayVLivePage {
50 52
51 build() { 53 build() {
52 Column() { 54 Column() {
53 - Stack() {  
54 - PlayerComponent({  
55 - playerController: this.playerController  
56 - })  
57 -  
58 - PlayerInfoComponent({  
59 - playerController: this.playerController,  
60 - swiperController: this.swiperController,  
61 - swiperIndex: $swiperIndex 55 + // 直播结束且无回看
  56 + if (this.liveState === 'end' || !this.playUrl) {
  57 + LiveEmptyComponent({
  58 + emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveEnd
62 }) 59 })
  60 + } else {
  61 + Stack() {
  62 + // 直播暂停,仍然可以评论
  63 + if (this.liveState === 'pause') {
  64 + LiveEmptyComponent({
  65 + emptyType: WDLiveViewDefaultType.WDViewDefaultType_NoLiveSuspend
  66 + })
  67 + } else {
  68 + PlayerComponent({
  69 + playerController: this.playerController
  70 + })
  71 + }
63 72
64 - Image($r('app.media.icon_live_more'))  
65 - .width(40)  
66 - .aspectRatio(1)  
67 - .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden)  
68 - .animation({ duration: 500 })  
69 - .position({ x: '100%', y: '100%' })  
70 - .markAnchor({ x: 56, y: 56 })  
71 - .onClick(() => {  
72 - this.swiperController.showNext() 73 + PlayerInfoComponent({
  74 + playerController: this.playerController,
  75 + swiperController: this.swiperController,
  76 + swiperIndex: $swiperIndex
73 }) 77 })
  78 +
  79 + Image($r('app.media.icon_live_more'))
  80 + .width(40)
  81 + .aspectRatio(1)
  82 + .visibility(this.swiperIndex === 0 ? Visibility.Visible : Visibility.Hidden)
  83 + .animation({ duration: 500 })
  84 + .position({ x: '100%', y: '100%' })
  85 + .markAnchor({ x: 56, y: 56 })
  86 + .onClick(() => {
  87 + this.swiperController.showNext()
  88 + })
  89 + }
  90 + .height('100%')
  91 + .width('100%')
74 } 92 }
75 - .height('100%')  
76 - .width('100%') 93 +
77 94
78 } 95 }
79 .height('100%') 96 .height('100%')
@@ -86,7 +103,10 @@ export struct DetailPlayVLivePage { @@ -86,7 +103,10 @@ export struct DetailPlayVLivePage {
86 (data) => { 103 (data) => {
87 if (data.length > 0) { 104 if (data.length > 0) {
88 this.liveDetailsBean = data[0] 105 this.liveDetailsBean = data[0]
89 - this.liveState = this.liveDetailsBean.liveInfo?.liveState 106 + this.liveState = this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
  107 + if (this.liveDetailsBean.liveInfo.liveState == 'end') {
  108 + this.playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri
  109 + }
90 console.log(TAG, 'getLiveDetails', JSON.stringify((this.liveDetailsBean))) 110 console.log(TAG, 'getLiveDetails', JSON.stringify((this.liveDetailsBean)))
91 } 111 }
92 }, 112 },