You have to put your code in the callback function you supply to setTimeout
:(您必须将代码放在您提供给setTimeout
的回调函数中:)
function stateChange(newState) {
setTimeout(function () {
if (newState == -1) {
alert('VIDEO HAS STOPPED');
}
}, 5000);
}
Any other code will execute immediately.(任何其他代码将立即执行。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…