05-06 17:51:34.771 14900 14958 I C03F00/com.hx.example/ArkCompiler: [gc] SmartGC: app cold start just finished
05-06 17:51:32.867 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onCreate 05-06 17:51:32.875 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onWindowStageCreate 05-06 17:51:32.878 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onForeground 05-06 17:51:36.143 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onBackPressed 05-06 17:51:36.151 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onBackground 05-06 17:51:36.881 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onNewWant 05-06 17:51:36.882 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onForeground 05-06 17:51:45.977 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onBackground 05-06 17:51:49.731 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onNewWant 05-06 17:51:49.738 14900 14900 I C01332/com.hx.example/UIAbility: [js_ui_ability.cpp:1568]JsUIAbility call js, name: onForeground
07-11 09:32:42.256 64899-64899 com.hx.example I video finish., %{public}s 监听组件可见区域变化事件,在Video组件重新可见时继续播放视频。
@Entry
@Component
export struct VideoPage {
videoSrc: Resource = $rawfile('TestVideo.mp4'); // 替换为启动页视频
controller : VideoController = new VideoController();
build() {
Column() {
Video({
src : this.videoSrc,
controller: this.controller
})
.autoPlay(true)
.loop(false)
.objectFit(ImageFit.Contain)
.onFinish(() => {
// 此处执行页面跳转
})
.onVisibleAreaChange([0.0, 1.0], (isExpanding: boolean, currentRatio: number) => {
// 当Video组件全部可见时,继续播放
if (isExpanding || currentRatio >= 1.0) {
console.info('Test Video is fully visible.');
this.controller.start();
}
// 当Video组件不可见时,暂停播放
if (!isExpanding && currentRatio <= 0.0) {
console.info('Test Video is completely invisible.');
this.controller.pause();
}
})
}
.height('100%')
.width('100%')
.justifyContent(FlexAlign.Center)
}
}