コード例 #1
0
        public void _StopVideo()
        {
            DebugLog("Stop video");

            if (seekableSource)
            {
                _lastVideoPosition = _currentPlayer.GetTime();
            }

            localPlayerState = PLAYER_STATE_STOPPED;

            _currentPlayer.Stop();
            _videoTargetTime = 0;
            _pendingPlayTime = 0;
            _pendingLoadTime = 0;
            _playStartTime   = 0;

            if (Networking.IsOwner(gameObject))
            {
                _syncVideoStartNetworkTime = 0;
                _syncOwnerPlaying          = false;
                _syncUrl = VRCUrl.Empty;
                RequestSerialization();
            }
        }
コード例 #2
0
        public void Prepare(int slideIndex)
        {
            if (mainPlayerController == null)
            {
                return;
            }
            Debug.Log("Prepping talk");
            mainPlayer      = mainPlayerController.vPlayer;
            lookaheadPlayer = lookaheadPlayerController.vPlayer;

            mainPlayerController.currUrl = talkUrl;
            currSlide = slideIndex;
            var currSlideStart = GetSlideStart();

            mainPlayerController.LoadAndSeek(currSlideStart);

            if (!isOwner)
            {
                lookaheadPlayer.Stop();
                lookaheadPlayerController.enabled = false;
                return;
            }

            lookaheadPlayerController.enabled = true;
            lookaheadPlayerController.currUrl = talkUrl;
            lookaheadPlayerController.LoadAndSeek(GetNextSlideEnd(currSlideStart));
        }
コード例 #3
0
        public void HandleURLInput()
        {
            if (!Networking.IsOwner(gameObject))
            {
                return;
            }

            _syncedURL = inputField.GetUrl();
            _videoNumber++;

            _loadedVideoNumber = _videoNumber;

            _currentPlayer.Stop();
            _currentPlayer.LoadURL(_syncedURL);
            _ownerPlaying = false;

            _videoStartNetworkTime = float.MaxValue;

            Debug.Log("Video URL Changed to " + _syncedURL);
        }
コード例 #4
0
 public void OnPowerOff()
 {
     DebugLog($"Received a power-off event.");
     enabled = false;
     _status = _status_off | _status_stop;
     _player1.Stop();
     _player2.Stop();
     _addressInput.SetUrl(VRCUrl.Empty);
     _player       = null;
     _progressDrag = false;
     ValidateView();
 }
コード例 #5
0
        void StartVideoLoad(VRCUrl url)
        {
            if (Time.time < _delayStartLoad)
            {
                return;
            }

            if (url != null)
            {
                string urlStr = url.Get();

                // RTSPT sources (and maybe others!?) trigger a spontaneous OnVideoEnd event at video start
                if (currentPlayerMode == PLAYER_MODE_STREAM && urlStr.Contains("rtspt://"))
                {
                    _rtsptSource = true;
                    Debug.Log("[USharpVideo] Detected RTSPT source");
                }
                else
                {
                    _rtsptSource = false;
                }
            }

            Debug.Log("[USharpVideo] Started video load");
            _statusStr = "Loading video...";
            SetStatusText(_statusStr);
            _delayStartLoad     = 0f;
            _loadingVideo       = true;
            _currentLoadingTime = 0f;
            _currentRetryCount  = 0;
            _currentPlayer.Stop();
            _currentPlayer.LoadURL(url);
        }
コード例 #6
0
 void LoadURL(VRCUrl url, int serial)
 {
     if (!_player)
     {
         return;
     }
     DebugLog($"Load the video with the URL `{url.Get()}` and set the serial to {serial}.");
     _status           = _status & ~_status_stop | _status_fetch;
     _url              = url;
     _serial           = serial;
     _messageText.text = $"Loading";
     _player.Stop();
     _player.LoadURL(url);
     ValidateView();
 }
コード例 #7
0
 public void Stop()
 {
     vPlayer.Stop();
 }
コード例 #8
0
        void PlayVideo(VRCUrl url, bool disablePlaylist)
        {
            bool isOwner = Networking.IsOwner(gameObject);

            if (!isOwner && !Networking.IsMaster && _masterOnly)
            {
                return;
            }

            if (_syncedURL != null && url.Get() == "")
            {
                return;
            }

            if (!isOwner)
            {
                Networking.SetOwner(Networking.LocalPlayer, gameObject);
            }

            if (disablePlaylist)
            {
                // -1 means we have stopped using the playlist since we had manual input
                _nextPlaylistIndex = -1;
            }

            StopVideo();

            _syncedURL = url;
            inputField.SetUrl(VRCUrl.Empty);

            if (isOwner)
            {
                _videoNumber++;
            }
            else // Add two to avoid having conflicts where the old owner increases the count
            {
                _videoNumber += 2;
            }

            _loadedVideoNumber = _videoNumber;
            StartVideoLoad(_syncedURL);
            _currentPlayer.Stop();
            _ownerPlaying  = false;
            _locallyPaused = _ownerPaused = false;

            _videoStartNetworkTime = float.MaxValue;

            if (Networking.IsOwner(gameObject))
            {
                // Attempt to parse out a start time from YouTube links with t= or start=
                string urlStr = url.Get();

                if (currentPlayerMode != PLAYER_MODE_STREAM &&
                    (urlStr.Contains("youtube.com/watch") ||
                     urlStr.Contains("youtu.be/")))
                {
                    int tIndex = -1;

                    tIndex = urlStr.IndexOf("?t=");

                    if (tIndex == -1)
                    {
                        tIndex = urlStr.IndexOf("&t=");
                    }
                    if (tIndex == -1)
                    {
                        tIndex = urlStr.IndexOf("?start=");
                    }
                    if (tIndex == -1)
                    {
                        tIndex = urlStr.IndexOf("&start=");
                    }

                    if (tIndex != -1)
                    {
                        char[] urlArr = urlStr.ToCharArray();
                        int    numIdx = urlStr.IndexOf('=', tIndex) + 1;

                        string intStr = "";

                        while (numIdx < urlArr.Length)
                        {
                            char currentChar = urlArr[numIdx];
                            if (!char.IsNumber(currentChar))
                            {
                                break;
                            }

                            intStr += currentChar;

                            ++numIdx;
                        }

                        if (intStr.Length > 0)
                        {
                            int secondsCount = 0;
                            if (int.TryParse(intStr, out secondsCount))
                            {
                                _videoTargetStartTime = secondsCount;
                            }
                            else
                            {
                                _videoTargetStartTime = 0f;
                            }
                        }
                        else
                        {
                            _videoTargetStartTime = 0f;
                        }
                    }
                    else
                    {
                        _videoTargetStartTime = 0f;
                    }
                }
                else
                {
                    _videoTargetStartTime = 0f;
                }
            }
            else
            {
                _videoTargetStartTime = 0f;
            }

            Debug.Log("[USharpVideo] Video URL Changed to " + _syncedURL);
        }