liyubing

fix:直播中的节目在无法获取到播放信息流时APP异常报错且提示信息与安卓不一致

... ... @@ -38,6 +38,7 @@ export struct DetailPlayLivePage {
aboutToAppear(): void {
Logger.info(TAG, `wyj-aboutToAppear`)
this.listener?.on("change", (mediaQueryResult) => {
Logger.info(TAG, `change;${mediaQueryResult.matches}`)
if (mediaQueryResult?.matches) {
... ... @@ -85,6 +86,7 @@ export struct DetailPlayLivePage {
}
.height('100%')
.width('100%')
// 设置底部绘制延伸到导航条
}
... ...
... ... @@ -21,6 +21,8 @@ export struct PlayUIComponent {
@State isPlayStatus: boolean = true
@Consume displayDirection: DisplayDirection
@Prop isShowBottom: boolean
onChangeMenuVisible() {
if (!this.liveDetailsBean || !this.liveDetailsBean.liveInfo ||
this.liveDetailsBean?.liveInfo?.liveState === 'wait') {
... ... @@ -59,8 +61,11 @@ export struct PlayUIComponent {
if (this.liveDetailsBean && this.liveDetailsBean.liveInfo) {
this.getTopUIComponent()
this.getMiddleUIComponent()
if(this.isShowBottom){
this.getBottomUIComponent()
}
}
}
.width('100%')
.height('100%')
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { StringUtils } from 'wdKit/Index';
import { WDAliPlayerController, WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
import { PlayerConstants, WDAliPlayerController, WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
import { PlayUIComponent } from './PlayUIComponent';
import { Logger } from 'wdKit/Index';
import { PictureLoading } from '../../vertical/PictureLoading';
const TAG: string = 'TopPlayComponent'
... ... @@ -16,13 +17,37 @@ export struct TopPlayComponent {
@State isWait: boolean = false
//已结束直播
@State isEnd: boolean = false
//播放错误
@State isError: boolean = false
// loading 控制字段
@State isLoading: boolean = false
// 获取播放资源能播放了
@State isCanPlay: boolean = false
private playUrl: string = ""
private xComponentIsLoaded: boolean = false
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
this.isCanPlay = true
this.isLoading = true
this.playerController?.play()
}
this.playerController.onStatusChange = (status: number) => {
if (status === PlayerConstants.STATUS_ERROR) {
this.isError = true
this.isLoading = true
this.isCanPlay = false
} else {
this.isError = false
}
}
}
this.updateData()
... ... @@ -74,6 +99,8 @@ export struct TopPlayComponent {
WDPlayerRenderLiveView({
playerController: this.playerController,
onLoad: async () => {
this.isLoading = false
this.isError = false
this.xComponentIsLoaded = true
this.tryToPlay()
}
... ... @@ -81,18 +108,56 @@ export struct TopPlayComponent {
.height('100%')
.width('100%')
.visibility(this.isWait ? Visibility.None : Visibility.Visible)
Image(this.imgUrl)
.objectFit(ImageFit.Cover)
.visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None)
.contrast(this.isEnd ? 0.2 : 1)
.width('100%')
PlayUIComponent({ playerController: this.playerController })
PictureLoading().visibility(this.isLoading ? Visibility.None : Visibility.Visible)
// 视频播放器上的控制面板和信息
PlayUIComponent({ playerController: this.playerController, isShowBottom: this.isCanPlay })
Text('直播已结束')
.fontSize('20fp')
.fontWeight(500)
.fontColor(Color.White)
.visibility(this.isEnd ? Visibility.Visible :
Visibility.None)
Column() {
Text('直播加载中,请稍候重试')
.fontSize('20fp')
.fontWeight(500)
.margin({ top: 16 })
.fontColor(Color.White)
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
.height(28)
.backgroundColor(Color.Transparent)
.fontColor('#ffcccccc')
.border({ width: 1 })
.borderColor('#4dffffff')
.borderRadius(4)
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.isLoading = false
this.isError = false
this.xComponentIsLoaded = true
this.tryToPlay()
})
}.width('100%').visibility(this.isError ? Visibility.Visible :
Visibility.None)
}
.width('100%')
.alignSelf(ItemAlign.Center)
... ...
... ... @@ -13,6 +13,11 @@ export struct PictureLoading {
Logger.info(TAG, 'pictures preview')
}
aboutToDisappear(): void {
Logger.info(TAG, 'aboutToDisappear')
}
build() {
Row() {
Image(this.imagePath)
... ...
... ... @@ -79,6 +79,7 @@ export struct PlayerComponent {
playerController: this.playerController,
onLoad: () => {
this.isCanplay = true
console.error('WDAliPlayerController','------1------------')
this.playerController?.firstPlay(this.playUrl);
}
}).margin({ top: 195 }).height(211)
... ...