private void Start()
        {
            _mediaPlayer.VideoRenderMaterial = _videoRenderMaterial;
            _mediaPlayer.StereoMode          = _stereoMode;
            _mediaPlayer.VideoSource         = _url;
            _mediaPlayer.LicenseServer       = _licenseUrl;
            _mediaPlayer.IsLooping           = _autoLoop;
            if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0)
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                foreach (StringKeyValue pair in _customLicenseHeaderData)
                {
                    if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value))
                    {
                        dict[pair.Key] = pair.Value;
                    }
                }
                _mediaPlayer.CustomLicenseHeaderData = dict;
            }

            MLResult result = _mediaPlayer.PrepareVideo();

            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                _statusText.text = result.ToString();
            }

            EnableUI(false);
            _timelineSlider.Value = 0;
        }
Пример #2
0
        private void Start()
        {
            _mediaPlayer.VideoSource   = _url;
            _mediaPlayer.LicenseServer = _licenseUrl;
            if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0)
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                foreach (StringKeyValue pair in _customLicenseHeaderData)
                {
                    if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value))
                    {
                        dict[pair.Key] = pair.Value;
                    }
                }
                _mediaPlayer.CustomLicenseHeaderData = dict;
            }

            MLResult result = _mediaPlayer.PrepareVideo();

            if (!result.IsOk)
            {
                _statusText.text = result.ToString();
            }

            EnableUI(false);
            _timelineSlider.Value = 0;
        }
Пример #3
0
        private void Start()
        {
            _mediaPlayer.VideoSource   = _url;
            _mediaPlayer.LicenseServer = _licenseUrl;
            _mediaPlayer.PrepareVideo();

            _volumeSlider.Value     = STARTING_VOLUME;
            _elapsedTime.text       = "--:--:--";
            _timelineSlider.enabled = false;
            _timelineSlider.Value   = 0;

            _mediaPlayer.OnPause           += HandlePause;
            _mediaPlayer.OnPlay            += HandlePlay;
            _mediaPlayer.OnStop            += HandleStop;
            _mediaPlayer.OnEnded           += HandleEnded;
            _mediaPlayer.OnSeekUpdate      += HandleSeek;
            _mediaPlayer.OnBufferingUpdate += HandleBufferUpdate;
            _mediaPlayer.OnError           += HandleError;
            _mediaPlayer.OnInfo            += HandleInfo;

            _pausePlayButton.OnToggle              += PlayPause;
            _rewindButton.OnControllerTriggerDown  += Rewind;
            _forwardButton.OnControllerTriggerDown += FastForward;
            _timelineSlider.OnValueChanged         += Seek;
            _volumeSlider.OnValueChanged           += SetVolume;
        }
Пример #4
0
        void Start()
        {
            MLResult result = MLInput.Start();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ScreensExample failed to start MLInput, disabling script. Reason {0}", result);
                enabled = false;
                return;
            }

            result = MLScreens.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ScreensExample failed to start MLScreens, disabling script. Reason {0}", result);
                enabled = false;
                return;
            }

            if (MLScreens.GetLauncherScreenId() == -1)
            {
                Debug.LogError("Error: ScreensExample is unable to parse screen id from command line. " +
                               "Make sure app is launched from screens universe launcher, disabling script..");
                enabled = false;
                return;
            }

            if (!UpdateLaunchedScreen())
            {
                return;
            }

            if (!_mediaPlayer)
            {
                Debug.LogError("Error: ScreensExample no MLMediaPlayer Found");
                DisplayVideoError();
                return;
            }

            _mediaPlayer.OnMediaError    += HandleError;
            _mediaPlayer.OnVideoPrepared += HandleVideoPrepared;

            _mediaPlayer.VideoSource = _url;
            result = _mediaPlayer.PrepareVideo();
            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }
                DisplayVideoError();
                Debug.LogErrorFormat("Error: ScreensExample MLMediaPlayer PrepareVideo failed. Reason {0}", result);
            }

            EnableUI(false);
        }
Пример #5
0
        private void Start()
        {
            _mediaPlayer.VideoSource   = _url;
            _mediaPlayer.LicenseServer = _licenseUrl;
            MLResult result = _mediaPlayer.PrepareVideo();

            if (!result.IsOk)
            {
                _statusText.text = result.ToString();
            }

            EnableUI(false);
            _timelineSlider.Value = 0;
        }
        /// <summary>
        /// Handles video capture ending.
        /// </summary>
        /// <param name="path">file path to load captured video to.</param>
        public void OnCaptureEnded(string path)
        {
            // Manage canvas visuals
            _recordingIndicator.SetActive(false);
            _previewText.text = "Press the bumper to start capturing a video.";

            // Load the captured video
            _mediaPlayer.VideoSource = path;
            MLResult result = _mediaPlayer.PrepareVideo();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: VideoCaptureVisualizer failed to prepare video on capture end. Reason: {0}", result);
            }
        }
Пример #7
0
        /// <summary>
        /// Handles video capture ending.
        /// </summary>
        /// <param name="path">file path to load captured video to.</param>
        public void OnCaptureEnded(string path)
        {
            // Manage canvas visuals
            _recordingIndicator.SetActive(false);

            #if PLATFORM_LUMIN
            // Only attempt to display video if we have a valid filename.
            if (!string.IsNullOrEmpty(path))
            {
                // Load the captured video
                _mediaPlayer.VideoSource = path;
                MLResult result = _mediaPlayer.PrepareVideo();
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: VideoCaptureVisualizer failed to prepare video on capture end. Reason: {0}", result);
                }
            }
            #endif
        }
Пример #8
0
        async UniTask PlayVideo(string url)
        {
            _mediaPlayer.VideoSource = url;

            // Start observing OnMediaError before PrepareVideo because
            // PrepareVideo itself can trigger MediaError events
            var error    = _mediaPlayer.OnMediaErrorAsObservable().ToUniTask(useFirstValue: true);
            var complete = _mediaPlayer.OnVideoPreparedAsObservable().ToUniTask(useFirstValue: true);

            _mediaPlayer.PrepareVideo().ThrowIfFail();

            // Throw exception in case an error happens,
            // otherwise wait until preparation is completed
            await UniTask.WhenAny(error, complete);

            // Play video
            _mediaPlayer.IsLooping = true;
            _mediaPlayer.Play().ThrowIfFail();
        }
Пример #9
0
        /// <summary>
        /// Initialize MLMediaPlayer parameters and attempt prepare the video.
        /// </summary>
        private void Start()
        {
            #if PLATFORM_LUMIN
            _mediaPlayer.VideoRenderMaterial = _videoRenderMaterial;
            _mediaPlayer.StereoMode          = _stereoMode;
            _mediaPlayer.VideoSource         = _url;
            _mediaPlayer.LicenseServer       = _licenseUrl;
            _mediaPlayer.IsLooping           = _autoLoop;
            #endif

            if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0)
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                foreach (StringKeyValue pair in _customLicenseHeaderData)
                {
                    if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value))
                    {
                        dict[pair.Key] = pair.Value;
                    }
                }

                #if PLATFORM_LUMIN
                _mediaPlayer.CustomLicenseHeaderData = dict;
                #endif
            }

            #if PLATFORM_LUMIN
            MLResult result = _mediaPlayer.PrepareVideo();
            if (!result.IsOk)
            {
                _statusText.text = result.ToString();
            }
            #endif

            EnableUI(false);
            _timelineSlider.Value = 0;
        }