@xiboplayer/schedule 0.6.8 → 0.6.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiboplayer/schedule",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Complete scheduling solution: campaigns, dayparting, interrupts, and overlays",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -12,7 +12,7 @@
12
12
  "./overlays": "./src/overlays.js"
13
13
  },
14
14
  "dependencies": {
15
- "@xiboplayer/utils": "0.6.8"
15
+ "@xiboplayer/utils": "0.6.9"
16
16
  },
17
17
  "devDependencies": {
18
18
  "vitest": "^2.0.0"
package/src/schedule.js CHANGED
@@ -262,6 +262,7 @@ export class ScheduleManager {
262
262
  file: layout.file,
263
263
  priority: layout.priority || 0,
264
264
  maxPlaysPerHour: layout.maxPlaysPerHour || 0,
265
+ duration: layout.duration || 0,
265
266
  });
266
267
  }
267
268
  }
@@ -276,6 +277,7 @@ export class ScheduleManager {
276
277
  file: layout.file,
277
278
  priority: campaign.priority || 0,
278
279
  maxPlaysPerHour: layout.maxPlaysPerHour || 0,
280
+ duration: layout.duration || 0,
279
281
  });
280
282
  }
281
283
  }
package/src/timeline.js CHANGED
@@ -273,6 +273,14 @@ export function buildScheduleQueue(allLayouts, durations, options = {}) {
273
273
  return { queue: [], periodSeconds: 0 };
274
274
  }
275
275
 
276
+ // Build CMS duration lookup — use CMS-reported duration as fallback
277
+ // when the durations map (from XLF parsing / video metadata) has no entry.
278
+ const cmsDurations = new Map();
279
+ for (const l of allLayouts) {
280
+ if (l.duration > 0) cmsDurations.set(l.file, l.duration);
281
+ }
282
+ const getDuration = (file) => durations.get(file) || cmsDurations.get(file) || defaultDuration;
283
+
276
284
  // Step 1: Identify rate-limited layouts to calculate LCM period
277
285
  const rateLimited = allLayouts.filter(l => l.maxPlaysPerHour > 0);
278
286
 
@@ -284,9 +292,9 @@ export function buildScheduleQueue(allLayouts, durations, options = {}) {
284
292
  if (periodSeconds > 7200) periodSeconds = 7200;
285
293
  } else {
286
294
  // No rate-limited layouts — single round-robin cycle
287
- const totalDuration = allLayouts.reduce((sum, l) => sum + (durations.get(l.file) || defaultDuration), 0)
295
+ const totalDuration = allLayouts.reduce((sum, l) => sum + getDuration(l.file), 0)
288
296
  + (defaultLayout && !allLayouts.some(l => l.file === defaultLayout)
289
- ? (durations.get(defaultLayout) || defaultDuration)
297
+ ? getDuration(defaultLayout)
290
298
  : 0);
291
299
  periodSeconds = totalDuration || defaultDuration;
292
300
  }
@@ -305,7 +313,7 @@ export function buildScheduleQueue(allLayouts, durations, options = {}) {
305
313
  if (playable.length === 0) {
306
314
  // All layouts exhausted — use default
307
315
  if (defaultLayout) {
308
- const dur = durations.get(defaultLayout) || defaultDuration;
316
+ const dur = getDuration(defaultLayout);
309
317
  queue.push({ layoutId: defaultLayout, duration: dur });
310
318
  cursorMs += dur * 1000;
311
319
  } else {
@@ -318,7 +326,7 @@ export function buildScheduleQueue(allLayouts, durations, options = {}) {
318
326
  // Play all playable layouts in round-robin order (one each), then re-evaluate
319
327
  for (let i = 0; i < playable.length && cursorMs < periodMs && queue.length < maxEntries; i++) {
320
328
  const file = playable[i];
321
- const dur = durations.get(file) || defaultDuration;
329
+ const dur = getDuration(file);
322
330
 
323
331
  queue.push({ layoutId: file, duration: dur });
324
332
 
@@ -336,7 +344,7 @@ export function buildScheduleQueue(allLayouts, durations, options = {}) {
336
344
 
337
345
  // Handle edge case: no layouts and only default
338
346
  if (queue.length === 0 && defaultLayout) {
339
- const defDur = durations.get(defaultLayout) || defaultDuration;
347
+ const defDur = getDuration(defaultLayout);
340
348
  queue.push({ layoutId: defaultLayout, duration: defDur });
341
349
  }
342
350