zhenghy

视频折叠屏适配

... ... @@ -13,7 +13,7 @@ import { PlayerBottomView } from '../view/PlayerBottomView';
import { PlayerRightView } from '../view/PlayerRightView';
import { DisplayDirection } from 'wdConstant/Index';
import { CommentDialogView } from '../view/CommentDialogView';
import { window } from '@kit.ArkUI';
import { componentUtils, window } from '@kit.ArkUI';
import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
import { ParamType, TrackConstants } from 'wdTracking/Index';
... ... @@ -207,14 +207,17 @@ export struct DetailPlayShortVideoPage {
* 屏幕变化动态计算播放器宽高
*/
calculatePlayerRect() {
let width = this.windowWidth
let height = this.windowHeight
const windowClass = WindowModel.shared.getWindowClass(); // 获取应用主窗口
const rect: window.Rect = windowClass.getWindowProperties().windowRect;
let width = rect.width
let height = rect.height
if (this.displayDirection === DisplayDirection.VERTICAL) {
width = this.windowWidth
height = this.windowHeight
width = rect.width
height = rect.height
} else {
width = this.windowHeight
height = this.windowWidth
width = rect.height
height = rect.width
}
// 视频宽高比屏幕大,则宽度撑满
if (this.ratio > width / height) {
... ... @@ -225,7 +228,7 @@ export struct DetailPlayShortVideoPage {
this.playerHeight = '100%'
this.playerWidth = px2vp(height * this.ratio)
}
console.log('calculatePlayerRect=====', this.windowWidth, this.windowHeight)
console.log('calculatePlayerRect=====', width, height)
}
... ... @@ -287,6 +290,7 @@ export struct DetailPlayShortVideoPage {
.width('100%')
}
.id('video-container')
.height('100%')
.width('100%')
.onAreaChange(() => this.calculatePlayerRect())
... ... @@ -314,7 +318,9 @@ export struct DetailPlayShortVideoPage {
@Builder
playerViewBuilder() {
Stack({alignContent: this.showCommentList && this.index === this.currentIndex ? Alignment.Top : Alignment.Center}) {
Stack({
alignContent: this.showCommentList && this.index === this.currentIndex ? Alignment.Top : Alignment.Center
}) {
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
... ...