liyubing

feat: 文字直播

@@ -68,19 +68,35 @@ export struct DetailPlayLiveCommon { @@ -68,19 +68,35 @@ export struct DetailPlayLiveCommon {
68 */ 68 */
69 getContentDetail() { 69 getContentDetail() {
70 this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType) 70 this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
71 - .then((data: Array<ContentDetailDTO>) => { 71 + .then(async (data: Array<ContentDetailDTO>) => {
72 console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data)) 72 console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data))
73 if (data) { 73 if (data) {
  74 +
74 let detailData = data[0] 75 let detailData = data[0]
  76 + //人民号类型单独获取直播地址
  77 + if (detailData.rmhPlatform === 1) {
  78 +
  79 + let vliveId = detailData.liveInfo.vlive[0].vliveId as string
  80 + console.error(TAG, 'vliveId==' + vliveId)
  81 + let pullStreamAddressData = await this.liveViewModel.getLiveRoomPullAddress(vliveId) as GetPullAddressBean
  82 +
  83 + if (pullStreamAddressData) {
  84 + console.log(TAG, ' GetPullAddressBean:', JSON.stringify(pullStreamAddressData))
  85 + let m3u8uUrl = pullStreamAddressData.transCode[0].m3u8Url
  86 + detailData.liveInfo.vlive[0].liveUrl = m3u8uUrl
  87 + this.playUrl = m3u8uUrl
  88 + console.log(TAG, ' GetPullAddressBean:', m3u8uUrl)
  89 + }
  90 +
  91 + }
  92 +
75 this.liveLandscape = 93 this.liveLandscape =
76 - detailData?.liveInfo?.liveLandScape //String(this.contentDetailData?.liveInfo?.liveLandScape || '') 94 + detailData?.liveInfo?.liveLandScape
77 95
78 this.liveState = detailData.liveInfo?.liveState 96 this.liveState = detailData.liveInfo?.liveState
79 97
80 -  
81 this.contentDetailData = data[0] 98 this.contentDetailData = data[0]
82 99
83 - console.log(TAG, '查询视频详情用于评论展示 openComment:', detailData.openComment)  
84 this.publishCommentModel.targetId = String(detailData?.newsId || '') 100 this.publishCommentModel.targetId = String(detailData?.newsId || '')
85 this.publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '') 101 this.publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '')
86 this.publishCommentModel.targetTitle = detailData?.newsTitle 102 this.publishCommentModel.targetTitle = detailData?.newsTitle
@@ -100,18 +116,6 @@ export struct DetailPlayLiveCommon { @@ -100,18 +116,6 @@ export struct DetailPlayLiveCommon {
100 this.playUrl = detailData.liveInfo.vlive[0].replayUri 116 this.playUrl = detailData.liveInfo.vlive[0].replayUri
101 } 117 }
102 118
103 - //人民号类型单独获取直播地址  
104 - if (detailData.rmhPlatform === 1) {  
105 -  
106 - let vliveId = detailData.liveInfo.vlive[0].vliveId as string  
107 - console.error(TAG, 'vliveId==' + vliveId)  
108 - this.liveViewModel.getLiveRoomPullAddress(vliveId)  
109 - .then((data: GetPullAddressBean) => {  
110 - console.log(TAG, ' GetPullAddressBean:', JSON.stringify(data))  
111 -  
112 - })  
113 -  
114 - }  
115 119
116 } 120 }
117 }) 121 })
@@ -27,14 +27,7 @@ export class LiveViewModel { @@ -27,14 +27,7 @@ export class LiveViewModel {
27 27
28 } 28 }
29 29
30 - getLiveRoomPullAddress(vliveId:string){  
31 - // return new Promise<GetPullAddressBean>((success, fail) => {  
32 - // this.liveModel.getContentDetail(contentId, relId, relType).then((data) => {  
33 - // success(data)  
34 - // }).catch((message: string) => {  
35 - // fail(message)  
36 - // })  
37 - // }) 30 + async getLiveRoomPullAddress(vliveId:string) : Promise<GetPullAddressBean>{
38 31
39 return new Promise<GetPullAddressBean>((success, fail) => { 32 return new Promise<GetPullAddressBean>((success, fail) => {
40 ContentDetailRequest.getLiveRoomPullStream(vliveId).then(async (resDTO: ResponseDTO<GetPullAddressBean>) => { 33 ContentDetailRequest.getLiveRoomPullStream(vliveId).then(async (resDTO: ResponseDTO<GetPullAddressBean>) => {
@@ -15,6 +15,7 @@ export struct TopPlayComponent { @@ -15,6 +15,7 @@ export struct TopPlayComponent {
15 playerController?: WDAliPlayerController 15 playerController?: WDAliPlayerController
16 // 预告片图片/视频url 16 // 预告片图片/视频url
17 @State previewUrl: string = '' 17 @State previewUrl: string = ''
  18 + // 预告资源是否是视频资源
18 @State isVideoSource: boolean = false 19 @State isVideoSource: boolean = false
19 //未开始 20 //未开始
20 @State isWait: boolean = false 21 @State isWait: boolean = false
@@ -61,6 +62,9 @@ export struct TopPlayComponent { @@ -61,6 +62,9 @@ export struct TopPlayComponent {
61 this.updateData() 62 this.updateData()
62 } 63 }
63 64
  65 + /**
  66 + * 更新直播播放数据
  67 + */
64 updateData() { 68 updateData() {
65 // 检测等待中的直播预告是否视频资源 69 // 检测等待中的直播预告是否视频资源
66 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1 70 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1
@@ -91,8 +95,11 @@ export struct TopPlayComponent { @@ -91,8 +95,11 @@ export struct TopPlayComponent {
91 } 95 }
92 } 96 }
93 97
  98 +
94 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' && 99 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' &&
95 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri) 100 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)
  101 +
  102 + Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)
96 if (!this.isWait && this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) { 103 if (!this.isWait && this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) {
97 let playUrl = '' 104 let playUrl = ''
98 if (this.contentDetailData.liveInfo.liveState == 'running') { 105 if (this.contentDetailData.liveInfo.liveState == 'running') {
@@ -105,17 +112,29 @@ export struct TopPlayComponent { @@ -105,17 +112,29 @@ export struct TopPlayComponent {
105 this.playUrl = this.previewUrl 112 this.playUrl = this.previewUrl
106 this.tryToPlay() 113 this.tryToPlay()
107 } else { 114 } else {
  115 + Logger.debug(TAG, `---0------>${playUrl}`)
108 if (StringUtils.isNotEmpty(playUrl)) { 116 if (StringUtils.isNotEmpty(playUrl)) {
109 - Logger.debug(TAG, `${playUrl}`)  
110 this.playUrl = playUrl 117 this.playUrl = playUrl
111 this.tryToPlay() 118 this.tryToPlay()
112 } 119 }
113 } 120 }
  121 + }
114 122
  123 + // 文字直播 running 状态
  124 + if (this.contentDetailData?.liveInfo?.liveWay === 1 && this.contentDetailData?.liveInfo?.liveState === 'running') {
  125 + this.isWait = true
  126 + this.isLoading = true
  127 + if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) {
  128 + this.previewUrl = this.contentDetailData.fullColumnImgUrls[0].url
  129 + } else {
  130 + this.previewUrl = ''
  131 + }
115 } 132 }
  133 +
116 } 134 }
117 135
118 tryToPlay() { 136 tryToPlay() {
  137 + Logger.debug(TAG, `---1------>`)
119 if (!this.xComponentIsLoaded) { 138 if (!this.xComponentIsLoaded) {
120 Logger.debug(TAG, "需要xComponent加载完成") 139 Logger.debug(TAG, "需要xComponent加载完成")
121 return 140 return
@@ -136,6 +155,7 @@ export struct TopPlayComponent { @@ -136,6 +155,7 @@ export struct TopPlayComponent {
136 this.isLoading = false 155 this.isLoading = false
137 this.isError = false 156 this.isError = false
138 this.xComponentIsLoaded = true 157 this.xComponentIsLoaded = true
  158 + Logger.debug(TAG, `---onLoad------>`)
139 this.tryToPlay() 159 this.tryToPlay()
140 } 160 }
141 }) 161 })
@@ -149,6 +169,7 @@ export struct TopPlayComponent { @@ -149,6 +169,7 @@ export struct TopPlayComponent {
149 // 直播房间图 169 // 直播房间图
150 Image(this.previewUrl) 170 Image(this.previewUrl)
151 .objectFit(ImageFit.Cover) 171 .objectFit(ImageFit.Cover)
  172 + .alt($r('app.media.live_room_image_fail'))
152 .visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None) 173 .visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None)
153 .contrast(this.isEnd ? 0.2 : 1) 174 .contrast(this.isEnd ? 0.2 : 1)
154 .width('100%') 175 .width('100%')
@@ -16,6 +16,7 @@ export struct PlayerComponent { @@ -16,6 +16,7 @@ export struct PlayerComponent {
16 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 16 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
17 @State imgUrl: string = '' 17 @State imgUrl: string = ''
18 @State isWait: boolean = false 18 @State isWait: boolean = false
  19 + // 0-横屏流画面,1-竖屏幕流画面
19 @State liveStreamType: number | null = -1 20 @State liveStreamType: number | null = -1
20 @State playUrl: string = '' 21 @State playUrl: string = ''
21 @State isCanplay: boolean = false 22 @State isCanplay: boolean = false