@bendyline/squisq-react 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1540,6 +1540,7 @@ function buildSegmentTitleMap(doc) {
|
|
|
1540
1540
|
|
|
1541
1541
|
// src/docPlayer/renderReadiness.ts
|
|
1542
1542
|
var DEFAULT_VIDEO_FRAME_TIMEOUT_MS = 2e3;
|
|
1543
|
+
var VIDEO_FRAME_READINESS_POLL_MS = 16;
|
|
1543
1544
|
var VIDEO_TIME_TOLERANCE_SECONDS = 0.01;
|
|
1544
1545
|
function formatMediaTime(time) {
|
|
1545
1546
|
return Number.isFinite(time) ? `${time.toFixed(3)}s` : String(time);
|
|
@@ -1565,6 +1566,7 @@ function seekVideoToFrame(video, targetTime, timeoutMs = DEFAULT_VIDEO_FRAME_TIM
|
|
|
1565
1566
|
let videoFrameRequest = null;
|
|
1566
1567
|
const cleanup = () => {
|
|
1567
1568
|
clearTimeout(timeout);
|
|
1569
|
+
clearInterval(readinessPoll);
|
|
1568
1570
|
video.removeEventListener("seeked", handleMediaReady);
|
|
1569
1571
|
video.removeEventListener("loadeddata", handleMediaReady);
|
|
1570
1572
|
video.removeEventListener("canplay", handleMediaReady);
|
|
@@ -1589,7 +1591,9 @@ function seekVideoToFrame(video, targetTime, timeoutMs = DEFAULT_VIDEO_FRAME_TIM
|
|
|
1589
1591
|
);
|
|
1590
1592
|
};
|
|
1591
1593
|
const requestPresentedFrame = () => {
|
|
1592
|
-
if (settled || video.seeking || video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA)
|
|
1594
|
+
if (settled || video.seeking || video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || Math.abs(video.currentTime - targetTime) > VIDEO_TIME_TOLERANCE_SECONDS) {
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1593
1597
|
if (typeof video.requestVideoFrameCallback !== "function" || !isVisiblyPresented(video)) {
|
|
1594
1598
|
finish();
|
|
1595
1599
|
return;
|
|
@@ -1604,6 +1608,7 @@ function seekVideoToFrame(video, targetTime, timeoutMs = DEFAULT_VIDEO_FRAME_TIM
|
|
|
1604
1608
|
requestPresentedFrame();
|
|
1605
1609
|
}
|
|
1606
1610
|
const timeout = setTimeout(fail, timeoutMs);
|
|
1611
|
+
const readinessPoll = setInterval(requestPresentedFrame, VIDEO_FRAME_READINESS_POLL_MS);
|
|
1607
1612
|
video.addEventListener("seeked", handleMediaReady);
|
|
1608
1613
|
video.addEventListener("loadeddata", handleMediaReady);
|
|
1609
1614
|
video.addEventListener("canplay", handleMediaReady);
|
package/dist/index.js
CHANGED