chenjun

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

@@ -49,12 +49,15 @@ export struct WDPlayerRenderView { @@ -49,12 +49,15 @@ export struct WDPlayerRenderView {
49 @State videoHeight: number = 9 49 @State videoHeight: number = 9
50 @State videoRatio: number = 16 / 9 50 @State videoRatio: number = 16 / 9
51 @State selfSize: Size = new Size('100%', '100%'); 51 @State selfSize: Size = new Size('100%', '100%');
52 - 52 + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
  53 + @StorageProp('currentBreakpoint') @Watch("currentChanged") currentBreakpoint: string = 'sm';
  54 + @State isPad: boolean = this.currentBreakpoint == "md" || this.currentBreakpoint == "lg" ? true : false
53 // 是否上推视频中 55 // 是否上推视频中
54 @Link liftVideo: boolean 56 @Link liftVideo: boolean
55 private enableAliPlayer = false 57 private enableAliPlayer = false
56 58
57 aboutToAppear() { 59 aboutToAppear() {
  60 + Logger.info(TAG, `aboutToAppear topSafeHeight = ${this.topSafeHeight} isPad = ${this.isPad}`)
58 MGPlayRenderViewIns.add(); 61 MGPlayRenderViewIns.add();
59 62
60 insIndex++; 63 insIndex++;
@@ -85,7 +88,19 @@ export struct WDPlayerRenderView { @@ -85,7 +88,19 @@ export struct WDPlayerRenderView {
85 type: XComponentType.SURFACE, 88 type: XComponentType.SURFACE,
86 libraryname: enableAliPlayer && this.enableAliPlayer ? "premierlibrary" : undefined, 89 libraryname: enableAliPlayer && this.enableAliPlayer ? "premierlibrary" : undefined,
87 controller: this.xComponentController 90 controller: this.xComponentController
88 - }) 91 + })// .animation({ duration: 500, curve: Curve.Friction })
  92 + // .animation({
  93 + // duration: 1200,
  94 + // curve: Curve.Friction,
  95 + // delay: 500,
  96 + // iterations: -1, // 设置-1表示动画无限循环
  97 + // playMode: PlayMode.Alternate,
  98 + // expectedFrameRateRange: {
  99 + // min: 20,
  100 + // max: 120,
  101 + // expected: 90,
  102 + // }
  103 + // })
89 .id(this.insId) 104 .id(this.insId)
90 .onLoad(async (event) => { 105 .onLoad(async (event) => {
91 Logger.info(TAG, 'onLoad') 106 Logger.info(TAG, 'onLoad')
@@ -107,12 +122,25 @@ export struct WDPlayerRenderView { @@ -107,12 +122,25 @@ export struct WDPlayerRenderView {
107 } 122 }
108 }) 123 })
109 .zIndex(1000) 124 .zIndex(1000)
110 - // .width(this.selfSize.width)  
111 - // .height(this.selfSize.height) 125 + // .width(this.selfSize.width)
  126 + // .height(this.selfSize.height)
112 } 127 }
113 .onAreaChange(() => { 128 .onAreaChange(() => {
114 this.updateLayout() 129 this.updateLayout()
115 }) 130 })
  131 + // .animation({
  132 + // duration: 1200,
  133 + // curve: Curve.Friction,
  134 + // delay: 500,
  135 + // iterations: -1, // 设置-1表示动画无限循环
  136 + // playMode: PlayMode.Alternate,
  137 + // expectedFrameRateRange: {
  138 + // min: 20,
  139 + // max: 120,
  140 + // expected: 90,
  141 + // }
  142 + // })
  143 + // .animation({ duration: 500, curve: Curve.Friction })
116 .backgroundColor("#000000") 144 .backgroundColor("#000000")
117 .justifyContent(FlexAlign.Center) 145 .justifyContent(FlexAlign.Center)
118 .height('100%') 146 .height('100%')
@@ -124,6 +152,7 @@ export struct WDPlayerRenderView { @@ -124,6 +152,7 @@ export struct WDPlayerRenderView {
124 updateLayout() { 152 updateLayout() {
125 153
126 let info = componentUtils.getRectangleById(this.insId); 154 let info = componentUtils.getRectangleById(this.insId);
  155 + Logger.debug(TAG, "播放器区域变化:isPad " + this.isPad)
127 Logger.debug(TAG, "播放器区域变化: " + JSON.stringify(info)) 156 Logger.debug(TAG, "播放器区域变化: " + JSON.stringify(info))
128 157
129 Logger.debug(TAG, "xComponent rect: " + JSON.stringify(this.xComponentController.getXComponentSurfaceRect())) 158 Logger.debug(TAG, "xComponent rect: " + JSON.stringify(this.xComponentController.getXComponentSurfaceRect()))
@@ -135,6 +164,7 @@ export struct WDPlayerRenderView { @@ -135,6 +164,7 @@ export struct WDPlayerRenderView {
135 this.xComponentController.setXComponentSurfaceRect({ 164 this.xComponentController.setXComponentSurfaceRect({
136 surfaceWidth: info.size.width, 165 surfaceWidth: info.size.width,
137 surfaceHeight: info.size.width / this.videoRatio, 166 surfaceHeight: info.size.width / this.videoRatio,
  167 + offsetY: this.isPad ? this.topSafeHeight : 0
138 }); 168 });
139 return 169 return
140 } 170 }
@@ -193,7 +223,6 @@ export struct WDPlayerRenderView { @@ -193,7 +223,6 @@ export struct WDPlayerRenderView {
193 } 223 }
194 224
195 225
196 -  
197 // if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) { 226 // if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) {
198 // if (info.size.width / info.size.height > this.videoWidth / this.videoHeight) { 227 // if (info.size.width / info.size.height > this.videoWidth / this.videoHeight) {
199 // let scale = info.size.height / this.videoHeight; 228 // let scale = info.size.height / this.videoHeight;
@@ -204,4 +233,13 @@ export struct WDPlayerRenderView { @@ -204,4 +233,13 @@ export struct WDPlayerRenderView {
204 // } 233 // }
205 // } 234 // }
206 } 235 }
  236 +
  237 + currentChanged() {
  238 + if (this.currentBreakpoint == "md" || this.currentBreakpoint == "lg") {
  239 + //大屏幕 折叠屏 或者ipad
  240 + this.isPad = true
  241 + } else {
  242 + this.isPad = false
  243 + }
  244 + }
207 } 245 }