Пример #1
0
        public override void OnVideoReady()
        {
            float duration = _currentPlayer.GetDuration();

            DebugLog("Video ready, duration: " + duration + ", position: " + _currentPlayer.GetTime());

            // If a seekable video is loaded it should have a positive duration.  Otherwise we assume it's a non-seekable stream
            seekableSource = !float.IsInfinity(duration) && !float.IsNaN(duration) && duration > 1;

            // If player is owner: play video
            // If Player is remote:
            //   - If owner playing state is already synced, play video
            //   - Otherwise, wait until owner playing state is synced and play later in update()
            //   TODO: Streamline by always doing this in update instead?

            if (Networking.IsOwner(gameObject))
            {
                _currentPlayer.Play();
            }
            else
            {
                // TODO: Stream bypass owner
                if (_syncOwnerPlaying)
                {
                    _currentPlayer.Play();
                }
                else
                {
                    _waitForSync = true;
                }
            }
        }
Пример #2
0
        public void OnSliderChanged()
        {
            if (!_draggingSlider || !allowSeeking)
            {
                return;
            }

            if (!Networking.IsOwner(gameObject))
            {
                return;
            }

            float newSliderValue = videoProgressSlider.value;
            float newTargetTime  = _currentPlayer.GetDuration() * newSliderValue;

            _videoStartNetworkTime = (float)Networking.GetServerTimeInSeconds() - newTargetTime;

            SyncVideo();
        }
Пример #3
0
 public override void OnVideoReady()
 {
     if (!_player)
     {
         return;
     }
     DebugLog($"The video is ready.");
     _status = _status & ~_status_fetch | _status_play;
     if (float.IsInfinity(_player.GetDuration()))
     {
         _status = _status | _status_stream;
     }
     SetElapsedTime(_timeSync);
     _player.Play();
     if (IsStatus(_status_pause))
     {
         _player.Pause();
     }
     ValidateView();
 }
Пример #4
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);
            }
        }