private async Task ResyncWithPlayerAsync(SubtitleInterval currentInterval) { var mediaPosition = _providerMediaElement.MediaElement.Position; var result = currentInterval.Start.Subtract(mediaPosition); var tolerance = TimeSpan.FromMilliseconds(10); if (result > tolerance) { //current is ahead await Task.Delay(result, _pauseToken.Token).ContinueWith(_ => { }); } }
private static bool TryParseSubtitleInterval(string input, out SubtitleInterval interval) { if (string.IsNullOrEmpty(input)) { interval = null; return(false); } var segments = input.Split(new[] { Settings.SubtitleSeparationString }, StringSplitOptions.None) .Select(s => s.Trim(' ').Replace(',', '.').Replace('.', ':')).ToArray(); return(SubtitleInterval.TryParse(segments, Settings.GetTimeSpanStringFormats(), out interval)); }
public SubtitleSegment([NotNull] SubtitleInterval subtitleInterval, string content) { Interval = subtitleInterval ?? throw new ArgumentNullException(nameof(subtitleInterval)); Content = content; }