diff --git a/entry/src/main/ets/pages/Question2Incorrect.ets b/entry/src/main/ets/pages/Question2Incorrect.ets index 5dd37c6020a45d7d059b0179f696423fac2b5e0d..6ed47f27daaa3e210025a22e55f0cf37f02b40c3 100644 --- a/entry/src/main/ets/pages/Question2Incorrect.ets +++ b/entry/src/main/ets/pages/Question2Incorrect.ets @@ -24,8 +24,8 @@ export function Question2IncorrectBuilder() { @Component export struct Question2Incorrect { @State aspect: number = 9 / 16; // default video height/width ratio value - @State xComponentWidth: number = px2vp(display.getDefaultDisplaySync().width); - @State xComponentHeight: number = px2vp(display.getDefaultDisplaySync().width * this.aspect); + @State xComponentWidth: number = this.getUIContext().px2vp(display.getDefaultDisplaySync().width); + @State xComponentHeight: number = this.getUIContext().px2vp(display.getDefaultDisplaySync().width * this.aspect); // [StartExclude Question2Incorrect] private xComponentController: XComponentController = new XComponentController(); private player?: AVPlayerUtil; @@ -45,8 +45,8 @@ export struct Question2Incorrect { this.player.setSurfaceId(this.xComponentController.getXComponentSurfaceId()); this.player.initPlayer('testVideo2.mp4', (aspect: number) => { this.aspect = aspect; - this.xComponentHeight = px2vp(display.getDefaultDisplaySync().height); - this.xComponentWidth = px2vp(display.getDefaultDisplaySync().height * aspect); + this.xComponentHeight = this.getUIContext().px2vp(display.getDefaultDisplaySync().height); + this.xComponentWidth = this.getUIContext().px2vp(display.getDefaultDisplaySync().height * aspect); }); }) // [EndExclude Question2Incorrect]