Skip to content

Instantly share code, notes, and snippets.

@Mikodes
Created May 21, 2020 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mikodes/d4b31401590c5e29301d0606c2de5775 to your computer and use it in GitHub Desktop.
Save Mikodes/d4b31401590c5e29301d0606c2de5775 to your computer and use it in GitHub Desktop.
cc.Class({
extends: cc.Component,
properties: {
video:{
default: null,
type: cc.VideoPlayer
}
},
// use this for initialization
onLoad: function () {
this.videoPlayer = this.node.getComponent(cc.VideoPlayer);
this.videoPlayer.node.on('ready-to-play', this.callback, this);
},
start: function () {
cc.director.setClearColor(new cc.Color(0, 0, 0, 0))
let videoElement = document.getElementsByClassName('cocosVideo')[0];
videoElement.style.zIndex = 2;
let gameCanvas = document.getElementsByClassName('gameCanvas')[0];
gameCanvas.style.position = 'relative';
gCanvas.style.zIndex = 4;
},
callback () {
console.log("video ready to play")
this.videoPlayer.play();
},
// called every frame
update: function (dt) {
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment