コード例 #1
0
        private void CheckSubtitles()
        {
            SubtitleBlock subtitleBlock = _srtParser.GetForTime((float)_videoPlayer.time);

            if (subtitleBlock.Index != _currentSubtitleIndex)
            {
                ShowSubtitle(subtitleBlock);
                _currentSubtitleIndex = subtitleBlock.Index;
            }
        }
コード例 #2
0
        private void VideoPlayerOnloopPointReached(VideoPlayer source)
        {
            SubtitleBlock subtitleBlock = _srtParser.GetForTime((float)_videoPlayer.time);

            if (subtitleBlock.Index != _currentSubtitleIndex)
            {
                ShowSubtitle(subtitleBlock);
                _currentSubtitleIndex = subtitleBlock.Index;
            }
            OnVideoClipFinished?.Invoke(source.clip);
        }
コード例 #3
0
        public IEnumerator Begin()
        {
            var currentlyDisplayingText = Text;
            var fadedOutText            = Text2;

            currentlyDisplayingText.text = string.Empty;
            fadedOutText.text            = string.Empty;

            currentlyDisplayingText.gameObject.SetActive(true);
            fadedOutText.gameObject.SetActive(true);

            var parser = new SRTParser(Subtitle);

            var           startTime       = Time.time;
            SubtitleBlock currentSubtitle = null;

            while (true)
            {
                var elapsed  = Time.time - startTime;
                var subtitle = parser.GetForTime(elapsed);
                if (subtitle != null)
                {
                    if (!subtitle.Equals(currentSubtitle))
                    {
                        currentSubtitle = subtitle;

                        // Swap references around
                        var temp = currentlyDisplayingText;
                        currentlyDisplayingText = fadedOutText;
                        fadedOutText            = temp;

                        // Switch subtitle text
                        currentlyDisplayingText.text = currentSubtitle.Text;

                        // Yield a bit for the fade out to get part-way
                        yield return(new WaitForSeconds(FadeTime / 3));

                        // Fade in the new current
                        //yield return FadeTextIn(currentlyDisplayingText);
                    }

                    yield return(null);
                }
                else
                {
                    currentlyDisplayingText.gameObject.SetActive(false);
                    fadedOutText.gameObject.SetActive(false);
                    yield break;
                }
            }
        }
コード例 #4
0
 private void ShowSubtitle(SubtitleBlock subtitleBlock)
 {
     // if(_currentSubtitleIndex > 0)
     // {
     //     OnHideSubtitle?.Invoke(_srtParser._subtitles[_currentSubtitleIndex - 1].Text);
     // }
     if (subtitleBlock != SubtitleBlock.Blank)
     {
         OnShowSubtitle?.Invoke(subtitleBlock.Text);
     }
     else if (_currentSubtitleIndex > 0)
     {
         OnHideSubtitle?.Invoke(_srtParser._subtitles[_currentSubtitleIndex - 1].Text);
     }
     if (_showSubtitles)
     {
         _subtitlePanel.SetText(subtitleBlock.Text);
     }
 }