Skip to content

Commit 0df93e0

Browse files
committed
Add getCues method to return all cues
1 parent 9e03e46 commit 0df93e0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

.changeset/wild-ideas-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'js-vtt': patch
3+
---
4+
5+
Add getCues method to return all cues

src/vtt.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ export class VTT {
231231

232232
return true;
233233
}
234+
/**
235+
* Retrieves all cue segments from the VTT instance, filtering the internal list of segments to return only those that are instances of the Cue class.
236+
*
237+
* @returns An array of Cue instances representing all cue segments in the VTT file.
238+
*/
239+
getCues() {
240+
return this.#segments.filter((s): s is Cue => s instanceof Cue);
241+
}
234242
/**
235243
* Converts the VTT instance to a JSON representation, including the header and all segments.
236244
* This can be useful for serialization, debugging, or interoperability with other systems.

0 commit comments

Comments
 (0)