陈剑华

Merge remote-tracking branch 'origin/main'

@@ -17,6 +17,7 @@ import { componentUtils, window } from '@kit.ArkUI'; @@ -17,6 +17,7 @@ import { componentUtils, window } from '@kit.ArkUI';
17 import { PlayerFullScreenView } from '../view/PlayerFullScreenView'; 17 import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
18 import { OperRowListView, publishCommentModel } from 'wdComponent/Index'; 18 import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
19 import { ParamType, TrackConstants } from 'wdTracking/Index'; 19 import { ParamType, TrackConstants } from 'wdTracking/Index';
  20 +import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
20 21
21 const TAG = 'DetailPlayShortVideoPage'; 22 const TAG = 'DetailPlayShortVideoPage';
22 23
@@ -55,6 +56,8 @@ export struct DetailPlayShortVideoPage { @@ -55,6 +56,8 @@ export struct DetailPlayShortVideoPage {
55 @State playerHeight: number | string = px2vp(this.windowHeight) 56 @State playerHeight: number | string = px2vp(this.windowHeight)
56 pageParam: ParamType = {} 57 pageParam: ParamType = {}
57 PageName: string = '' 58 PageName: string = ''
  59 + @State toastText: ResourceStr = "正在使用非WI-FI网络,播放将产生流量费用"
  60 + @Consume onlyWifiLoadVideo: boolean
58 61
59 /** 62 /**
60 * 页面显示重查用户关注、点赞等信息 63 * 页面显示重查用户关注、点赞等信息
@@ -62,7 +65,7 @@ export struct DetailPlayShortVideoPage { @@ -62,7 +65,7 @@ export struct DetailPlayShortVideoPage {
62 async pageShowChange() { 65 async pageShowChange() {
63 if (this.currentIndex === this.index) { 66 if (this.currentIndex === this.index) {
64 this.queryNewsInfoOfUser() 67 this.queryNewsInfoOfUser()
65 - if (this.switchVideoStatus && this.isPlay) { 68 + if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
66 await this.playerController.play() 69 await this.playerController.play()
67 this.imageVisible = false 70 this.imageVisible = false
68 } 71 }
@@ -75,7 +78,7 @@ export struct DetailPlayShortVideoPage { @@ -75,7 +78,7 @@ export struct DetailPlayShortVideoPage {
75 */ 78 */
76 async videoStatusChange() { 79 async videoStatusChange() {
77 if (this.currentIndex === this.index) { 80 if (this.currentIndex === this.index) {
78 - if (this.switchVideoStatus && this.isPlay) { 81 + if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
79 await this.playerController.play() 82 await this.playerController.play()
80 this.imageVisible = false 83 this.imageVisible = false
81 } else { 84 } else {
@@ -99,9 +102,18 @@ export struct DetailPlayShortVideoPage { @@ -99,9 +102,18 @@ export struct DetailPlayShortVideoPage {
99 if (!this.playerController.getPlayer()) { 102 if (!this.playerController.getPlayer()) {
100 this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '', this.PageName, 103 this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '', this.PageName,
101 this.PageName, this.pageParam); 104 this.PageName, this.pageParam);
  105 + this.playerController.onCanplay = async () => {
  106 + this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
  107 + await this.playerController.play()
  108 + this.imageVisible = false
  109 + }
102 } else { 110 } else {
103 - await this.playerController.play()  
104 - this.imageVisible = false 111 + if (!this.onlyWifiLoadVideo) {
  112 + await this.playerController.pause()
  113 + } else {
  114 + await this.playerController.play()
  115 + this.imageVisible = false
  116 + }
105 } 117 }
106 } 118 }
107 } 119 }
@@ -156,15 +168,22 @@ export struct DetailPlayShortVideoPage { @@ -156,15 +168,22 @@ export struct DetailPlayShortVideoPage {
156 168
157 } 169 }
158 170
159 - aboutToAppear() { 171 + async aboutToAppear() {
  172 + if(await onlyWifiLoadVideo()){
  173 + this.onlyWifiLoadVideo = true
  174 + }
160 this.videoLandScape = this.contentDetailData.videoInfo[0]?.videoLandScape 175 this.videoLandScape = this.contentDetailData.videoInfo[0]?.videoLandScape
161 this.ratio = (this.contentDetailData.videoInfo[0]?.resolutionWidth || 16) / 176 this.ratio = (this.contentDetailData.videoInfo[0]?.resolutionWidth || 16) /
162 (this.contentDetailData.videoInfo[0]?.resolutionHeight || 9) 177 (this.contentDetailData.videoInfo[0]?.resolutionHeight || 9)
163 this.playerController.onCanplay = async () => { 178 this.playerController.onCanplay = async () => {
164 this.ratio = this.playerController.videoWidth / this.playerController.videoHeight 179 this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
165 if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) { 180 if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) {
166 - await this.playerController.play()  
167 - this.imageVisible = false 181 + if (!this.onlyWifiLoadVideo) {
  182 + await this.playerController.pause()
  183 + } else {
  184 + await this.playerController.play()
  185 + this.imageVisible = false
  186 + }
168 } 187 }
169 } 188 }
170 this.playerController.onTimeUpdate = (position, duration) => { 189 this.playerController.onTimeUpdate = (position, duration) => {
@@ -261,6 +280,10 @@ export struct DetailPlayShortVideoPage { @@ -261,6 +280,10 @@ export struct DetailPlayShortVideoPage {
261 playerController: this.playerController 280 playerController: this.playerController
262 }) 281 })
263 282
  283 + if (!this.onlyWifiLoadVideo) {
  284 + this.buildContent()
  285 + }
  286 +
264 } 287 }
265 .width('100%') 288 .width('100%')
266 .layoutWeight(1) 289 .layoutWeight(1)
@@ -303,6 +326,51 @@ export struct DetailPlayShortVideoPage { @@ -303,6 +326,51 @@ export struct DetailPlayShortVideoPage {
303 326
304 } 327 }
305 328
  329 + @Builder
  330 + buildContent() {
  331 + Row() {
  332 + Column(){
  333 + Column(){
  334 + Text(this.toastText)
  335 + .fontFamily('PingFang SC-Regular')
  336 + .fontWeight(FontWeight.Regular)
  337 + .fontColor('#FFFFFF')
  338 + .fontSize(14)
  339 + .lineHeight(20)
  340 + .textAlign(TextAlign.Center)
  341 + }
  342 + Column() {
  343 + Text("使用流量播放")
  344 + .fontFamily('PingFang SC-Regular')
  345 + .fontWeight(FontWeight.Regular)
  346 + .fontColor(Color.White)
  347 + .fontSize(12)
  348 + }
  349 + .border({ width: 1, color: '#4DFFFFFF', radius: 4 })
  350 + .height(28)
  351 + .width(88)
  352 + .alignItems(HorizontalAlign.Center)
  353 + .justifyContent(FlexAlign.Center)
  354 + .margin({
  355 + top: 16
  356 + })
  357 + .onClick(() => {
  358 + this.onlyWifiLoadVideo = true
  359 + this.playerController?.play()
  360 + this.imageVisible = false
  361 + })
  362 + }
  363 + .width('100%')
  364 + .height(64)
  365 + }
  366 + .width('100%')
  367 + .height('100%')
  368 + .alignItems(VerticalAlign.Center)
  369 + .justifyContent(FlexAlign.Center)
  370 + .backgroundColor('#222222')
  371 + .opacity(0.7)
  372 + }
  373 +
306 /** 374 /**
307 * 视频首帧图,用于快速显示 375 * 视频首帧图,用于快速显示
308 * 竖屏封面顶部仍然有点偏移,待处理 376 * 竖屏封面顶部仍然有点偏移,待处理
@@ -39,6 +39,7 @@ export struct DetailVideoListPage { @@ -39,6 +39,7 @@ export struct DetailVideoListPage {
39 @State interactDataList: InteractDataDTO[] = [] 39 @State interactDataList: InteractDataDTO[] = []
40 pageShowTime:number = 0; 40 pageShowTime:number = 0;
41 pageHideTime:number = 0; 41 pageHideTime:number = 0;
  42 + @Provide onlyWifiLoadVideo: boolean = false
42 43
43 async aboutToAppear(): Promise<void> { 44 async aboutToAppear(): Promise<void> {
44 // 注册监听网络连接 45 // 注册监听网络连接
@@ -9,12 +9,11 @@ import { @@ -9,12 +9,11 @@ import {
9 contentListParams, 9 contentListParams,
10 getRecCompInfoParams 10 getRecCompInfoParams
11 } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; 11 } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
12 -import { Logger, WindowModel } from 'wdKit/Index'; 12 +import { Logger, WindowModel, DateTimeUtils } from 'wdKit/Index';
13 import { PictureLoading } from './PictureLoading'; 13 import { PictureLoading } from './PictureLoading';
14 import { DisplayDirection } from 'wdConstant/Index'; 14 import { DisplayDirection } from 'wdConstant/Index';
15 import { window } from '@kit.ArkUI'; 15 import { window } from '@kit.ArkUI';
16 import { EmptyComponent, WDViewDefaultType } from 'wdComponent/Index'; 16 import { EmptyComponent, WDViewDefaultType } from 'wdComponent/Index';
17 -import { DateTimeUtils } from 'wdKit/Index';  
18 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; 17 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
19 18
20 interface loadMoreData { 19 interface loadMoreData {
@@ -65,6 +64,7 @@ export struct VideoChannelDetail { @@ -65,6 +64,7 @@ export struct VideoChannelDetail {
65 @State isRequesting: boolean = false 64 @State isRequesting: boolean = false
66 pageShowTime: number = 0; 65 pageShowTime: number = 0;
67 pageHideTime: number = 0; 66 pageHideTime: number = 0;
  67 + @Provide onlyWifiLoadVideo: boolean = false
68 68
69 autoRefreshChange() { 69 autoRefreshChange() {
70 if (this.topNavIndex === 0 && !this.isRequesting) { 70 if (this.topNavIndex === 0 && !this.isRequesting) {
@@ -13,6 +13,7 @@ export struct PlayerBottomView { @@ -13,6 +13,7 @@ export struct PlayerBottomView {
13 @Consume isDragging?: boolean 13 @Consume isDragging?: boolean
14 @Consume contentDetailData: ContentDetailDTO 14 @Consume contentDetailData: ContentDetailDTO
15 @Consume displayDirection: DisplayDirection 15 @Consume displayDirection: DisplayDirection
  16 + @Consume onlyWifiLoadVideo: boolean
16 17
17 aboutToAppear(): void { 18 aboutToAppear(): void {
18 19
@@ -14,6 +14,7 @@ export struct PlayerProgressView { @@ -14,6 +14,7 @@ export struct PlayerProgressView {
14 @State loadingTop: number = 10 14 @State loadingTop: number = 10
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 aboutToAppear() { 18 aboutToAppear() {
18 if (this.playerController) { 19 if (this.playerController) {
19 this.playerController.onStatusChange = (status: number) => { 20 this.playerController.onStatusChange = (status: number) => {
@@ -26,7 +27,9 @@ export struct PlayerProgressView { @@ -26,7 +27,9 @@ export struct PlayerProgressView {
26 this.playerController.onLoaded = (loaded: number) => { 27 this.playerController.onLoaded = (loaded: number) => {
27 if(loaded == 1) { 28 if(loaded == 1) {
28 this.loadingWidth = '95%' 29 this.loadingWidth = '95%'
29 - this.showLoading = true 30 + if (this.onlyWifiLoadVideo) {
  31 + this.showLoading = true
  32 + }
30 } else { 33 } else {
31 this.loadingWidth = 1 34 this.loadingWidth = 1
32 this.showLoading = false 35 this.showLoading = false
@@ -14,7 +14,7 @@ interface obj { @@ -14,7 +14,7 @@ interface obj {
14 @Observed 14 @Observed
15 export class WDPlayerController { 15 export class WDPlayerController {
16 private initPromise: Promise<void>; 16 private initPromise: Promise<void>;
17 - private avPlayer?: media.AVPlayer; 17 + private avPlayer?: media.AVPlayer | null;
18 private duration: number = 0; 18 private duration: number = 0;
19 private status: number = PlayerConstants.STATUS_IDLE; 19 private status: number = PlayerConstants.STATUS_IDLE;
20 private loop: boolean = true; 20 private loop: boolean = true;
@@ -196,6 +196,7 @@ export class WDPlayerController { @@ -196,6 +196,7 @@ export class WDPlayerController {
196 } 196 }
197 if (this.avPlayer == null) { 197 if (this.avPlayer == null) {
198 console.log("等待") 198 console.log("等待")
  199 + this.initPromise = this.createAVPlayer();
199 await this.initPromise; 200 await this.initPromise;
200 } else { 201 } else {
201 if (this.avPlayer.state != AVPlayerStatus.IDLE) { 202 if (this.avPlayer.state != AVPlayerStatus.IDLE) {
@@ -225,7 +226,7 @@ export class WDPlayerController { @@ -225,7 +226,7 @@ export class WDPlayerController {
225 return 226 return
226 } 227 }
227 this.avPlayer.release() 228 this.avPlayer.release()
228 - this.avPlayer = undefined 229 + this.avPlayer = null
229 230
230 } 231 }
231 232