faradayfuture commited on
Commit
23aa459
·
verified ·
1 Parent(s): 14f7845

teleop viewer: multi-view sync — slow-loading tile skips to freshest buffered frame instead of replaying from start

Browse files
Files changed (1) hide show
  1. teleopSample/drink_ep1.html +14 -4
teleopSample/drink_ep1.html CHANGED
@@ -133,10 +133,20 @@ function syncSlaves(t,hard){
133
  if(hard){ v.playbackRate=1; if(!v.seeking&&Math.abs(v.currentTime-t)>0.06){ try{v.currentTime=t;}catch(e){} } continue; }
134
  if(!playing) continue;
135
  if(v.paused&&!v.ended){ v.play().catch(()=>{}); }
136
- const drift=v.currentTime-t, ad=Math.abs(drift);
137
- if(ad>0.75){ if(!v.seeking&&inBuf(v,t)){ try{v.currentTime=t;}catch(e){} } v.playbackRate=1; }
138
- else if(ad>0.035){ v.playbackRate=Math.max(0.5,Math.min(1.6, 1-drift*3)); }
139
- else v.playbackRate=1;
 
 
 
 
 
 
 
 
 
 
140
  }
141
  }
142
  function seekTo(t){ t=Math.max(0,Math.min(DUR-0.01,t));
 
133
  if(hard){ v.playbackRate=1; if(!v.seeking&&Math.abs(v.currentTime-t)>0.06){ try{v.currentTime=t;}catch(e){} } continue; }
134
  if(!playing) continue;
135
  if(v.paused&&!v.ended){ v.play().catch(()=>{}); }
136
+ const drift=v.currentTime-t, ad=Math.abs(drift); // drift<0 => this tile is behind
137
+ if(ad>1.0 && !v.seeking){
138
+ // big gap: jump to master if it's downloaded here, otherwise to the freshest
139
+ // buffered point of THIS tile — so a slow-loading tile skips ahead to current
140
+ // content instead of crawling from the start (which looked like a replay loop)
141
+ let tgt = inBuf(v,t) ? t
142
+ : (v.buffered.length ? Math.max(0, v.buffered.end(v.buffered.length-1)-0.25) : v.currentTime);
143
+ if(Math.abs(v.currentTime-tgt)>0.4){ try{ v.currentTime=tgt; }catch(e){} }
144
+ v.playbackRate=1;
145
+ } else if(ad>0.04){
146
+ v.playbackRate=Math.max(0.5,Math.min(1.8, 1-drift*3)); // trim toward master
147
+ } else {
148
+ v.playbackRate=1;
149
+ }
150
  }
151
  }
152
  function seekTo(t){ t=Math.max(0,Math.min(DUR-0.01,t));