Commit f1e15910 authored by asdf's avatar asdf

iframe添加监听

parent a570544e
......@@ -122,14 +122,16 @@ cc.Class({
this.preloadItem()
}
})
window.addEventListener('message',(e)=>{
let msgData = e.data;
console.log(msgData.action)
if(msgData.action==="course-ready"){
this.stopBgm();
}
});
var testiframe = document.getElementById("previewFrame");
if (testiframe) {
testiframe.contentWindow.addEventListener('message', (e) => {
let msgData = e.data;
console.log(msgData.action)
if (msgData.action === "course-ready") {
this.stopBgm();
}
});
}
},
getData(cb) {
......@@ -204,8 +206,8 @@ cc.Class({
this.bgAudioId = cc.audioEngine.play(clip, true, 1);
});
},
stopBgm(){
if(this.bgAudioId){
stopBgm() {
if (this.bgAudioId) {
cc.audioEngine.stop(this.bgAudioId);
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment