王士厅

fix: 沉浸式播放时关闭网络,上滑视频,视频一直loading,恢复网络后,视频无法自动播放

... ... @@ -41,7 +41,7 @@ export struct PageComponent {
private pageTrackBean: PageTrackBean = new PageTrackBean()
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
@State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图
@State netStatus: number | undefined = undefined // 存储网络状态
build() {
Column() {
... ...
... ... @@ -8,7 +8,7 @@ import {
postInteractBrowsOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { HttpUtils } from 'wdNetwork/Index';
import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger, WindowModel } from 'wdKit/Index';
import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger, NetworkType, WindowModel } from 'wdKit/Index';
import { PlayerBottomView } from '../view/PlayerBottomView';
import { PlayerRightView } from '../view/PlayerRightView';
import { DisplayDirection } from 'wdConstant/Index';
... ... @@ -61,6 +61,7 @@ export struct DetailPlayShortVideoPage {
@Consume toastTextVisible: boolean
@StorageProp('currentBreakpoint') @Watch("currentChanged") currentBreakpoint: string = 'sm';
@State isPad: boolean = this.currentBreakpoint == "md" || this.currentBreakpoint == "lg" ? true : false
@State timer: number = -1
currentChanged() {
if (this.currentBreakpoint == "md" || this.currentBreakpoint == "lg") {
... ... @@ -230,6 +231,24 @@ export struct DetailPlayShortVideoPage {
///解决初始化竖屏视频时 this.ratio未更新导致显示错误
this.calculatePlayerRect()
// 注册监听网络连接
EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, (async (str?: string) => {
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(() => {
let type: NetworkType | null = null
if (str) {
type = JSON.parse(str) as NetworkType
}
// 注册监听网络连接
if (this.currentIndex === this.index && type != NetworkType.TYPE_UNKNOWN) {
console.log(TAG, '网络连接状态变化', type, 'this.currentIndex', this.currentIndex, 'this.index', this.index)
this.currentIndexChange()
}
}, 1000)
}))
}
contentTrackingDict() {
... ...
import { ContentDetailDTO } from 'wdBean/Index';
import { DateTimeUtils, ToastUtils } from 'wdKit/Index';
import { DateTimeUtils, EmitterEventId, EmitterUtils, ToastUtils } from 'wdKit/Index';
import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index';
@Reusable
... ... @@ -49,6 +49,12 @@ export struct PlayerProgressView {
this.playerController?.play()
}
}
// 注册监听网络连接
EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, (async (str?: string) => {
if (this.timer) {
clearTimeout(this.timer)
}
}))
}
/**
... ...