This commit is contained in:
2025-10-13 16:20:37 +08:00
parent 4953b86bb3
commit 347a7292cc
8 changed files with 30 additions and 45 deletions
+14 -5
View File
@@ -96,7 +96,7 @@ export class PreloadUI extends Component {
this.desc = this._nodeTab.Desc.getComponent(Label);
// 设置视频为静音,提高移动端自动播放成功率
this.VideoPlayer.muted = true;
this.VideoPlayer.mute = true;
this.VideoPlayer.loop = true;
this.VideoPlayer.stayOnBottom = true;
@@ -205,16 +205,25 @@ export class PreloadUI extends Component {
// 尝试播放视频
try {
this.VideoPlayer.play();
logger.log(`PreloadUI: Video play attempted (retry: ${this.videoPlayRetryCount}/${this.maxVideoPlayRetry})`);
logger.log(
`PreloadUI: Video play attempted (retry: ${this.videoPlayRetryCount}/${this.maxVideoPlayRetry})`
);
// 延迟检查播放状态,如果失败则重试
this.scheduleOnce(() => {
if (!this.VideoPlayer.isPlaying && this.videoPlayRetryCount < this.maxVideoPlayRetry) {
if (
!this.VideoPlayer.isPlaying &&
this.videoPlayRetryCount < this.maxVideoPlayRetry
) {
this.videoPlayRetryCount++;
logger.warn(`PreloadUI: Video play failed, retrying... (${this.videoPlayRetryCount}/${this.maxVideoPlayRetry})`);
logger.warn(
`PreloadUI: Video play failed, retrying... (${this.videoPlayRetryCount}/${this.maxVideoPlayRetry})`
);
this.tryPlayVideo();
} else if (!this.VideoPlayer.isPlaying) {
logger.warn("PreloadUI: Video autoplay failed after max retries. Will retry on user interaction.");
logger.warn(
"PreloadUI: Video autoplay failed after max retries. Will retry on user interaction."
);
}
}, 0.5);
} catch (error) {