Skip to content

Commit

Permalink
make sure stream is not selfstream before skipping silence
Browse files Browse the repository at this point in the history
  • Loading branch information
Mjaethers committed Jan 14, 2024
1 parent 5adf695 commit 5dde9e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion model/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,12 @@ func (s Stream) ToDTO() StreamDTO {
}
}

// FirstSilenceAsProgress returns the end of the first silence as a float between 0 and 1
// FirstSilenceAsProgress returns the end of the first silence as a quotient of the length of the stream
func (s Stream) FirstSilenceAsProgress() float64 {
// Sanity check: first silence at beginning of stream
if s.Silences[0].Start != 0 {
return 0
}
duration := s.End.Sub(s.Start).Seconds()
p := float64(s.Silences[0].End) / duration

Expand Down
5 changes: 4 additions & 1 deletion web/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ func (r mainRoutes) WatchPage(c *gin.Context) {
if err != nil {
log.Printf("Couldn't decode user setting: %v\n", err)
} else if autoSkip.Enabled {
data.Progress.Progress = math.Max(data.Progress.Progress, tumLiveContext.Stream.FirstSilenceAsProgress())
// The length of the stream may mismatch with the length of the video if it is a self-stream
if tumLiveContext.Stream.LectureHallID != 0 {
data.Progress.Progress = math.Max(data.Progress.Progress, tumLiveContext.Stream.FirstSilenceAsProgress())
}
}
}
if c.Query("restart") == "1" {
Expand Down

0 comments on commit 5dde9e4

Please sign in to comment.