zhenghy

视频折叠屏适配

@@ -13,7 +13,7 @@ import { PlayerBottomView } from '../view/PlayerBottomView'; @@ -13,7 +13,7 @@ import { PlayerBottomView } from '../view/PlayerBottomView';
13 import { PlayerRightView } from '../view/PlayerRightView'; 13 import { PlayerRightView } from '../view/PlayerRightView';
14 import { DisplayDirection } from 'wdConstant/Index'; 14 import { DisplayDirection } from 'wdConstant/Index';
15 import { CommentDialogView } from '../view/CommentDialogView'; 15 import { CommentDialogView } from '../view/CommentDialogView';
16 -import { window } from '@kit.ArkUI'; 16 +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';
@@ -207,14 +207,17 @@ export struct DetailPlayShortVideoPage { @@ -207,14 +207,17 @@ export struct DetailPlayShortVideoPage {
207 * 屏幕变化动态计算播放器宽高 207 * 屏幕变化动态计算播放器宽高
208 */ 208 */
209 calculatePlayerRect() { 209 calculatePlayerRect() {
210 - let width = this.windowWidth  
211 - let height = this.windowHeight 210 + const windowClass = WindowModel.shared.getWindowClass(); // 获取应用主窗口
  211 + const rect: window.Rect = windowClass.getWindowProperties().windowRect;
  212 +
  213 + let width = rect.width
  214 + let height = rect.height
212 if (this.displayDirection === DisplayDirection.VERTICAL) { 215 if (this.displayDirection === DisplayDirection.VERTICAL) {
213 - width = this.windowWidth  
214 - height = this.windowHeight 216 + width = rect.width
  217 + height = rect.height
215 } else { 218 } else {
216 - width = this.windowHeight  
217 - height = this.windowWidth 219 + width = rect.height
  220 + height = rect.width
218 } 221 }
219 // 视频宽高比屏幕大,则宽度撑满 222 // 视频宽高比屏幕大,则宽度撑满
220 if (this.ratio > width / height) { 223 if (this.ratio > width / height) {
@@ -225,7 +228,7 @@ export struct DetailPlayShortVideoPage { @@ -225,7 +228,7 @@ export struct DetailPlayShortVideoPage {
225 this.playerHeight = '100%' 228 this.playerHeight = '100%'
226 this.playerWidth = px2vp(height * this.ratio) 229 this.playerWidth = px2vp(height * this.ratio)
227 } 230 }
228 - console.log('calculatePlayerRect=====', this.windowWidth, this.windowHeight) 231 + console.log('calculatePlayerRect=====', width, height)
229 232
230 } 233 }
231 234
@@ -287,6 +290,7 @@ export struct DetailPlayShortVideoPage { @@ -287,6 +290,7 @@ export struct DetailPlayShortVideoPage {
287 .width('100%') 290 .width('100%')
288 291
289 } 292 }
  293 + .id('video-container')
290 .height('100%') 294 .height('100%')
291 .width('100%') 295 .width('100%')
292 .onAreaChange(() => this.calculatePlayerRect()) 296 .onAreaChange(() => this.calculatePlayerRect())
@@ -314,7 +318,9 @@ export struct DetailPlayShortVideoPage { @@ -314,7 +318,9 @@ export struct DetailPlayShortVideoPage {
314 318
315 @Builder 319 @Builder
316 playerViewBuilder() { 320 playerViewBuilder() {
317 - Stack({alignContent: this.showCommentList && this.index === this.currentIndex ? Alignment.Top : Alignment.Center}) { 321 + Stack({
  322 + alignContent: this.showCommentList && this.index === this.currentIndex ? Alignment.Top : Alignment.Center
  323 + }) {
318 WDPlayerRenderView({ 324 WDPlayerRenderView({
319 playerController: this.playerController, 325 playerController: this.playerController,
320 onLoad: async () => { 326 onLoad: async () => {