internal void CheckForSubtitles( ) { if (!HaveSubtitlesBeenLoaded || !enabled) { return; } TimeSpan position = Player.GetComponent <TimeComponent>( ).GetPosition( ); TimeSpan currentPosition = position - subtitlesOffset; if (!Subtitles.AnySubtitlesLeft(currentPosition)) { return; } SubtitleSegment nextSubs = Subtitles.GetData(currentPosition); SubtitleSegment subs = nextSubs != null?Subtitles.GetData(nextSubs.Index - 1) : Subtitles.GetData(Subtitles.Count - 1); // If we're in the sub interval. if (currentPosition < subs.To && currentPosition >= subs.From) { this.OnSubtitlesChanged?.Invoke(this, new OnSubtitlesChangedEventArgs(subs)); subtitlesTimer.Interval = subs.To - currentPosition; } // If we're not in a sub interval else { // Stop the showing of subtitles. this.StopSubtitles( ); // If there are still subs left, change the interval to run when they need to be shown. if (nextSubs != null) { subtitlesTimer.Interval = nextSubs.From - currentPosition; } // Otherwise, don't bother starting the timer again. else { return; } } subtitlesTimer.Start( ); }
/// <summary> /// Constructor. /// </summary> /// <param name="SubtitleSegment">The new subtitles.</param> public OnSubtitlesChangedEventArgs(SubtitleSegment SubtitleSegment) { Subtitles = SubtitleSegment; }