王士厅

fix: 加载场景-进度加载_视频加载>加载中切断网络页面报错

1 import { ContentDetailDTO } from 'wdBean/Index'; 1 import { ContentDetailDTO } from 'wdBean/Index';
2 -import { DateTimeUtils } from 'wdKit/Index'; 2 +import { DateTimeUtils, ToastUtils } from 'wdKit/Index';
3 import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index'; 3 import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index';
4 4
5 @Component 5 @Component
@@ -15,6 +15,7 @@ export struct PlayerProgressView { @@ -15,6 +15,7 @@ export struct PlayerProgressView {
15 @State loadingWidth: number | string = 1 15 @State loadingWidth: number | string = 1
16 @State showLoading: boolean = false 16 @State showLoading: boolean = false
17 @Consume onlyWifiLoadVideo: boolean 17 @Consume onlyWifiLoadVideo: boolean
  18 + timer: number = 0
18 aboutToAppear() { 19 aboutToAppear() {
19 if (this.playerController) { 20 if (this.playerController) {
20 this.playerController.onSeekDone = (status: number) => { 21 this.playerController.onSeekDone = (status: number) => {
@@ -27,7 +28,11 @@ export struct PlayerProgressView { @@ -27,7 +28,11 @@ export struct PlayerProgressView {
27 if (this.onlyWifiLoadVideo) { 28 if (this.onlyWifiLoadVideo) {
28 this.showLoading = true 29 this.showLoading = true
29 } 30 }
  31 + this.timer = setTimeout(() => {
  32 + ToastUtils.shortToast('网络出小差了,请检查下网络')
  33 + }, 10000)
30 } else { 34 } else {
  35 + clearTimeout(this.timer)
31 this.loadingWidth = 1 36 this.loadingWidth = 1
32 this.showLoading = false 37 this.showLoading = false
33 } 38 }
@@ -156,7 +156,7 @@ export class WDPlayerController { @@ -156,7 +156,7 @@ export class WDPlayerController {
156 this.initProgress(time); 156 this.initProgress(time);
157 }); 157 });
158 this.avPlayer?.on(Events.ERROR, (error) => { 158 this.avPlayer?.on(Events.ERROR, (error) => {
159 - this.playError(error.message); 159 + // this.playError(error.message);
160 Logger.error(TAG, '播放错误' + JSON.stringify(error)) 160 Logger.error(TAG, '播放错误' + JSON.stringify(error))
161 TrackingPlay.videoPlayError(error.message, this.pageName, this.pageName, this.pageParam) 161 TrackingPlay.videoPlayError(error.message, this.pageName, this.pageName, this.pageParam)
162 }) 162 })
@@ -448,20 +448,20 @@ export class WDPlayerController { @@ -448,20 +448,20 @@ export class WDPlayerController {
448 448
449 Logger.debug(TAG, 'watchStatus ' + this.status) 449 Logger.debug(TAG, 'watchStatus ' + this.status)
450 if(this.status == PlayerConstants.STATUS_START){ 450 if(this.status == PlayerConstants.STATUS_START){
451 - Logger.debug(TAG, '播放视频')  
452 - Logger.debug(TAG, '播放视频prepareTime' + JSON.stringify(this.prepareTime))  
453 - Logger.debug(TAG, '播放视频pageName' + JSON.stringify(this.pageName))  
454 - Logger.debug(TAG, '播放视频pageParam' + JSON.stringify(this.pageParam)) 451 + // Logger.debug(TAG, '播放视频')
  452 + // Logger.debug(TAG, '播放视频prepareTime' + JSON.stringify(this.prepareTime))
  453 + // Logger.debug(TAG, '播放视频pageName' + JSON.stringify(this.pageName))
  454 + // Logger.debug(TAG, '播放视频pageParam' + JSON.stringify(this.pageParam))
455 // 播放埋点 455 // 播放埋点
456 TrackingPlay.videoPositivePlay(Number(this.prepareTime),this.pageName, this.pageName, this.pageParam) 456 TrackingPlay.videoPositivePlay(Number(this.prepareTime),this.pageName, this.pageName, this.pageParam)
457 } 457 }
458 if(this.status == PlayerConstants.STATUS_COMPLETION){ 458 if(this.status == PlayerConstants.STATUS_COMPLETION){
459 let initDuration = Math.floor(Number(this.duration)/1000) 459 let initDuration = Math.floor(Number(this.duration)/1000)
460 - Logger.debug(TAG, '播放结束')  
461 - Logger.debug(TAG, '播放结束currentPlayTime' + JSON.stringify(this.currentPlayTime))  
462 - Logger.debug(TAG, '播放结束initDuration' + JSON.stringify(initDuration))  
463 - Logger.debug(TAG, '播放结束pageName' + JSON.stringify(this.pageName))  
464 - Logger.debug(TAG, '播放结束pageParam' + JSON.stringify(this.pageParam)) 460 + // Logger.debug(TAG, '播放结束')
  461 + // Logger.debug(TAG, '播放结束currentPlayTime' + JSON.stringify(this.currentPlayTime))
  462 + // Logger.debug(TAG, '播放结束initDuration' + JSON.stringify(initDuration))
  463 + // Logger.debug(TAG, '播放结束pageName' + JSON.stringify(this.pageName))
  464 + // Logger.debug(TAG, '播放结束pageParam' + JSON.stringify(this.pageParam))
465 // 播放结束埋点 465 // 播放结束埋点
466 TrackingPlay.videoPlayEnd(this.currentPlayTime, initDuration, this.currentPlayTime, this.pageName, this.pageName, this.pageParam) 466 TrackingPlay.videoPlayEnd(this.currentPlayTime, initDuration, this.currentPlayTime, this.pageName, this.pageName, this.pageParam)
467 } 467 }