wangliang_wd

feat:优化视频详情页转全屏问题

... ... @@ -4,6 +4,7 @@ import { Logger, WindowModel } from 'wdKit';
import { enableAliPlayer } from '../utils/GlobalSetting';
import json from '@ohos.util.json';
import { JSON } from '@kit.ArkTS';
import { window } from '@kit.ArkUI';
class Size {
width: Length = "100%";
... ... @@ -159,13 +160,34 @@ export struct WDPlayerRenderView {
if (info.size.width > 0 && info.size.height > 0) {
if (!this.liftVideo) {
//解决全屏展示问题
const windowClass = WindowModel.shared.getWindowClass(); // 获取应用主窗口
const rect: window.Rect = windowClass.getWindowProperties().windowRect;
let ratio = this.videoWidth / this.videoHeight
const height = info.size.width / ratio
Logger.debug(TAG, "ratio = " + ratio + " ==> new height = " + height)
let width = rect.width
let height = rect.height
let playerWidth = 0
let playerHeight = 0
width = rect.width
height = rect.height
// 视频宽高比屏幕大,则宽度撑满
//console.log(`cj2024 ratio = ${this.ratio} width / height = ${width / height}`)
if (ratio > width / height) {
playerWidth = width
playerHeight = width / ratio
} else {
// 否则高度撑满
playerHeight = height
playerWidth = height * ratio
}
// const height = info.size.width / ratio
Logger.debug(TAG, "ratio = " + ratio + " ==> new height = " + playerHeight)
if (this.videoHeight > 0 && this.videoWidth > 0) {
this.xComponentController.setXComponentSurfaceRect({
surfaceWidth: info.size.width,
surfaceHeight: info.size.width / this.videoRatio,
surfaceWidth: playerWidth,
surfaceHeight: playerHeight,
// offsetY: this.isPad ? this.topSafeHeight : (info.size.height - height) / 2
});
return
... ...