Пример #1
0
        public override void OnVideoStart()
        {
            DebugLog("Video start");

            if (Networking.IsOwner(gameObject))
            {
                localPlayerState = PLAYER_STATE_PLAYING;
                _playStartTime   = Time.time;

                _syncVideoStartNetworkTime = (float)Networking.GetServerTimeInSeconds() - _videoTargetTime;
                _syncOwnerPlaying          = true;
                RequestSerialization();

                _currentPlayer.SetTime(_videoTargetTime);
            }
            else
            {
                if (!_syncOwnerPlaying)
                {
                    // TODO: Owner bypass
                    _currentPlayer.Pause();
                    _waitForSync = true;
                }
                else
                {
                    localPlayerState = PLAYER_STATE_PLAYING;
                    _playStartTime   = Time.time;

                    SyncVideo();
                }
            }
        }
Пример #2
0
        public override void OnVideoStart()
        {
            Debug.Log("[USharpVideo] Video start");

            if (Networking.IsOwner(gameObject))
            {
                if (_locallyPaused)
                {
                    _videoStartNetworkTime = (float)Networking.GetServerTimeInSeconds() - _currentPlayer.GetTime();
                }
                else
                {
                    _videoStartNetworkTime = (float)Networking.GetServerTimeInSeconds() - _videoTargetStartTime;
                }

                _ownerPaused  = _locallyPaused = false;
                _ownerPlaying = true;
            }
            else if (!_ownerPlaying) // Watchers pause and wait for sync from owner
            {
                bool bypass = _streamBypassOwner && currentPlayerMode == PLAYER_MODE_STREAM;
                if (!bypass)
                {
                    _currentPlayer.Pause();
                    _waitForSync = true;
                }
            }

            UpdateScreenMaterial(SCREEN_MODE_NORMAL);

            _statusStr      = "";
            _draggingSlider = false;

            lastVideoField.text    = currentVideoField.text;
            currentVideoField.text = _syncedURL.Get();

            if (currentPlayerMode == PLAYER_MODE_VIDEO)
            {
                _currentPlayer.SetTime(_videoTargetStartTime);
            }
            _videoTargetStartTime = 0f;

#if !UNITY_EDITOR // Causes null ref exceptions so just exclude it from the editor
            videoOwnerTextField.text = Networking.GetOwner(gameObject).displayName;
#endif
        }
Пример #3
0
        void SyncVideo()
        {
            float offsetTime = Mathf.Clamp((float)Networking.GetServerTimeInSeconds() - _videoStartNetworkTime, 0f, _currentPlayer.GetDuration());

            if (Mathf.Abs(_currentPlayer.GetTime() - offsetTime) > syncThreshold)
            {
                _currentPlayer.SetTime(offsetTime);
                Debug.LogFormat("Syncing Video to {0:N2}", offsetTime);
            }
        }
Пример #4
0
 void SetElapsedTime(float time)
 {
     if (!_player)
     {
         return;
     }
     DebugLog($"Set the progress time to {(float)Networking.GetServerTimeInSeconds() - time}.");
     _time = time;
     _player.SetTime((float)Networking.GetServerTimeInSeconds() - time);
     ValidateView();
 }
Пример #5
0
        // Pauses videos and stops streams
        public void TriggerPauseButton()
        {
            if (!Networking.IsOwner(gameObject))
            {
                return;
            }

            _ownerPaused = !_ownerPaused;

            if (currentPlayerMode == PLAYER_MODE_VIDEO ||
                currentPlayerMode == PLAYER_MODE_KARAOKE)
            {
                if (_ownerPaused)
                {
                    _currentPlayer.Pause();
                    _locallyPaused = true;
                }
                else
                {
                    _currentPlayer.Play();
                }
            }
            else
            {
                if (_ownerPaused)
                {
                    _currentPlayer.Pause();
                    _locallyPaused = true;
                }
                else
                {
                    _currentPlayer.Play();
                    _currentPlayer.SetTime(float.MaxValue);
                }
            }

            playIcon.SetActive(_ownerPaused);
            pauseStopIcon.SetActive(!_ownerPaused);
        }
Пример #6
0
        // for late joiners
        public void SeekToSlide(int slideIndex)
        {
            PauseContinuous();
            mainPlayerController.Play();
            currSlide = Mathf.Clamp(slideIndex, 0, slideDurations.Length - 1);
            var startTime = GetSlideStart();

            mainPlayerController.SetTime(startTime + 0.3f);
            Debug.Log($"ut: seeked to slide {currSlide}, time {startTime}");
            if (isOwner)
            {
                if (currSlide + 1 != slideDurations.Length)
                {
                    lookaheadPlayer.Play();
                    lookaheadPlayer.SetTime(GetNextSlideEnd(startTime));
                    lookaheadPlayer.Pause();
                }
            }

            if (!shouldAutoplay[currSlide])
            {
                mainPlayerController.Pause();
            }
            else
            {
                playingContinuously = true;
                if (currSlide + 1 == slideDurations.Length)
                {
                    shouldStopAt = float.MaxValue;
                }
                else
                {
                    shouldStopAt = startTime + slideDurations[currSlide];
                }
            }
        }
Пример #7
0
 public void SetTime(float time)
 {
     vPlayer.SetTime(time);
 }