예제 #1
0
        private IEnumerator RunDetection(BaseVideoPlayer videoPlayer)
        {
            while (!videoPlayer.IsVideoLoaded)
            {
                yield return(null);
            }

            // It isn't guaranteed that metadata is available before these conditions are met
            // in the Gvr Video Plugin.
            while (videoPlayer.CurrentPositionMilliseconds == 0 || !videoPlayer.IsPlaying)
            {
                yield return(null);
            }

            if (!videoPlayer.HasSphericalMetadata)
            {
                CompleteDetection(null);
            }
            else
            {
                StereoProjectionFormat format = new StereoProjectionFormat();
                format.stereoMode = videoPlayer.MetadataStereoMode;

                // TODO: Proper parsing of projection box in GvrVideoPlugin.
                if (videoPlayer.HasProjectionMetadata)
                {
                    format.projectionMode = BaseMediaPlayer.ProjectionMode.Projection360;
                }

                CompleteDetection(format);
            }
        }
예제 #2
0
        private static bool TryPlayMedia(MediaHelpers.MediaType mediaType, FileInfo file, BaseMediaPlayer player)
        {
            switch (mediaType)
            {
            case MediaHelpers.MediaType.Video:
                BaseVideoPlayer videoPlayer = player as BaseVideoPlayer;
                if (videoPlayer != null)
                {
                    PlayOptions options = new PlayOptions();
                    options.Path = PATH_PREFIX + file.FullName;
                    options.Type = BaseVideoPlayer.VideoType.Other;
                    videoPlayer.Play(options);
                    return(true);
                }
                break;

            case MediaHelpers.MediaType.Photo:
                BasePhotoPlayer photoPlayer = player as BasePhotoPlayer;
                if (photoPlayer != null)
                {
                    photoPlayer.ShowPhoto(file);
                    return(true);
                }
                break;

            default:
                Debug.LogError("Invalid Media Type.");
                break;
            }

            return(false);
        }
예제 #3
0
        protected override void PostAnalyzeImage()
        {
            base.PostAnalyzeImage();

            BaseVideoPlayer videoPlayer = MediaPlayer as BaseVideoPlayer;

            // Should never reach this point if the media player isn't a video player.
            Assert.IsNotNull(videoPlayer);

            videoPlayer.Paused = false;
        }
예제 #4
0
        protected override void DetectInternal()
        {
            BaseVideoPlayer videoPlayer = MediaPlayer as BaseVideoPlayer;

            if (videoPlayer == null)
            {
                CompleteDetection(null);
                return;
            }

            videoPlayer.StartCoroutine(RunDetection(videoPlayer));
        }
예제 #5
0
        protected override void DetectInternal()
        {
            BaseVideoPlayer videoPlayer = MediaPlayer as BaseVideoPlayer;

            if (videoPlayer == null)
            {
                Debug.LogError("Can't detect format, MediaPlayer must be a BaseVideoPlayer.");
                CompleteDetection(null);
                return;
            }

            analyzeVideoFrameCoroutine = MediaPlayer.StartCoroutine(AnalyzeVideoFrame(videoPlayer));
        }
예제 #6
0
        private void LoadFrameAndAnalyze(BaseVideoPlayer videoPlayer)
        {
            string path = videoPlayer.FilePath;

            if (path.StartsWith(PATH_PREFIX))
            {
                path = path.Substring(PATH_PREFIX.Length, path.Length - PATH_PREFIX.Length);
            }

            // Seek to an arbitrary frame in hopes that it has good image data to analyze.
            // and isn't just a black fade transition or something like that.
            long framePositionMilliseconds = videoPlayer.DurationMilliseconds / 4;

            MediaHelpers.GetVideoFrame(path, framePositionMilliseconds, -1, OnFrameLoaded);
        }
예제 #7
0
        private IEnumerator AnalyzeVideoFrame(BaseVideoPlayer videoPlayer)
        {
            while (!videoPlayer.IsVideoLoaded)
            {
                yield return(null);
            }

            // It isn't guaranteed that metadata is available before these conditions are met
            // in the Gvr Video Plugin.
            while (videoPlayer.CurrentPositionMilliseconds == 0 || !videoPlayer.IsPlaying)
            {
                yield return(null);
            }

            videoPlayer.Paused = true;

            LoadFrameAndAnalyze(videoPlayer);
        }
        public void Setup(BaseMediaPlayer player)
        {
            mediaPlayer = player;
            videoPlayer = mediaPlayer as BaseVideoPlayer;

            // Stereo
            Assert.IsNotNull(monoToggle);
            monoToggle.onValueChanged.AddListener(OnMonoToggleChanged);
            Assert.IsNotNull(leftRightToggle);
            leftRightToggle.onValueChanged.AddListener(OnLeftRightToggleChanged);
            Assert.IsNotNull(topBottomToggle);
            topBottomToggle.onValueChanged.AddListener(OnTopBottomToggleChanged);

            // Make sure all Stereo toggles are in the same toggle group.
            Assert.IsTrue(monoToggle.group != null &&
                          monoToggle.group == leftRightToggle.group &&
                          monoToggle.group == topBottomToggle.group);

            // Projection
            Assert.IsNotNull(flatToggle);
            flatToggle.onValueChanged.AddListener(OnFlatToggleChanged);
            Assert.IsNotNull(projection180Toggle);
            projection180Toggle.onValueChanged.AddListener(OnProjection180ToggleChanged);
            Assert.IsNotNull(projection360Toggle);
            projection360Toggle.onValueChanged.AddListener(OnProjection360ToggleChanged);

            // Make sure all Projection toggles are in the same toggle group.
            Assert.IsTrue(flatToggle.group != null &&
                          flatToggle.group == projection180Toggle.group &&
                          flatToggle.group == projection360Toggle.group);

            SetStereoModeToggle(mediaPlayer.CurrentStereoMode);
            SetProjectionModeToggle(mediaPlayer.CurrentProjectionMode);
            SetTogglesInteractable(mediaPlayer.MediaScreen != null);

            mediaPlayer.OnStereoModeChanged     += SetStereoModeToggle;
            mediaPlayer.OnProjectionModeChanged += SetProjectionModeToggle;
            mediaPlayer.OnMediaScreenChanged    += OnMediaScreenChanged;
        }
예제 #9
0
        private void CreateMediaPlayer(MediaHelpers.MediaType mediaType)
        {
            DestroyMediaPlayer();

            switch (mediaType)
            {
            case MediaHelpers.MediaType.Video:
                currentPlayerObject = GameObject.Instantiate(videoPlayerPrefab);
                BaseVideoPlayer videoPlayer = currentPlayerObject.GetComponentInChildren <BaseVideoPlayer>();
                currentPlayer = videoPlayer;
                break;

            case MediaHelpers.MediaType.Photo:
                currentPlayerObject = GameObject.Instantiate(photoPlayerPrefab);
                BasePhotoPlayer photoPlayer = currentPlayerObject.GetComponentInChildren <BasePhotoPlayer>();
                currentPlayer = photoPlayer;
                break;

            default:
                Debug.LogError("Invalid Media Type.");
                break;
            }
        }
예제 #10
0
 public void Setup(BaseMediaPlayer player)
 {
     videoPlayer = player as BaseVideoPlayer;
     gameObject.SetActive(videoPlayer != null);
 }
 void Awake()
 {
     videoPlayer = GetComponent <BaseVideoPlayer>();
 }