videojs / http-streaming

HLS, DASH, and future HTTP streaming protocols library for video.js
https://videojs-http-streaming.netlify.app/
Other
2.53k stars 425 forks source link

feat: add daterange support #1402

Closed harisha-swaminathan closed 1 year ago

harisha-swaminathan commented 1 year ago

Description

Adds support for #EXT-X-DATERANGE tags. This PR exposes parsed dateRanges data from this m3u8 parser PR as a metadata text track for use as timed metadata (as Safari does).

Specific Changes proposed

The PR adds two new functions

     {
    endDate: new Date(5000),
    plannedDuration: 5,
    scte35Out: '0xFC30200FFF00F0500D00E4612424',
    startDate: new Date(3000),
    id: 'testId',
  }

the following cues are added as timed metadata to the texttrack

     {
    endTime: 3,
    id: 'testId',
    startTime: 1,
    value: {data: 5, key: 'PLANNED-DURATION'}
  }, {
    endTime: 3,
    id: 'testId',
    startTime: 1,
    value: {data: new ArrayBuffer(), key: 'SCTE35-OUT'}
  }

Use Cases

To listen to and log dateRanges metadata text track cue changes

const timedMetadaTrack = Array.from(player.textTracks()).find((track) => typeof track.inBandMetadataTrackDispatchType === 'string' && track.inBandMetadataTrackDispatchType.trim().length > 0);
timedMetadataTrack.addEventListener("cuechange", () => {
  console.log(timedmetadata.activeCues);
});

Requirements Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #1402 (65db0ed) into main (fe25a04) will increase coverage by 0.06%. The diff coverage is 91.91%.

@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
+ Coverage   85.48%   85.54%   +0.06%     
==========================================
  Files          40       41       +1     
  Lines       10028    10125      +97     
  Branches     2322     2345      +23     
==========================================
+ Hits         8572     8661      +89     
- Misses       1456     1464       +8     
Impacted Files Coverage Δ
src/util/date-ranges.js 88.33% <88.33%> (ø)
src/util/text-tracks.js 88.70% <95.23%> (+1.20%) :arrow_up:
src/playlist-controller.js 95.22% <100.00%> (+0.01%) :arrow_up:
src/playlist-loader.js 95.19% <100.00%> (+0.19%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more