wangyujian_wd

fix:1)直播详情页面 bug 修改

... ... @@ -171,7 +171,7 @@ export struct EmptyComponent {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) {
imageString = $r('app.media.icon_no_content')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) {
imageString = $r('app.media.icon_no_appointmentMade')
imageString = $r('app.media.icon_no_appointmentMade1')
}
return imageString
}
... ...
... ... @@ -9,12 +9,14 @@ import { Logger, WindowModel } from 'wdKit/Index';
import { window } from '@kit.ArkUI';
import { devicePLSensorManager } from 'wdDetailPlayApi/Index';
import { LiveCommentComponent } from 'wdComponent/Index';
import { WDPlayerController } from 'wdPlayer/Index';
@Entry
@Component
export struct DetailPlayLivePage {
//横竖屏,默认竖屏
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
playerController: WDPlayerController = new WDPlayerController();
TAG: string = 'DetailPlayLivePage';
liveViewModel: LiveViewModel = new LiveViewModel()
@State relId: string = ''
... ... @@ -23,18 +25,19 @@ export struct DetailPlayLivePage {
@Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean
@Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean
@State tabs: string[] = []
//监听屏幕横竖屏变化
listener = mediaquery.matchMediaSync('(orientation: landscape)');
aboutToAppear(): void {
//监听屏幕横竖屏变化
let listener = mediaquery.matchMediaSync('(orientation: landscape)');
listener.on("change", (mediaQueryResult) => {
Logger.info(this.TAG, `wyj-aboutToAppear`)
this.listener?.on("change", (mediaQueryResult) => {
Logger.info(this.TAG, `change;${mediaQueryResult.matches}`)
if (mediaQueryResult.matches) {
if (mediaQueryResult?.matches) {
this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
} else {
this.displayDirection = DisplayDirection.VERTICAL
}
// WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
})
let par: Action = router.getParams() as Action;
let params = par?.params;
... ... @@ -47,7 +50,7 @@ export struct DetailPlayLivePage {
build() {
Column() {
TopPlayComponent()
TopPlayComponent({ playerController: this.playerController })
.layoutWeight(211)
TabComponent({ tabs: this.tabs })
.layoutWeight(503)
... ... @@ -60,12 +63,15 @@ export struct DetailPlayLivePage {
}
onPageShow(): void {
WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
Logger.info(this.TAG, `wyj-onPageShow`)
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
onPageHide(): void {
Logger.info(this.TAG, `wyj-onPageHide`)
devicePLSensorManager.devicePLSensorOff();
WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
this.playerController?.pause()
}
getLiveDetails() {
... ... @@ -98,7 +104,7 @@ export struct DetailPlayLivePage {
}
aboutToDisappear(): void {
Logger.info(this.TAG, `wyj-aboutToDisappear`)
}
onBackPress(): boolean | void {
... ...
... ... @@ -8,6 +8,7 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel'
import { ViewType } from 'wdConstant/Index'
import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout'
import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout'
import { StringUtils } from 'wdKit/Index'
@Component
export struct TabLiveComponent {
... ... @@ -94,15 +95,6 @@ export struct TabLiveComponent {
2.名称固定:人民日报主持人
3.内容:详情接口的简介,newIntroduction
*/
// if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId)
// && this.liveDetailsBean
// && this.liveDetailsBean.liveInfo.liveState != 'wait'
// && this.pageModel.currentPage == 1) {
// let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean
// liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction
// liveRoomItemBeanTemp.senderUserName = '人民日报主持人'
// data.barrageResponses.push(liveRoomItemBeanTemp)
// }
this.pageModel.viewType = ViewType.LOADED;
this.liveList.push(...data.barrageResponses)
if (data.barrageResponses.length === this.pageModel.pageSize) {
... ... @@ -110,6 +102,14 @@ export struct TabLiveComponent {
this.pageModel.hasMore = true;
} else {
this.pageModel.hasMore = false;
if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId)
&& this.liveDetailsBean
&& this.liveDetailsBean.liveInfo.liveState != 'wait') {
let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean
liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction
liveRoomItemBeanTemp.senderUserName = '人民日报主持人'
this.liveList.push(liveRoomItemBeanTemp)
}
}
} else {
this.pageModel.viewType = ViewType.EMPTY;
... ...
... ... @@ -91,6 +91,7 @@ export struct TabLiveItemComponent {
.objectFit(ImageFit.Auto)
.borderRadius(4)
}.onClick(() => {
this.photoList=[]
for (let item of this.item.pictureUrls) {
this.photoList.push({
width: 0,
... ...
... ... @@ -9,7 +9,7 @@ import { DisplayDirection } from 'wdConstant/Index'
export struct PlayUIComponent {
playerController: WDPlayerController = new WDPlayerController();
//菜单键是否可见
@State isMenuVisible: boolean = true
@State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true
@Consume liveDetailsBean: LiveDetailsBean
@Consume liveRoomDataBean: LiveRoomDataBean
@State currentTime: string = ''
... ... @@ -19,13 +19,26 @@ export struct PlayUIComponent {
@State isPlayStatus: boolean = true
@Consume displayDirection: DisplayDirection
onChangeMenuVisible() {
let time: number = 0
if (this.isMenuVisible) {
setTimeout(() => {
this.isMenuVisible = false
}, 5 * 1000)
} else {
clearTimeout(time)
}
}
aboutToAppear(): void {
this.onChangeMenuVisible()
//播放进度监听
this.playerController.onTimeUpdate = (position: number, duration: number) => {
this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000));
this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000));
this.progressVal = Math.floor(position * 100 / duration);
}
}
build() {
... ... @@ -178,7 +191,12 @@ export struct PlayUIComponent {
@Builder
getBottomUIComponent() {
Row() {
if (this.liveDetailsBean?.liveInfo?.liveState == 'end') {
if (this.liveDetailsBean?.liveInfo?.liveState == 'wait') {
Blank()
} else if (this.liveDetailsBean?.liveInfo?.liveState == 'running') {
this.playOrPauseBtn()
Blank()
} else if (this.liveDetailsBean?.liveInfo?.liveState == 'end') {
this.playOrPauseBtn()
Text(this.currentTime)
.fontColor(Color.White)
... ... @@ -187,9 +205,7 @@ export struct PlayUIComponent {
.margin({
left: 16
})
this.playProgressView()
Text(this.totalTime)
.fontColor(Color.White)
.fontWeight(600)
... ... @@ -197,8 +213,6 @@ export struct PlayUIComponent {
.margin({
right: 16
})
} else {
Blank()
}
if (this.liveDetailsBean?.liveInfo?.liveState == 'running'
|| this.liveDetailsBean?.liveInfo?.liveState == 'end') {
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { Logger } from 'wdKit/Index';
import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
import { PlayUIComponent } from './PlayUIComponent';
@Component
export struct TopPlayComponent {
TAG: string = 'TopPlayComponent'
@Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean
playerController: WDPlayerController = new WDPlayerController();
@State imgUrl: string = ''
... ... @@ -42,6 +44,18 @@ export struct TopPlayComponent {
.height('100%')
.width('100%')
.visibility(this.isWait ? Visibility.None : Visibility.Visible)
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
Logger.debug(this.TAG, `当前屏幕可见区域大小: currentRatio:' +${currentRatio}`)
if (isVisible && currentRatio >= 1.0) {
Logger.debug(this.TAG, `播放器-暂停. currentRatio:' +${currentRatio}`)
this.playerController.play()
}
if (!isVisible && currentRatio <= 0.0) {
Logger.debug(this.TAG, `播放器-播放. currentRatio:' +${currentRatio}`)
this.playerController.pause()
}
})
Image(this.imgUrl)
.objectFit(ImageFit.Contain)
.visibility(this.isWait ? Visibility.Visible : Visibility.None)
... ...