Spaces:
Running
Running
teleop viewer: multi-view sync — slow-loading tile skips to freshest buffered frame instead of replaying from start
Browse files- teleopSample/drink_ep0.html +14 -4
teleopSample/drink_ep0.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>
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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));
|