我想取一个特定的时间值(由 html5 htmlmedia timerange.end 以秒为单位给出)并检查它在我已经拥有的时间列表中的位置,看起来像这样
00:00:00.00
00:00:22.00
00:01:21.00
00:01:36.00
00:01:51.00
00:02:06.00
00:02:21.00
00:02:36.00
我将这些值硬编码在捕获程序的文本文件服务器端。我想检查并查看它(video_time)位于哪两个值之间,如果 src 不对应于时隙,则从那里更改 iframe 中的 src,上面的列表中有 n 次和对应的 n -1 个插槽,src 将命名为 /Slide0.html 到 /Slide[n-1].html 到目前为止 iv 创建了一些逻辑来检查时间,占位符逻辑来更改 iframe 的 src,如果值 > 15 秒和一些回调定期调用事物,
[编辑:删除了一些不相关的东西]这是问题所在,
function category() {
var played_ob =video_time_played() ;
if ( played_ob > 0 )
var played_num = played_ob;
else
var played_num = 0;
var tes = 15;
if ( played_num > tes)
document.getElementsByTagName("iframe")[0].src="/static/Slide1.html";
else
console.log ("meh");
};
上面我希望检查它落在哪个时间范围并设置正确的 iframe。这就是我需要帮助的,我想做的如下
/* PSEUDOCODE OF WHAT I WISH TO ACHIEVE BUT DONT KNOW HOW TO DO IT ENTIRELY.*/
function category (){
var time_spent = video_time_played_so_far_in_seconds();
/* this part i dont know, especially how to generate the list from a text file serverside */
categories_list = [list of consecutive times i showed above in HH:MM:SS.00]
var which_category = function check_in_between_which_two_times_var_lies () {
/*********** i DONT know how to code this part either, *******/
the_category_found_as_an_integer_between_0=>n-1 = ?
var category = the_category_found_as_an_integer_between_0=>n-1 ;
return category ;
}
function which_new_src (which_category) {
/* code to select new src */
var new_src = "/static/Slide"+which_category".html";
return new_src;
}
function change_src_of_iframe () {
var relevant_iframe = document.getElementsByTagName("iframe")[0];
change_src_of_iframe () {
var new_src = which_new_src(which_category);
relevant_iframe..src= new_src ;
}