|
|
@ -410,9 +410,10 @@ async function initializeVideoInfo() {
|
|
|
|
rangeEndField.value = videoHumanTimeFromWubloaderTime(globalEndTimeString);
|
|
|
|
rangeEndField.value = videoHumanTimeFromWubloaderTime(globalEndTimeString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
videoElement.removeEventListener("durationchange", handleInitialSetupForDuration);
|
|
|
|
rangeDataUpdated();
|
|
|
|
|
|
|
|
videoElement.removeEventListener("loadedmetadata", handleInitialSetupForDuration);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
videoElement.addEventListener("durationchange", handleInitialSetupForDuration);
|
|
|
|
videoElement.addEventListener("loadedmetadata", handleInitialSetupForDuration);
|
|
|
|
videoElement.addEventListener("durationchange", (_event) => {
|
|
|
|
videoElement.addEventListener("durationchange", (_event) => {
|
|
|
|
// Every time this is updated, we need to update based on the new video duration
|
|
|
|
// Every time this is updated, we need to update based on the new video duration
|
|
|
|
rangeDataUpdated();
|
|
|
|
rangeDataUpdated();
|
|
|
@ -986,13 +987,27 @@ function setCurrentRangeEndToVideoTime() {
|
|
|
|
function videoPlayerTimeFromWubloaderTime(wubloaderTime) {
|
|
|
|
function videoPlayerTimeFromWubloaderTime(wubloaderTime) {
|
|
|
|
const wubloaderDateTime = dateTimeFromWubloaderTime(wubloaderTime);
|
|
|
|
const wubloaderDateTime = dateTimeFromWubloaderTime(wubloaderTime);
|
|
|
|
const segmentList = getSegmentList();
|
|
|
|
const segmentList = getSegmentList();
|
|
|
|
for (const segment of segmentList) {
|
|
|
|
for (let segmentIndex = 0; segmentIndex < segmentList.length - 1; segmentIndex++) {
|
|
|
|
const segmentStart = DateTime.fromISO(segment.rawProgramDateTime, { zone: "utc" });
|
|
|
|
const thisSegment = segmentList[segmentIndex];
|
|
|
|
const segmentEnd = segmentStart.plus({ seconds: segment.duration });
|
|
|
|
const nextSegment = segmentList[segmentIndex + 1];
|
|
|
|
if (segmentStart <= wubloaderDateTime && segmentEnd > wubloaderDateTime) {
|
|
|
|
const segmentStartTime = DateTime.fromISO(thisSegment.rawProgramDateTime);
|
|
|
|
return segment.start + wubloaderDateTime.diff(segmentStart).as("seconds");
|
|
|
|
const nextSegmentStartTime = DateTime.fromISO(nextSegment.rawProgramDateTime);
|
|
|
|
|
|
|
|
if (segmentStartTime <= wubloaderDateTime && nextSegmentStartTime > wubloaderDateTime) {
|
|
|
|
|
|
|
|
let offset = wubloaderDateTime.diff(segmentStartTime).as("seconds");
|
|
|
|
|
|
|
|
// If there's a hole in the video and this wubloader time is in the hole, this will end up
|
|
|
|
|
|
|
|
// at a random point. We can fix that by capping the offset at the segment duration.
|
|
|
|
|
|
|
|
if (offset > thisSegment.duration) {
|
|
|
|
|
|
|
|
offset = thisSegment.duration;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return thisSegment.start + offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const lastSegment = segmentList[segmentList.length - 1];
|
|
|
|
|
|
|
|
const lastSegmentStartTime = DateTime.fromISO(lastSegment.rawProgramDateTime);
|
|
|
|
|
|
|
|
const lastSegmentEndTime = lastSegmentStartTime.plus({ seconds: lastSegment.duration });
|
|
|
|
|
|
|
|
if (lastSegmentStartTime <= wubloaderDateTime && wubloaderDateTime <= lastSegmentEndTime) {
|
|
|
|
|
|
|
|
return segment.start + wubloaderDateTime.diff(lastSegmentStartTime).as("seconds");
|
|
|
|
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|