Why does setTimeout cause some loaded: parameters of the ckplayer player to fail to load?

problem description

recently, Apple cms 10.x is used to integrate movie station players, which involves loading custom functions in loaded. However, in the playback aspect of this program, there must be a code with ckplayer in the setTimeout timer. If you don"t understand, loaded:"" will be invalid after you install setTimeout.

the environmental background of the problems and what methods you have tried

there is no problem with removing the setTimeout function, but the program does not know why it is necessary. If you remove the player, it will be gone.

related codes

setTimeout (function () {

var videoObject = {
    container: "-sharpplayleft",//"-sharp" ID"." "" class
    variable: "player",//new chplayer()
    autoplay:false,
    loaded:"loadedHandler",//
    video:"http://ckplayer-video.oss-cn-shanghai.aliyuncs.com/ckplayer-sample/mydream_zh_768-432.mp4"//
    
};
var player=new ckplayer(videoObject);

function loadedHandler() {

    alert("")
}


player.addListener("ended", endedHandler);

}, 1000);

is there any way to make ckplayer work perfectly in setTimeout, or what causes it?

Jun.04,2021

is probably a scope problem. Your loadedHandler is defined in an anonymous function. Execute this sentence


var player=new ckplayer(videoObject);

is either undefined or destroyed.
it is recommended that this function be defined at the same level as endedHandler. If executed in a timer, it should be defined in a global location. If you really want to personalize here, hang it on window directly outside

Menu