From c612ebb2e41ad10d469841579969dda9ab296895 Mon Sep 17 00:00:00 2001 From: Deivid Soto Date: Tue, 7 Apr 2026 23:29:00 +0200 Subject: [PATCH] feat(stream): report duration and position in watch progress EstimatedProgress now returns video duration in seconds (from ffprobe). WatchReporter sends Position and Duration fields when available, giving the server precise playback time instead of just a percentage. --- internal/engine/watch_reporter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/engine/watch_reporter.go b/internal/engine/watch_reporter.go index e7fa4da..9e6c185 100644 --- a/internal/engine/watch_reporter.go +++ b/internal/engine/watch_reporter.go @@ -47,7 +47,7 @@ func (wr *WatchReporter) Run(ctx context.Context) { } func (wr *WatchReporter) sendReport(ctx context.Context) { - pct, _ := wr.server.EstimatedProgress() + pct, durSec := wr.server.EstimatedProgress() if pct == 0 || pct == wr.lastSentPct { return } @@ -58,6 +58,11 @@ func (wr *WatchReporter) sendReport(ctx context.Context) { Source: "range", Progress: &pct, } + if durSec > 0 { + update.Duration = &durSec + pos := int(float64(pct) / 100 * float64(durSec)) + update.Position = &pos + } reportCtx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel()