diff --git a/README.md b/README.md index 5c6d263..4cafcd3 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ This section describes the structure of the object returned by `parse()` method. | `dateRange` | `DateRange` | No | undefined | See [EXT-X-DATERANGE](https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.7) | | `markers` | [`SpliceInfo`] | No | [] | SCTE-35 messages associated with this segment| | `parts` | [`PartialSegment`] | No | [] | Partial Segments that constitute this segment | +| `gap` | boolean | No | undefined | See [EXT-X-GAP](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.4.7) | ### `PartialSegment` (extends `Data`) | Property | Type | Required | Default | Description | diff --git a/stringify.ts b/stringify.ts index b8b7836..62de521 100644 --- a/stringify.ts +++ b/stringify.ts @@ -331,6 +331,9 @@ function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastM if (segment.discontinuity) { lines.push(`#EXT-X-DISCONTINUITY`); } + if (segment.gap) { + lines.push(`#EXT-X-GAP`); + } if (segment.key) { const line = buildKey(segment.key); if (line !== lastKey) { diff --git a/test/spec/4_Playlists/4.3_Playlist-Tags/4.3.2_Media-Segment-Tags/4.4.4.7_EXT-X-GAP.spec.js b/test/spec/4_Playlists/4.3_Playlist-Tags/4.3.2_Media-Segment-Tags/4.4.4.7_EXT-X-GAP.spec.js index e8412e9..46cf29c 100644 --- a/test/spec/4_Playlists/4.3_Playlist-Tags/4.3.2_Media-Segment-Tags/4.4.4.7_EXT-X-GAP.spec.js +++ b/test/spec/4_Playlists/4.3_Playlist-Tags/4.3.2_Media-Segment-Tags/4.4.4.7_EXT-X-GAP.spec.js @@ -1,5 +1,7 @@ const test = require("ava"); +const HLS = require('../../../../..'); const utils = require("../../../../helpers/utils"); +const {equalPlaylist} = require("../../../../helpers/matchers"); // https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.4.7 @@ -38,3 +40,17 @@ test('#EXT-X-TAG_02', t => { #EXT-X-ENDLIST `); }); + +test('#EXT-X-TAG_03', t => { + const txt = ` + #EXTM3U + #EXT-X-VERSION:8 + #EXT-X-TARGETDURATION:5 + #EXT-X-GAP + #EXTINF:4, + 1.ts + `; + const playlist = HLS.parse(txt); + t.truthy(playlist.segments[0].gap); + equalPlaylist(t, txt, HLS.stringify(playlist)); +});