Files
playback/internal/srt/types.go
2026-01-25 17:13:15 -06:00

40 lines
839 B
Go

package srt
import "time"
// Cue represents a single subtitle entry
type Cue struct {
Index int
Start time.Duration
End time.Duration
Text string
LineNumber int // Line number in the SRT file (1-indexed)
}
// Transcript represents a complete subtitle file
type Transcript struct {
Cues []Cue
FilePath string
IsTemp bool
}
// CueAt returns the cue that contains the given time position
func (t *Transcript) CueAt(pos time.Duration) *Cue {
for i := range t.Cues {
if pos >= t.Cues[i].Start && pos < t.Cues[i].End {
return &t.Cues[i]
}
}
return nil
}
// CueIndexAt returns the index of the cue at the given position, or -1
func (t *Transcript) CueIndexAt(pos time.Duration) int {
for i := range t.Cues {
if pos >= t.Cues[i].Start && pos < t.Cues[i].End {
return i
}
}
return -1
}