0

現在のビデオ時間が指定された値に達したときに次のビデオを再生する必要がありますが、 currentTime を取得する必要があるイベントがまったく発生しない理由がわかりませんか? 誰かが理由を知っているかもしれません (明らかに、最も単純なタスクが最も多くの問題を引き起こします)。

   function setupVideoPlayer() { 
var currentVideo = 1;
// i.e. [video url, start time, end time]
var videos = [["1.mp4", 0, 4], ["2.mp4", 3, 7]];
var videoPlayer = document.getElementById('videoPlayer');
// set first video clip
videoPlayer.src = videos[0][0]; // 1.mp4
// Syncrhonization function should come here


videoPlayer.addEventListener('timeupdate', function(e){
    if (this.currentTime == videos[currentVideo-1][2]) {
        currentVideo += 1;
        this.src = videos[currentVideo-1][0];
        this.play();
    }
}, true);

// It makes sure the seek will happen after buffering 
// the video
videoPlayer.addEventListener('progress', function(e) {
    // Seek to start point
    this.currentTime = videos[currentVideo-1][1]; 
}, false)
}
4

1 に答える 1

1

currentTimeイベントはインテグラーではないため、タイムチェックを=ではなく>に変更することをお勧めします

if (this.currentTime == videos[currentVideo-1][2]) {

になります

if (this.currentTime > videos[currentVideo-1][2]) {

(または、テスト用のインテグラーに変換することもできます)

他に問題がある場合はconsole.log(this.currentTime)、イベントにを追加して、コードがトリガーされているかどうかを確認するだけの価値があります。

于 2013-03-16T06:21:41.810 に答える