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();
        }
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            /*
             * if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
             * {
             *      isMediaAlreadyLoaded = true;
             * }*/

            if (mediaItem.isOverrideTransition)
            {
                SetTransition(mediaItem.overrideTransition, mediaItem.overrideTransitionDuration, mediaItem.overrideTransitionEasing.preset);
            }
            else
            {
                SetTransition(_nextTransition, _transitionDuration, _transitionEasing.preset);
            }

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_AutoStart     = NextPlayer.m_AutoStart = mediaItem.autoPlay;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                if (_nextItem.startMode == StartMode.Immediate)
                {
                    NextPlayer.Play();
                }
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, _nextItem.startMode == StartMode.Immediate);
                }
            }
        }
Example #3
0
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
            {
                isMediaAlreadyLoaded = true;
            }

            SetTransition(_nextTransition);

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                NextPlayer.Play();
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, true);
                }
            }
        }
 public void CloseVideoExt()
 {
     NextPlayer.CloseVideo();
     CurrentPlayer.CloseVideo();
 }