@ -1,6 +1,7 @@
var googleUser = null ;
var videoInfo ;
var currentRange = 1 ;
var globalLoadedRangeData = false ;
window . addEventListener ( "DOMContentLoaded" , async ( event ) => {
commonPageSetup ( ) ;
@ -39,9 +40,9 @@ window.addEventListener("DOMContentLoaded", async (event) => {
// The video duration isn't precisely the video times, but can be padded by up to the
// segment length on either side.
// This makes the assumption that all segments have the same length.
const segmentLength = getPlaylistData ( ) . segments [ 0 ] . duration ;
newDuration += segmentL ength * 2 ;
const segmentList = getPlaylistData ( ) . segments ;
newDuration += segmentList [ 0 ] . duration ;
newDuration += segmentL ist[ segmentList . length - 1 ] . duration ;
// Abort for ranges that exceed new times
for ( const rangeContainer of document . getElementById ( "range-definitions" ) . children ) {
@ -74,14 +75,14 @@ window.addEventListener("DOMContentLoaded", async (event) => {
if ( rangeStart === null ) {
rangeErrorCount ++ ;
} else {
rangeStartField . value = videoHumanTimeFromVideoPlayerTime ( startAdjustment + rangeStar t) ;
rangeStartField . value = videoHumanTimeFromVideoPlayerTime ( rangeStart - startAdjustment) ;
}
const rangeEnd = videoPlayerTimeFromVideoHumanTime ( rangeEndField . value ) ;
if ( rangeEnd === null ) {
rangeErrorCount ++ ;
} else {
rangeEndField . value = videoHumanTimeFromVideoPlayerTime ( startAdjustment + rangeEnd ) ;
rangeEndField . value = videoHumanTimeFromVideoPlayerTime ( rangeEnd - startAdjustment) ;
}
}
if ( rangeErrorCount > 0 ) {
@ -89,6 +90,7 @@ window.addEventListener("DOMContentLoaded", async (event) => {
"Some ranges couldn't be updated for the new video time endpoints. Please verify the time range values."
) ;
}
rangeDataUpdated ( ) ;
const waveformImage = document . getElementById ( "waveform" ) ;
if ( newEnd === null ) {
@ -376,6 +378,7 @@ async function initializeVideoInfo() {
const player = getVideoJS ( ) ;
player . on ( "loadedmetadata" , ( ) => {
if ( ! globalLoadedRangeData ) {
const rangeDefinitionsContainer = document . getElementById ( "range-definitions" ) ;
if ( videoInfo . video _ranges && videoInfo . video _ranges . length > 0 ) {
for ( let rangeIndex = 0 ; rangeIndex < videoInfo . video _ranges . length ; rangeIndex ++ ) {
@ -410,6 +413,8 @@ async function initializeVideoInfo() {
}
}
rangeDataUpdated ( ) ;
globalLoadedRangeData = true ;
}
} ) ;
player . on ( "timeupdate" , ( ) => {
const player = getVideoJS ( ) ;