This commit is contained in:
2025-10-14 15:19:12 +08:00
parent 7999c0b9ad
commit a389733596
7 changed files with 398 additions and 155 deletions
+26 -6
View File
@@ -56,6 +56,26 @@ export class ShowPanel extends li_BaseView {
start() {
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
GButton.BandClick(this.splash.node, this.onClose, this);
// 监听视频点击事件(Web平台上视频会覆盖UI,需要直接监听视频点击)
if (this.videoPlayer) {
this.videoPlayer.node.on(
VideoPlayer.EventType.CLICKED,
this.onClose,
this
);
}
}
onDestroy() {
// 清理视频点击事件监听
if (this.videoPlayer && this.videoPlayer.node) {
this.videoPlayer.node.off(
VideoPlayer.EventType.CLICKED,
this.onClose,
this
);
}
}
protected onClose() {
@@ -63,7 +83,7 @@ export class ShowPanel extends li_BaseView {
if (this.videoPlayer) {
this.videoPlayer.stop();
}
if (this.func) {
this.func();
}
@@ -105,10 +125,10 @@ export class ShowPanel extends li_BaseView {
const pos = this.videoArea.node.getWorldPosition();
this.videoPlayer.node.setWorldPosition(pos);
}
this.videoPlayer.loop = true;
this.videoPlayer.play();
// 延迟调整缩放以填充区域
this.scheduleOnce(() => {
this.adjustVideoScale();
@@ -123,7 +143,7 @@ export class ShowPanel extends li_BaseView {
const videoAreaPos = this.videoArea
? this.videoArea.node.getWorldPosition()
: undefined;
if (SceneBgVideoLayer.handle) {
SceneBgVideoLayer.handle.playVideo(path, {
loop: true,
@@ -140,13 +160,13 @@ export class ShowPanel extends li_BaseView {
*/
private adjustVideoScale() {
if (!this.videoPlayer || !this.videoArea) return;
const videoTransform = this.videoPlayer.node.getComponent(UITransform);
if (videoTransform && videoTransform.height > 0) {
const scaleX = this.videoArea.width / videoTransform.width;
const scaleY = this.videoArea.height / videoTransform.height;
const scale = Math.max(scaleX, scaleY); // 填满整个区域
this.videoPlayer.node.setScale(new Vec3(scale, scale, 1));
logger.log(`ShowPanel: 调整视频缩放到 ${scale}`);
}