王士厅

fix: 沉浸式播放,断网后上滑,视频无法加载和上滑,恢复网络后视频重新播放,无法上滑切换下一个视频

import { Action,
ContentDetailDTO, ContentDTO, InteractDataDTO, PeopleShipNextListDTO } from 'wdBean/Index';
import { NetworkUtil, WindowModel } from 'wdKit';
import { EmitterEventId, EmitterUtils, NetworkType, NetworkUtil, WindowModel } from 'wdKit';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { ResponseDTO } from 'wdNetwork/Index';
import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
... ... @@ -55,6 +55,7 @@ export struct DetailVideoListPage {
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
@StorageLink('GestureLoadStrategy') GestureLoadStrategy: number = 0
@State timer: number = -1
// async getRmhDetail() {
// // 注册监听网络连接
... ... @@ -119,6 +120,30 @@ export struct DetailVideoListPage {
this.getDetail()
}
// 注册监听网络连接
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 (type != NetworkType.TYPE_UNKNOWN) {
console.log(TAG, '网络连接状态变化', type)
if(type == NetworkType.TYPE_CELLULAR || type == NetworkType.TYPE_WIFI) {
if (!this.peopleShipHomeCreatorId) {
this.queryVideoList()
} else {
this.getRmhPublishNexts(this.peopleShipHomeCreatorId, `${this.data[this.currentIndex].newsId}`, 1, 1, 10, systemDateTime.getTime(false));
}
}
}
}, 1000)
}))
}
... ... @@ -443,7 +468,9 @@ export struct DetailVideoListPage {
.displayCount(1, true)
.onChange((index: number) => {
this.currentIndex = index
if (this.currentIndex === this.data.length - 1) {
// if (this.currentIndex === this.data.length - 1) {
// 倒数第二个开始请求下一页数据解决视频上滑卡顿
if (this.currentIndex === this.data.length - 2) {
// TODO:下拉刷新“努力加载中”
if (!this.peopleShipHomeCreatorId) {
this.queryVideoList()
... ...
... ... @@ -9,7 +9,9 @@ import {
contentListParams,
getRecCompInfoParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { NetworkUtil, Logger, WindowModel, DateTimeUtils, LazyDataSource } from 'wdKit/Index';
import { NetworkUtil, Logger, WindowModel, DateTimeUtils, LazyDataSource, EmitterUtils,
EmitterEventId,
NetworkType} from 'wdKit/Index';
import { PictureLoading } from './PictureLoading';
import { DisplayDirection } from 'wdConstant/Index';
import { window } from '@kit.ArkUI';
... ... @@ -70,6 +72,7 @@ export struct VideoChannelDetail {
@Provide onlyWifiLoadVideo: boolean = false
@Provide toastTextVisible: boolean = false
@StorageLink('GestureLoadStrategy') GestureLoadStrategy: number = 0
@State timer: number = -1
autoRefreshChange() {
if (this.topNavIndex === 0 && !this.isRequesting) {
... ... @@ -140,6 +143,25 @@ export struct VideoChannelDetail {
aboutToAppear() {
this.getDetail()
// Logger.info(TAG, 'aboutToAppear');
// 注册监听网络连接
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 (type != NetworkType.TYPE_UNKNOWN) {
console.log(TAG, '网络连接状态变化', type)
if(type == NetworkType.TYPE_CELLULAR || type == NetworkType.TYPE_WIFI) {
this.getRecCompInfo()
}
}
}, 1000)
}))
}
aboutToDisappear(): void {
... ... @@ -331,7 +353,9 @@ export struct VideoChannelDetail {
this.currentIndex = index
// console.info('onChange==', index.toString())
if (this.currentIndex === this.data.length - 1) {
// if (this.currentIndex === this.data.length - 1) {
// 倒数第二个开始请求下一页数据解决视频上滑卡顿
if (this.currentIndex === this.data.length - 2) {
this.pageNum++
this.refreshTime = new Date().getTime()
this.loadStrategy = 'push_up'
... ...