2

HTML5ビデオが特定の2番目の値に達したときに実行する基本的な関数を取得しようとしています。現在、私は運がなく、ここで助けが得られることを望んでいました。これまでに使用しているコードは次のとおりです。

jQuery(function(){
    jQuery("video").bind("timeupdate", function() {
        if(this.currentTime == "6") { alert("six seconds in"); }
        // also tried the above line with the 6 not in quotes
    });
});

私はビデオの周りで本当に基本的なコンテンツの交換をしたいだけですが、今のところあまり運がありません。助けてくれてありがとう!

4

2 に答える 2

1

このバニラJavaScriptは私にとっては問題なく機能します。

video.addEventListener('timeupdate'、function(e){
    if(e.target.currentTime == 6)..。
}、false);
于 2010-09-10T03:24:25.327 に答える
1

currentTimeは浮動小数点値であり、整数ではありません。比較のために小数部を削除します。

var currentTime = parseInt(this.currentTime, 10);
if(currentTime == 6) { 
    ..
}
于 2010-09-10T03:29:42.990 に答える