コード例 #1
0
        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(_ => { });
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public SubtitleSegment([NotNull] SubtitleInterval subtitleInterval, string content)
 {
     Interval = subtitleInterval ?? throw new ArgumentNullException(nameof(subtitleInterval));
     Content  = content;
 }