Skip to content

Commit

Permalink
Merge pull request vexorian#332 from vexorian/20210622_dev
Browse files Browse the repository at this point in the history
Fix vexorian#330, programs cut off the last few milliseconds of a program, up to 30 seconds
  • Loading branch information
vexorian authored Jun 22, 2021
2 parents 9bda296 + fb5791d commit 588c940
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/helperFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function createLineup(obj, channel, fillers, isFirst) {
// When within 30 seconds of start time, just make the time 0 to smooth things out
// Helps prevents loosing first few seconds of an episode upon lineup change
let activeProgram = obj.program
let beginningOffset = 0;

let lineup = []

Expand All @@ -67,7 +68,8 @@ function createLineup(obj, channel, fillers, isFirst) {
err: activeProgram.err,
streamDuration: remaining,
duration: remaining,
start: 0
start: 0,
beginningOffset: beginningOffset,
})
return lineup;
}
Expand Down Expand Up @@ -120,6 +122,7 @@ function createLineup(obj, channel, fillers, isFirst) {
streamDuration: Math.max(1, Math.min(filler.duration - fillerstart, remaining) ),
duration: filler.duration,
fillerId: filler.fillerId,
beginningOffset: beginningOffset,
serverKey: filler.serverKey
});
return lineup;
Expand All @@ -133,14 +136,17 @@ function createLineup(obj, channel, fillers, isFirst) {
type: 'offline',
title: 'Channel Offline',
streamDuration: remaining,
beginningOffset: beginningOffset,
duration: remaining,
start: 0
})
return lineup;
}
let originalTimeElapsed = timeElapsed;
if (timeElapsed < 30000) {
timeElapsed = 0
}
beginningOffset = Math.max(0, originalTimeElapsed - timeElapsed);

return [ {
type: 'program',
Expand All @@ -151,6 +157,7 @@ function createLineup(obj, channel, fillers, isFirst) {
ratingKey: activeProgram.ratingKey,
start: timeElapsed,
streamDuration: activeProgram.duration - timeElapsed,
beginningOffset: beginningOffset,
duration: activeProgram.duration,
serverKey: activeProgram.serverKey
} ];
Expand Down
8 changes: 6 additions & 2 deletions src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,19 @@ function video( channelDB , fillerDB, db) {
}
let fillers = await fillerDB.getFillersFromChannel(brandChannel);
let lineup = helperFuncs.createLineup(prog, brandChannel, fillers, isFirst)
lineupItem = lineup.shift()
lineupItem = lineup.shift();
}

if ( !isLoading && (lineupItem != null) ) {
let upperBound = 1000000000;
let beginningOffset = 0;
if (typeof(lineupItem.beginningOffset) !== 'undefined') {
beginningOffset = lineupItem.beginningOffset;
}
//adjust upper bounds and record playbacks
for (let i = redirectChannels.length-1; i >= 0; i--) {
lineupItem = JSON.parse( JSON.stringify(lineupItem ));
let u = upperBounds[i];
let u = upperBounds[i] + beginningOffset;
if (typeof(u) !== 'undefined') {
let u2 = upperBound;
if ( typeof(lineupItem.streamDuration) !== 'undefined') {
Expand Down

0 comments on commit 588c940

Please sign in to comment.