2013-03-04 84 views
7

我需要HTML5视频播放器的提示点。我发现Cuepoint.js除了这只是像标题的东西。当某个提示点被击中时,我需要改变文字以外的东西。HTML5视频标签中的提示点

我有点提出了自己的提示点逻辑,但我觉得它并不像它那样高效。我现在正在处理一些小问题,这不是什么大问题。当我进入数百人时,恐怕会导致一些性能问题。

这是我走过来,它是相当准确:

function timeUpdate(event) 
{ 
    var times = [3,8,13,19,25]; 
    currentTime = player.currentTime(); 
    $.each(times,function(key, value) 
    { 
     if (currentTime >= times[key] && currentTime <= times[key] + 0.3) 
     { 
      currentIndex++; 
      loadAssets(currentIndex); 
     } 
    }); 
} 

times阵列仅仅是一个例子。有没有更有效的方法来做到这一点,或者这是非常有用的吗?

回答

1

罗尼,你不通过数组需要循环。如果项目是有序的,只需检查第一个项目,然后将currentIndex加1。

function timeUpdate(event) 
{ 
    var times = [3,8,13,19,25]; 
    currentTime = player.currentTime(); 

    if (currentTime >= times[currentIndex]) 
    { 
     currentIndex++; 
     loadAssets(currentIndex); 
    } 
} 
+1

什么是查找功能? – Toniq 2015-10-05 22:15:43

+0

直到用户倒带视频。这仅在禁用控件时才有效。 – 2015-12-10 22:43:05