video.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. videoplayer: cc.VideoPlayer
  14. },
  15. onLoad: function () {
  16. this.videoplayer.node.on('ready-to-play', this.callback, this);
  17. },
  18. callback: function (event) {
  19. console.log(event)
  20. //这里的 event 是一个 EventCustom 对象,你可以通过 event.detail 获取 VideoPlayer 组件
  21. var videoplayer = event.detail;
  22. //do whatever you want with videoplayer
  23. //另外,注意这种方式注册的事件,也无法传递 customEventData
  24. },
  25. start () {
  26. },
  27. // update (dt) {},
  28. });