[0]视频节点VideoNode无法监听事件
								const { regClass, property } = Laya;
import { MainBase } from "./Main.generated";
@regClass()
export class Main extends MainBase {
onAwake() {
this.VideoNode.play();
console.log("Game start"); // 监听视频播放结束事件
this.VideoNode.on('playing', this, () => {
// 在视频结束时添加文本
console.log("-------------");
});
this.VideoNode.on('click', this, () => {
this.Button.alpha = 1;
this.VideoNode.pause();
// 在视频结束时添加文本
console.log("---------END----");
});
}
}
																				import { MainBase } from "./Main.generated";
@regClass()
export class Main extends MainBase {
onAwake() {
this.VideoNode.play();
console.log("Game start"); // 监听视频播放结束事件
this.VideoNode.on('playing', this, () => {
// 在视频结束时添加文本
console.log("-------------");
});
this.VideoNode.on('click', this, () => {
this.Button.alpha = 1;
this.VideoNode.pause();
// 在视频结束时添加文本
console.log("---------END----");
});
}
}
没有找到相关结果
									已邀请:
																	
							要回复问题请先登录
 
1 个回复
Laya_Fred
赞同来自:
const { regClass, property } = Laya;
@regClass()
export class VideoTest extends Laya.Script {
//declare owner : Laya.Sprite3D;
@property({ type: Laya.VideoNode })
public video: Laya.VideoNode;
public isStop: Boolean;
constructor() {
super();
}
/**
* 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
*/
onAwake(): void {
this.video.play();
// 需要添加到videoTexture上
this.video.videoTexture.on("playing", () => {
console.log("开始播放--------");
this.video.loop = true;
});
this.video.videoTexture.on("timeupdate", () => {
console.log("播放更新--------");
});
// videoNode可以添加Laya.Event.CLICK事件来监听点击事件
this.video.on(Laya.Event.CLICK, () => {
this.isStop = !this.isStop;
this.isStop && (this.video.pause());
!this.isStop && (this.video.play());
console.log("暂停视频播放-----------");
});
}
}