Created
May 21, 2020 11:26
-
-
Save Mikodes/d4b31401590c5e29301d0606c2de5775 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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