请问官方文档中的这个方法二,如果想改成视频播放结束后触发,应该吧"ready-to-play"改成什么啊,求指教,谢谢
方法二
通过 videoplayer.node.on(‘ready-to-play’, …) 的方式来添加
//假设我们在一个组件的 onLoad 方法里面添加事件处理回调,在 callback 函数中进行事件处理:
cc.Class({
extends: cc.Component,
properties: {
videoplayer: cc.VideoPlayer
},
onLoad: function () {
this.videoplayer.node.on('ready-to-play', this.callback, this);
},
callback: function (event) {
//这里的 event 是一个 EventCustom 对象,你可以通过 event.detail 获取 VideoPlayer 组件
var videoplayer = event.detail;
//do whatever you want with videoplayer
//另外,注意这种方式注册的事件,也无法传递 customEventData
}
});
同样的,你也可以注册 ‘meta-loaded’, ‘clicked’ , ‘playing’ 等事件,这些事件的回调函数的参数与 ‘read-to-play’ 的参数一致。