Exemplo n.º 1
0
        protected override void Update()
        {
            if (IsTransitioning())
            {
                _transitionTimer += Time.deltaTime;
                float t = _easeFunc(_transitionTimer / _transitionDuration);

                // Fade the audio volume
                NextPlayer.Control.SetVolume(1f - t);
                CurrentPlayer.Control.SetVolume(t);

                // TODO: support going from mono to stereo
                // TODO: support videos of different aspect ratios by rendering with scaling to fit
                // This can be done by blitting twice, once for each eye
                // If the stereo mode is different for playera/b then both should be set to stereo during the transition
                // if (CurrentPlayer.m_StereoPacking == StereoPacking.TopBottom)....
                _material.SetFloat(_propT, t);
                _rt.DiscardContents();
                Graphics.Blit(CurrentPlayer.TextureProducer.GetTexture(), _rt, _material);

                // After the transition is complete, pause the previous video
                if (!_pausePreviousOnTransition && !IsTransitioning())
                {
                    if (NextPlayer != null && NextPlayer.Control.IsPlaying())
                    {
                        NextPlayer.Pause();
                    }
                }
            }

            base.Update();
        }
        protected override void Update()
        {
            if (IsTransitioning())
            {
                _transitionTimer += Time.deltaTime;
                float t = _easeFunc(Mathf.Clamp01(_transitionTimer / _currentTransitionDuration));

                // Fade the audio volume
                NextPlayer.Control.SetVolume(1f - t);
                CurrentPlayer.Control.SetVolume(t);

                // TODO: support going from mono to stereo
                // TODO: support videos of different aspect ratios by rendering with scaling to fit
                // This can be done by blitting twice, once for each eye
                // If the stereo mode is different for playera/b then both should be set to stereo during the transition
                // if (CurrentPlayer.m_StereoPacking == StereoPacking.TopBottom)....
                _material.SetFloat(_propT, t);
                _rt.DiscardContents();
                Graphics.Blit(GetCurrentTexture(), _rt, _material);

                // After the transition is now complete, close/pause the previous video if required
                bool isTransitioning = IsTransitioning();
                if (!isTransitioning)
                {
                    if (_autoCloseVideo)
                    {
                        if (NextPlayer != null)
                        {
                            NextPlayer.m_VideoPath = string.Empty;
                            NextPlayer.CloseVideo();
                        }
                    }
                    else if (!_pausePreviousOnTransition)
                    {
                        if (NextPlayer != null && NextPlayer.Control.IsPlaying())
                        {
                            NextPlayer.Pause();
                        }
                    }
                }
            }
            else
            {
                if (_playlistAutoProgress && _nextItem == null && _currentItem != null && _currentItem.progressMode == ProgressMode.BeforeFinish && Control != null && Control.GetCurrentTimeMs() >= (Info.GetDurationMs() - (_currentItem.progressTimeSeconds * 1000f)))
                {
                    this.NextItem();
                }
            }

            base.Update();
        }