Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/ui/Features/Main/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6087,6 +6087,8 @@ private async Task ShowVideoSetOffset()
return;
}

var oldOffsetMs = Se.Settings.General.CurrentVideoOffsetInMs;

var result = await ShowDialogAsync<SetVideoOffsetWindow, SetVideoOffsetViewModel>();

if (result.ResetPressed)
Expand All @@ -6111,14 +6113,23 @@ private async Task ShowVideoSetOffset()
offset = offset - TimeSpan.FromSeconds(vp.Position);
}

Se.Settings.General.CurrentVideoOffsetInMs = (int)Math.Round(offset.TotalMilliseconds, MidpointRounding.AwayFromZero);
Se.Settings.General.CurrentVideoOffsetInMs = (long)Math.Round(offset.TotalMilliseconds, MidpointRounding.AwayFromZero);
}

if (result.KeepTimeCodes)
// The video offset is a non-destructive display offset (see TimeSpanToDisplayFullConverter):
// the listview shows "time code + offset" while the underlying time codes stay untouched.
// "Keep existing time codes" therefore leaves the time codes alone. When it is NOT checked,
// we bake the offset change into the time codes so the displayed values stay the same.
if (!result.KeepTimeCodes)
{
foreach (var s in Subtitles)
var delta = TimeSpan.FromMilliseconds(Se.Settings.General.CurrentVideoOffsetInMs - oldOffsetMs);
if (delta != TimeSpan.Zero)
{
s.StartTime = s.StartTime - offset;
foreach (var s in Subtitles)
{
s.StartTime -= delta;
s.EndTime -= delta;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void Ok()
return;
}

Se.Settings.General.CurrentVideoOffsetInMs = (int)Math.Round(TimeOffset.Value.TotalMilliseconds, MidpointRounding.AwayFromZero);
Se.Settings.General.CurrentVideoOffsetInMs = (long)Math.Round(TimeOffset.Value.TotalMilliseconds, MidpointRounding.AwayFromZero);
OkPressed = true;
Window?.Close();
}
Expand Down