hls.js 1.6.0-beta.1.0.canary.10821 → 1.6.0-beta.1.0.canary.10824

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.
@@ -6,9 +6,10 @@ import {
6
6
  type InterstitialId,
7
7
  TimelineOccupancy,
8
8
  } from '../loader/interstitial-event';
9
- import { logger } from '../utils/logger';
9
+ import { Logger } from '../utils/logger';
10
10
  import type { DateRange } from '../loader/date-range';
11
11
  import type { MediaSelection } from '../types/media-playlist';
12
+ import type { ILogger } from '../utils/logger';
12
13
 
13
14
  const ABUTTING_THRESHOLD_SECONDS = 0.033;
14
15
 
@@ -59,7 +60,7 @@ type ScheduleUpdateCallback = (
59
60
  previousItems: InterstitialScheduleItem[] | null,
60
61
  ) => void;
61
62
 
62
- export class InterstitialsSchedule {
63
+ export class InterstitialsSchedule extends Logger {
63
64
  private onScheduleUpdate: ScheduleUpdateCallback;
64
65
  private eventMap: Record<string, InterstitialEvent> = {};
65
66
  public events: InterstitialEvent[] | null = null;
@@ -70,7 +71,8 @@ export class InterstitialsSchedule {
70
71
  integrated: 0,
71
72
  };
72
73
 
73
- constructor(onScheduleUpdate: ScheduleUpdateCallback) {
74
+ constructor(onScheduleUpdate: ScheduleUpdateCallback, logger: ILogger) {
75
+ super('interstitials-sched', logger);
74
76
  this.onScheduleUpdate = onScheduleUpdate;
75
77
  }
76
78
 
@@ -579,14 +581,14 @@ export class InterstitialsSchedule {
579
581
  if (
580
582
  Math.abs(resumeTime - resumesInPlaceAt) > ALIGNED_END_THRESHOLD_SECONDS
581
583
  ) {
582
- logger.log(
583
- `Interstitial resumption ${resumeTime} not aligned with estimated timeline end ${resumesInPlaceAt}`,
584
+ this.log(
585
+ `"${interstitial.identifier}" resumption ${resumeTime} not aligned with estimated timeline end ${resumesInPlaceAt}`,
584
586
  );
585
587
  return false;
586
588
  }
587
589
  if (!mediaSelection) {
588
- logger.log(
589
- `Interstitial resumption ${resumeTime} can not be aligned with media (none selected)`,
590
+ this.log(
591
+ `"${interstitial.identifier}" resumption ${resumeTime} can not be aligned with media (none selected)`,
590
592
  );
591
593
  return false;
592
594
  }
@@ -594,8 +596,8 @@ export class InterstitialsSchedule {
594
596
  const details = mediaSelection[playlistType].details;
595
597
  const playlistEnd = details.edge;
596
598
  if (resumeTime > playlistEnd) {
597
- logger.log(
598
- `Interstitial resumption ${resumeTime} past ${playlistType} playlist end ${playlistEnd}`,
599
+ this.log(
600
+ `"${interstitial.identifier}" resumption ${resumeTime} past ${playlistType} playlist end ${playlistEnd}`,
599
601
  );
600
602
  return true;
601
603
  }
@@ -605,19 +607,20 @@ export class InterstitialsSchedule {
605
607
  resumeTime,
606
608
  );
607
609
  if (!startFragment) {
608
- logger.log(
609
- `Interstitial resumption ${resumeTime} does not overlap with any fragments in ${playlistType} playlist`,
610
+ this.log(
611
+ `"${interstitial.identifier}" resumption ${resumeTime} does not align with any fragments in ${playlistType} playlist`,
610
612
  );
611
613
  return true;
612
614
  }
615
+ const endAllowance = playlistType === 'audio' ? 0.175 : 0;
613
616
  const alignedWithSegment =
614
617
  Math.abs(startFragment.start - resumeTime) <
615
618
  ALIGNED_END_THRESHOLD_SECONDS ||
616
619
  Math.abs(startFragment.end - resumeTime) <
617
- ALIGNED_END_THRESHOLD_SECONDS;
620
+ ALIGNED_END_THRESHOLD_SECONDS + endAllowance;
618
621
  if (!alignedWithSegment) {
619
- logger.log(
620
- `Interstitial resumption ${resumeTime} does not overlap with fragment in ${playlistType} playlist (${startFragment.start}-${startFragment.end})`,
622
+ this.log(
623
+ `"${interstitial.identifier}" resumption ${resumeTime} not aligned with ${playlistType} fragment bounds (${startFragment.start}-${startFragment.end} sn: ${startFragment.sn} cc: ${startFragment.cc})`,
621
624
  );
622
625
  return true;
623
626
  }
@@ -3,7 +3,7 @@ import type { DateRange, DateRangeCue } from './date-range';
3
3
  import type { MediaFragmentRef } from './fragment';
4
4
  import type { Loader, LoaderContext } from '../types/loader';
5
5
 
6
- export const ALIGNED_END_THRESHOLD_SECONDS = 0.02; // 0.1 // 0.2
6
+ export const ALIGNED_END_THRESHOLD_SECONDS = 0.02;
7
7
 
8
8
  export type PlaybackRestrictions = {
9
9
  skip: boolean;