Ejemplo n.º 1
0
        /// <summary>
        /// 動作を再生/停止
        /// </summary>
        public void PlayButton()
        {
            if (isPlaying)
            {
                // 停止

                if (videoPlayer)
                {
                    videoPlayer.Stop();
                }
                //if (videoPlayer) videoPlayer.Pause();

                isPlaying   = false;
                currentKoma = 0;

                // 停止中はキーフレーム単位の姿勢合わせ状態にしておく
                ApplyPose(currentFrame);
            }
            else
            {
                // 再生開始

                if (videoPlayer)
                {
                    videoPlayer.Play();
                }

                currentKoma = firstKoma;
                startedTime = Time.time - ((float)firstKoma / fps);
                isPlaying   = true;
            }
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            videoPlayer = GetComponent <UnityEngine.Video.VideoPlayer>();

            // TODO: Move to extension method.
            videoPlayer.targetTexture.Release();
            videoPlayer.targetTexture.width  = Screen.width;
            videoPlayer.targetTexture.height = Screen.height;

            timeline.PointerDown += () => videoPlayer.Pause();
            timeline.PointerUp   += () => videoPlayer.Play();
            timeline.Slider.onValueChanged
            .AddListener(value => videoPlayer.time = value * Duration);

            volumeSlider.ValueSlider.onValueChanged
            .AddListener(value => videoPlayer.SetDirectAudioVolume(0, value));

            playPauseToggle.onValueChanged.AddListener(isOn =>
            {
                if (isOn)
                {
                    videoPlayer.Play();
                }
                else
                {
                    videoPlayer.Pause();
                }
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 動作を再生/停止
        /// </summary>
        public void PlayButton()
        {
            if (isPlaying)
            {
                // 停止

                if (videoPlayer)
                {
                    videoPlayer.Stop();
                }
                //if (videoPlayer) videoPlayer.Pause();

                isPlaying   = false;
                currentKoma = 0;
                ApplyPose(currentFrame);
            }
            else
            {
                // 再生開始

                if (videoPlayer)
                {
                    videoPlayer.Play();
                }

                currentKoma = 0;
                startedTime = Time.time;
                isPlaying   = true;
            }
        }
Ejemplo n.º 4
0
        //rutina para inicia video
        IEnumerator IniciarVideo(UnityEngine.Video.VideoPlayer video)
        {
            yield return(new WaitForSeconds(5));

            flag = true;
            video.Play();
            yield return(new WaitForEndOfFrame());
        }
        /// <summary>
        /// PlayVideo is for playing video specified by the filepath given in the scene.
        /// </summary>
        /// <returns></returns>
        private IEnumerator PlayVideo()
        {
            yield return(new WaitForSeconds(0.1f));

            videoPlayerComponent     = videoPlayerSpace.GetComponent <UnityEngine.Video.VideoPlayer>();
            videoPlayerComponent.url = System.IO.Path.Combine(Application.streamingAssetsPath, nameOfVideoFile);

            videoPlayerComponent.Play();
        }
Ejemplo n.º 6
0
 IEnumerator CRPlayThread(bool loop)
 {
     while (!mVideoPlayer.isPrepared)
     {
         yield return(null);
     }
     mVideoPlayer.isLooping = loop;
     mVideoPlayer.Play();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Play video process.
 /// </summary>
 public void PlayVideo()
 {
     if (index >= videoFiles.Count)
     {
         return;
     }
     this.GetComponent <UnityEngine.Video.VideoPlayer>().url = "file://" + videoFiles[index];
     Debug.Log("[VideoPlayer::PlayVideo] Video Path:" + videoFiles[index]);
     videoPlayerImpl.Play();
 }
Ejemplo n.º 8
0
        public void SetQuestion(Question question, int nomor)
        {
            this.question      = question;
            questionNomor.text = "" + nomor;

            switch (question.questionType)
            {
            case QuestionType.TEXT:

                questionImage.transform.parent.gameObject.SetActive(false);

                break;

            case QuestionType.IMAGE:
                ImageHolder();
                questionImage.transform.gameObject.SetActive(true);

                questionImage.sprite = question.questionImg;
                break;

            case QuestionType.VIDEO:
                ImageHolder();
                questionVideo.transform.gameObject.SetActive(true);

                questionVideo.clip = question.questionVideo;
                questionVideo.Play();
                break;

            case QuestionType.AUDIO:
                ImageHolder();
                questionAudio.transform.gameObject.SetActive(true);

                audioLength = question.questionClip.length;

                StartCoroutine(PlayAudio());

                break;
            }

            questionText.text = question.questionInfo;

            List <string> answerList = ShuffleList.ShuffleListItems <string>(question.options);


            for (int i = 0; i < options.Count; i++)
            {
                options[i].GetComponentInChildren <Text>().text = answerList[i];
                options[i].name = answerList[i];
                //options[i].image.color = normalCol;
            }

            answered = false;
        }
Ejemplo n.º 9
0
        //=========================================================================================================================
        //   E N U M E R A T O R S
        //=========================================================================================================================
        private IEnumerator Phases()
        {
            yield return(new WaitForEndOfFrame());

            yield return(new WaitUntil(() => lastBoss.isDeath));

            QuestLog.ChangeCurrentObjective(Objective.Completed);
            yield return(new WaitForSeconds(5.0f));

            InstantiatePrefab();
            Setting();
            Phase = CongratulationMessagePhase.AppearingLine;

            yield return(new WaitForSeconds(1.0f));

            Phase = CongratulationMessagePhase.AppearingMessage;

            yield return(new WaitUntil(() => Phase == CongratulationMessagePhase.DisappearingMessage));

            yield return(new WaitForSeconds(1.0f));

            Phase = CongratulationMessagePhase.DisapearringLine;

            yield return(new WaitUntil(() => Phase == CongratulationMessagePhase.ResizeMonitorVertically));

            videoPlayer.Play();
            yield return(new WaitUntil(() => videoPlayer.isPlaying));

            videoPlayer.Pause();
            yield return(new WaitUntil(() => Phase == CongratulationMessagePhase.PlayVideo));

            videoPlayer.Play();
            yield return(new WaitUntil(() => videoPlayer.isPlaying));

            yield return(new WaitUntil(() => !videoPlayer.isPlaying));

            Phase = CongratulationMessagePhase.End;
            Debug.Log("END!");
        }
Ejemplo n.º 10
0
        // Public functions
        #region
        public void ChangeBackground()
        {
            currentVideo += 1;

            // Cycle back to first video
            if (currentVideo >= videoClip.Length)
            {
                currentVideo = 0;
            }

            videoPlayer.clip = videoClip[currentVideo];     // Change background
            videoPlayer.Play();                             // Play Video
        }
Ejemplo n.º 11
0
        public void OpenVideo(string videoPath)
        {
            gameObject.SetActive(true);

            // Fix transparent image on opening.
            RenderTexture.active = videoPlayer.targetTexture;
            GL.Clear(true, true, backgroundColor);
            RenderTexture.active = null;

            videoPlayer.url = videoPath;
            lastVideoPath   = videoPath;

            animation.PlayInTweenFull()
            .OnComplete(() => { videoPlayer.Play(); });
        }
Ejemplo n.º 12
0
 public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
 {
     print("Test");
     if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED ||
         newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
     {
         print("TargetTracker : onTrackingFound");
         OnTrackingFound();
         videoPlayer.Play();
     }
     else
     {
         print("TargetTracker : onTrackingLost");
         OnTrackingLost();
         videoPlayer.Pause();
     }
 }
Ejemplo n.º 13
0
        // Start is called before the first frame update
        void Start()
        {
            if (useBackgroundVideo == true)
            {
                // Setup gameobject
                videoPlayer = gameObject.AddComponent <UnityEngine.Video.VideoPlayer>();

                // Video settings
                videoPlayer.waitForFirstFrame = true;
                videoPlayer.playOnAwake       = false;
                videoPlayer.clip                   = videoClip[currentVideo];
                videoPlayer.renderMode             = UnityEngine.Video.VideoRenderMode.MaterialOverride;
                videoPlayer.targetMaterialRenderer = GetComponent <Renderer>();
                videoPlayer.targetMaterialProperty = "_MainTex";
                videoPlayer.isLooping              = true;

                videoPlayer.Play();                             // Play first video
            }
        }
 private System.Collections.IEnumerator VideoPlayCoroutine(int num)
 {
     videoPlayer = GetComponent <UnityEngine.Video.VideoPlayer>();
     Debug.Assert(videoClips.Count > num);
     Debug.Assert(videoClips[num] != null);
     videoPlayer.clip = videoClips[num];
     videoPlayer.Prepare();
     while (!videoPlayer.isPrepared)
     {
         Debug.Log("Preparing Video");
         yield return(null);
     }
     Debug.Log("Done Preparing Video");
     videoPlayer.Play();
     while (videoPlayer.isPlaying)
     {
         yield return(null);
     }
     Debug.Log("Played Successfully!!");
 }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     player.Play();
     sound.Play();
 }
 public void RestartVideo()
 {
     videoPlayer.frame = 0;
     videoPlayer.Play();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 繪製轉場圖片
        /// </summary>
        /// <param name="_step">繪製完後要進入的腳本位置</param>
        /// <param name="sceneName">Scene名稱</param>
        private static void DrawSlidePic(int _step)
        {
            GameObject parent;

            switch (KK_FBIOpenUp.nowGameMode)
            {
            case KK_FBIOpenUp.GameMode.Studio:
                parent = GameObject.Find("StudioScene/Canvas Main Menu");
                break;

            case KK_FBIOpenUp.GameMode.MainGame:
                parent = GameObject.Find("ActionScene/UI/ActionMenuCanvas/ModeAnimation");
                break;

            case KK_FBIOpenUp.GameMode.Maker:
                parent = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsCoordinateType/redBagBtn");
                break;

            //FreeH死都不成功,放棄
            //case KK_FBIOpenUp.GameMode.FreeH:
            //    parent = GameObject.Find("CommonSpace");
            //    break;
            default:
                parent = GameObject.FindObjectsOfType <GameObject>()[0];    //Not tested
                break;
            }
            GameObject gameObject = new GameObject();

            gameObject.transform.SetParent(parent.transform, false);
            gameObject.SetActive(false);
            if (null != shiftPicture)
            {
                GameObject.Destroy(shiftPicture.Transform.parent.gameObject);
                shiftPicture.image = null;
                shiftPicture.video = null;
                shiftPicture       = null;
            }
            shiftPicture = new ShiftPicture();

            //如果影片不存在,用熊吉代替
            bool noVideoFallback = _step == 20 && null == KK_FBIOpenUp.videoPath;

            if (noVideoFallback)
            {
                _step = 2;
            }

            switch (_step)
            {
            case 1:
                //小學生真是太棒了
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.saikodaze.jpg", 800, 657));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 800 / 657, Screen.height / 1.5f);
                Right2Center();
                break;

            case 2:
                //熊吉逮捕
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.Kumakichi.jpg", 640, 480));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 640 / 480, Screen.height / 1.5f);
                Left2Center();
                break;

            case 10:
                //幼女退光線
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.beam.png", 700, 700));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.25f, Screen.height / 1.25f);
                Right2Center();
                break;

            case 20:
                //FBI Open Up影片
                shiftPicture.type = ShiftPicture.Type.video;

                shiftPicture.video = UIUtility.CreateRawImage("", gameObject.transform);
                shiftPicture.video.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f, Screen.height / 1.5f);

                UnityEngine.Video.VideoPlayer videoPlayer = gameObject.AddComponent <UnityEngine.Video.VideoPlayer>();
                AudioSource audioSource = gameObject.AddComponent <AudioSource>();
                videoPlayer.playOnAwake = false;
                audioSource.playOnAwake = false;
                videoPlayer.renderMode  = UnityEngine.Video.VideoRenderMode.APIOnly;

                //videoPlayer.url= "../UserData/audio/FBI.mp4";
                videoPlayer.url = KK_FBIOpenUp.videoPath;

                //Set Audio Output to AudioSource
                videoPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;

                //Assign the Audio from Video to AudioSource to be played
                videoPlayer.EnableAudioTrack(0, true);
                videoPlayer.SetTargetAudioSource(0, audioSource);

                Logger.LogDebug($"{videoPlayer.url}");
                videoPlayer.isLooping = true;

                //先把他移到螢幕外啟用,否則未啟用無法Prepare,而直接啟用會出現白色畫面
                shiftPicture.Transform.position = new Vector3(-2 * Screen.width, Screen.height / 2);
                gameObject.SetActive(true);

                videoPlayer.Prepare();
                videoPlayer.prepareCompleted += (source) => {
                    ///TODO 這實際上沒有辦法真的catch到錯誤,待修
                    if (videoPlayer.texture == null)
                    {
                        Logger.LogError("Video not found");
                        GameObject.Destroy(shiftPicture.Transform.parent.gameObject);
                        shiftPicture.video = null;
                        shiftPicture       = null;
                        _step = 0;
                        return;
                    }

                    shiftPicture.video.texture = videoPlayer.texture;
                    videoTimer = 2;
                    videoPlayer.Play();
                    audioSource.Play();

                    //影片太大聲QQ
                    audioSource.volume = KK_FBIOpenUp.videoVolume;

                    Left2Center();
                };
                break;
            }

            //如果影片不存在,用熊吉代替
            if (noVideoFallback)
            {
                _step = 20;
            }

            step = _step;
            Logger.LogDebug("Draw Slide Pic");

            void Right2Center()
            {
                //Right To Center
                shiftPicture.Transform.position = new Vector3(Screen.width + shiftPicture.Width / 2, Screen.height / 2);
                shiftPicture.targetPosition     = new Vector3(Screen.width / 2, Screen.height / 2);
                gameObject.SetActive(true);
            }

            void Left2Center()
            {
                //Left To Center
                shiftPicture.Transform.position = new Vector3(-1 * (Screen.width + shiftPicture.Width / 2), Screen.height / 2);
                shiftPicture.targetPosition     = new Vector3(Screen.width / 2, Screen.height / 2);
                gameObject.SetActive(true);
            }
        }
Ejemplo n.º 18
0
 private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e)
 {
     tooltipAnimator.Play("AppearAnimation");
     video.Play();
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Play/Resume the video.
        /// </summary>
        public void Play()
        {
            if (CurrentState != StateType.Prepared &&
                CurrentState != StateType.Paused &&
                CurrentState != StateType.Stopped)
            {
                return;
            }
#if USE_EASY_MOVIE_TEXTURE
            if (easyMovieTexture == null)
            {
                return;
            }
            easyMovieTexture.Play();
#elif USE_UNITY_VIDEO_PLAYER
            if (videoPlayer == null)
            {
                return;
            }
            videoPlayer.Play();
#elif USE_ANDROID_MEDIA_PLAYER
            if (mediaPlayer == null)
            {
                return;
            }
            try
            {
                mediaPlayer.Call("start");
            }
            catch (Exception e)
            {
                UpdateState(StateType.Error);
                Debug.LogError(TAG + " Failed to start mediaPlayer: " + e.Message);
            }
            if (!checkingComplete)
            {
                StartCoroutine(WaitVideoComplete());
            }
#elif USE_VIVE_MEDIA_DECODER
            if (mediaDecoder == null)
            {
                return;
            }
            if (CurrentState == StateType.Prepared)
            {
                mediaDecoder.startDecoding();
            }
            if (CurrentState == StateType.Paused || CurrentState == StateType.Stopped)
            {
                mediaDecoder.setResume();
            }
#else
            if (movieTexture == null || audioSource == null)
            {
                return;
            }
            movieTexture.Play();
            audioSource.Play();
            if (!checkingComplete)
            {
                StartCoroutine(WaitVideoComplete());
            }
#endif
            Debug.Log(TAG + " Start to play: " + videoFile);
            UpdateState(StateType.Started);
        }
Ejemplo n.º 20
0
        public void SetupVideoPlayer()
        {
            if (videoEnabled == ModelVideoEnabled.Never || videoPlayer == null)
            {
                if (videoPlayer != null)
                {
                    videoPlayer.enabled = false;
                }
                SetupImageMaterial();
                if (imageList == null)
                {
                    this.enabled = false;
                }
                return;
            }

            ArcadeAudioManager.activeVideos.Add(gameObject.GetComponent <ModelVideoSetup>());

            // Setup videoplayer properties
            ulong frameCount    = videoPlayer.frameCount;
            int   frameCountInt = (int)frameCount;
            long  randomFrame   = (long)Random.Range(0, frameCountInt);

            videoPlayer.frame                  = randomFrame;
            videoPlayer.isLooping              = true;
            videoPlayer.waitForFirstFrame      = true;
            videoPlayer.targetMaterialProperty = "_EmissionMap";
            videoPlayer.SetDirectAudioMute(0, true);

            if (renderer != null)
            {
                // TODO: This fixes black textures when some prefabs are loaded from an assetbundle
                var shaderName = renderer.material.shader.name;
                var newShader  = Shader.Find(shaderName);
                if (newShader != null)
                {
                    renderer.material.shader = newShader;
                }
                else
                {
                    Debug.LogWarning("unable to refresh shader: " + shaderName + " in material " + renderer.material.name);
                }

                // TODO: Setup material, resize to better fit the screen. Should we still do this? I think we did this because the mame32 screenshots had a white border.
                if (modelComponentType == ModelComponentType.Screen)
                {
                    //renderer.material.SetTextureOffset("_MainTex", new Vector2(-0.075f, -0.075f));
                    //renderer.material.SetTextureScale("_MainTex", new Vector2(1.15f, 1.15f));
                }
                if (modelComponentType != ModelComponentType.Generic)
                {
                    //renderer.material.SetTexture("_MainTex", null);
                    renderer.material.color = Color.black;
                    renderer.material.SetColor("_EmissionColor", Color.white);
                    renderer.material.EnableKeyword("_EMISSION");
                    renderer.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
                }
                if (modelComponentType == ModelComponentType.Screen)
                {
                    if (modelProperties.genre.ToLower().Contains("vector"))
                    {
                        renderer.material.SetVector("_EmissionColor", Color.white * modelSharedProperties.renderSettings.screenVectorIntenstity);
                    }
                    else if (modelProperties.screen.ToLower().Contains("pinball"))
                    {
                        renderer.material.SetVector("_EmissionColor", Color.white * modelSharedProperties.renderSettings.screenPinballIntensity);
                    }
                    else
                    {
                        renderer.material.SetVector("_EmissionColor", Color.white * modelSharedProperties.renderSettings.screenRasterIntensity);
                    }
                }
                if (modelComponentType == ModelComponentType.Marquee)
                {
                    renderer.material.SetVector("_EmissionColor", Color.white * modelSharedProperties.renderSettings.marqueeIntensity);
                }
            }

            if (videoEnabled == ModelVideoEnabled.Always)
            {
                videoPlayer.enabled = true;
                videoPlayer.Prepare();
                videoPlayer.Play();
            }
            else if (videoEnabled == ModelVideoEnabled.VisiblePlay || videoEnabled == ModelVideoEnabled.VisibleUnobstructed)
            {
                prepareDone         = false;
                videoPlayer.enabled = true;
                videoPlayer.Prepare();
                videoPlayer.frame = 10;
                videoPlayer.Play();
                StartCoroutine("PrepareVideo");
            }
            else if (videoEnabled == ModelVideoEnabled.VisibleEnable || videoEnabled == ModelVideoEnabled.Selected)
            {
                videoPlayer.enabled = false;
                SetupImageMaterial();
            }
        }
 public override void Play()
 {
     _mediaPlayer.Play();
     Events.OnClipPlaybackStarted();
 }