Home Reference Source

src/utils/output-filter.ts

  1. import { CaptionScreen } from './cea-608-parser';
  2.  
  3. export default class OutputFilter {
  4. timelineController: any;
  5. trackName: string;
  6. startTime: number | null;
  7. endTime: number | null;
  8. screen: CaptionScreen | null;
  9.  
  10. // TODO(typescript-timelineController)
  11. constructor (timelineController: any, trackName: string) {
  12. this.timelineController = timelineController;
  13. this.trackName = trackName;
  14. this.startTime = null;
  15. this.endTime = null;
  16. this.screen = null;
  17. }
  18.  
  19. dispatchCue () {
  20. if (this.startTime === null) {
  21. return;
  22. }
  23.  
  24. this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen);
  25. this.startTime = null;
  26. }
  27.  
  28. newCue (startTime: number, endTime: number, screen: CaptionScreen) {
  29. if (this.startTime === null || this.startTime > startTime) {
  30. this.startTime = startTime;
  31. }
  32.  
  33. this.endTime = endTime;
  34. this.screen = screen;
  35. this.timelineController.createCaptionsTrack(this.trackName);
  36. }
  37. }