chenjun

2.折叠屏展开,视频顶部遮挡

... ... @@ -49,12 +49,15 @@ export struct WDPlayerRenderView {
@State videoHeight: number = 9
@State videoRatio: number = 16 / 9
@State selfSize: Size = new Size('100%', '100%');
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@StorageProp('currentBreakpoint') @Watch("currentChanged") currentBreakpoint: string = 'sm';
@State isPad: boolean = this.currentBreakpoint == "md" || this.currentBreakpoint == "lg" ? true : false
// 是否上推视频中
@Link liftVideo: boolean
private enableAliPlayer = false
aboutToAppear() {
Logger.info(TAG, `aboutToAppear topSafeHeight = ${this.topSafeHeight} isPad = ${this.isPad}`)
MGPlayRenderViewIns.add();
insIndex++;
... ... @@ -85,7 +88,19 @@ export struct WDPlayerRenderView {
type: XComponentType.SURFACE,
libraryname: enableAliPlayer && this.enableAliPlayer ? "premierlibrary" : undefined,
controller: this.xComponentController
})
})// .animation({ duration: 500, curve: Curve.Friction })
// .animation({
// duration: 1200,
// curve: Curve.Friction,
// delay: 500,
// iterations: -1, // 设置-1表示动画无限循环
// playMode: PlayMode.Alternate,
// expectedFrameRateRange: {
// min: 20,
// max: 120,
// expected: 90,
// }
// })
.id(this.insId)
.onLoad(async (event) => {
Logger.info(TAG, 'onLoad')
... ... @@ -107,12 +122,25 @@ export struct WDPlayerRenderView {
}
})
.zIndex(1000)
// .width(this.selfSize.width)
// .height(this.selfSize.height)
// .width(this.selfSize.width)
// .height(this.selfSize.height)
}
.onAreaChange(() => {
this.updateLayout()
})
// .animation({
// duration: 1200,
// curve: Curve.Friction,
// delay: 500,
// iterations: -1, // 设置-1表示动画无限循环
// playMode: PlayMode.Alternate,
// expectedFrameRateRange: {
// min: 20,
// max: 120,
// expected: 90,
// }
// })
// .animation({ duration: 500, curve: Curve.Friction })
.backgroundColor("#000000")
.justifyContent(FlexAlign.Center)
.height('100%')
... ... @@ -124,6 +152,7 @@ export struct WDPlayerRenderView {
updateLayout() {
let info = componentUtils.getRectangleById(this.insId);
Logger.debug(TAG, "播放器区域变化:isPad " + this.isPad)
Logger.debug(TAG, "播放器区域变化: " + JSON.stringify(info))
Logger.debug(TAG, "xComponent rect: " + JSON.stringify(this.xComponentController.getXComponentSurfaceRect()))
... ... @@ -135,6 +164,7 @@ export struct WDPlayerRenderView {
this.xComponentController.setXComponentSurfaceRect({
surfaceWidth: info.size.width,
surfaceHeight: info.size.width / this.videoRatio,
offsetY: this.isPad ? this.topSafeHeight : 0
});
return
}
... ... @@ -193,7 +223,6 @@ export struct WDPlayerRenderView {
}
// if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) {
// if (info.size.width / info.size.height > this.videoWidth / this.videoHeight) {
// let scale = info.size.height / this.videoHeight;
... ... @@ -204,4 +233,13 @@ export struct WDPlayerRenderView {
// }
// }
}
currentChanged() {
if (this.currentBreakpoint == "md" || this.currentBreakpoint == "lg") {
//大屏幕 折叠屏 或者ipad
this.isPad = true
} else {
this.isPad = false
}
}
}
\ No newline at end of file
... ...