Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (isLoadingMainMenu)
        {
            foreach (GameObject o in GameObject.FindObjectsOfType <GameObject>())
            {
                //    Destroy(o);
            }
            SceneManager.LoadScene("MainMenuGameScreen");

            return;
        }
        else
        {
            videoTime += Time.deltaTime;
            if (videoTime > 28)
            {
                mText.enabled   = true;
                vRender.enabled = false;
                video.Stop();
                vaudio.Stop();
                isLoadingMainMenu = true;
            }
            else
            {
                timerStartVideo += Time.deltaTime;
                if (timerStartVideo > 0.5f && !video.isPlaying)
                {
                    video.Play();
                    //vaudio.Play();
                }
            }
        }
    }
    public void VideoPlayPause()
    {
#if UNITY_PS4
        // Pause if playing, Resume if paused, Play if stopped
        if (video.playerState == PS4VideoPlayer.VidState.PLAY)
        {
            video.Pause();
            playPauseIcon.sprite = playIcon;

            AddToOutputText("Video was playing, now paused");
        }
        else if (video.playerState == PS4VideoPlayer.VidState.PAUSE)
        {
            video.Resume();
            playPauseIcon.sprite = pauseIcon;

            AddToOutputText("Video was paused, now resumed");
        }
        else
        {
            video.Play(moviePath, isLooping);
            playPauseIcon.sprite = pauseIcon;

            AddToOutputText("Video was stopped, now playing");
        }

        // Calling Play ignores the current mute settings. This reapplies them
        video.SetVolume(isMuted ? 0 : 100);
#endif
    }
Esempio n. 3
0
    public void StartVideo()
    {
        if (isStart)
        {
            return;
        }


#if UNITY_PS4 && !UNITY_EDITOR
        planePS4.gameObject.SetActive(true);

        videoPlayerPs4 = new PS4VideoPlayer();

        videoPlayerPs4.PerformanceLevel      = PS4VideoPlayer.Performance.Optimal;
        videoPlayerPs4.clearFrameOnTerminate = false;
        videoPlayerPs4.demuxVideoBufferSize  = 8 * 1024 * 1024;      // defaults to 256k, or 1mb for Optimal
        videoPlayerPs4.videoDecoderType      = PS4VideoPlayer.VideoDecoderType.SOFTWARE2;
        videoPlayerPs4.videoMemoryType       = PS4VideoPlayer.MemoryType.WC_GARLIC;

        //      video.AudioThreadPriority = 500;

        lumaTex = new UnityEngine.PS4.PS4ImageStream();
        lumaTex.Create(1920, 1080, PS4ImageStream.Type.R8, 0);
        chromaTex = new UnityEngine.PS4.PS4ImageStream();
        chromaTex.Create(1920 / 2, 1080 / 2, PS4ImageStream.Type.R8G8, 0);
        videoPlayerPs4.Init(lumaTex, chromaTex);

        planePS4.material.mainTexture = lumaTex.GetTexture();
        planePS4.material.SetTexture("_CromaTex", chromaTex.GetTexture());

        videoPlayerPs4.Play(MoviePath + pathHD + videoName, looping);
#else
        video.url = MoviePath + pathHD + videoName;

        video.isLooping              = false;
        video.renderMode             = UnityEngine.Video.VideoRenderMode.MaterialOverride;
        video.targetMaterialRenderer = GetComponent <Renderer>();
        video.targetMaterialProperty = "_MainTex";

        video.Play();
#endif

        if (isDebug)
        {
            StartCoroutine("FinishVideo", timeDebug);
        }
        isStart = true;
    }
    public void VideoPlayPause()
    {
        // Pause if playing, Resume if paused, Play if stopped
        if (video.playerState == PS4VideoPlayer.VidState.PLAY)
        {
            video.Pause();
        }
        else if (video.playerState == PS4VideoPlayer.VidState.PAUSE)
        {
            video.Resume();
            //playPauseIcon.sprite = pauseIcon;
        }
        else
        {
            try
            {
                video.Play(moviePath, isLooping);

                StopAllCoroutines();
                StartCoroutine(CheckDimensions(moviePath));

                // cargar subtitulos si existen y si se llaman igual al video
                string caminoSub = moviePath.Replace(Path.GetExtension(moviePath), "");
                if (File.Exists(caminoSub + ".srt"))
                {
                    SubtitlesParser.Classes.Parsers.SrtParser parser = new SubtitlesParser.Classes.Parsers.SrtParser();

                    Subtitulos.text = "";
                    linea           = 0;
                    itemsubs        = parser.ParseStream(caminoSub + ".srt");
                }
                else if (File.Exists(caminoSub + ".ssa"))
                {
                    SubtitlesParser.Classes.Parsers.SsaParser parser = new SubtitlesParser.Classes.Parsers.SsaParser();

                    Subtitulos.text = "";
                    linea           = 0;
                    itemsubs        = parser.ParseStream(caminoSub + ".ssa");
                }
                else if (File.Exists(caminoSub + ".ass"))
                {
                    SubtitlesParser.Classes.Parsers.SsaParser parser = new SubtitlesParser.Classes.Parsers.SsaParser();

                    Subtitulos.text = "";
                    linea           = 0;
                    itemsubs        = parser.ParseStream(caminoSub + ".ass");
                }
                else
                {
                    linea    = 0;
                    itemsubs = null;
                }
            }
            catch (Exception ex)
            {
                linea           = 0;
                itemsubs        = null;
                Subtitulos.text = "Error: " + ex.Message;
            }
        }

        // Calling Play ignores the current mute settings. This reapplies them
        video.SetVolume(Volumen);
    }
    /* public void VideoPlayPause()
     * {
     #if UNITY_PS4
     *   // Pause if playing, Resume if paused, Play if stopped
     *   if (video.playerState == PS4VideoPlayer.VidState.PLAY)
     *   {
     *       video.Pause();
     *       playPauseIcon.sprite = playIcon;
     *
     *       AddToOutputText("Video was playing, now paused");
     *   }
     *   else if(video.playerState == PS4VideoPlayer.VidState.PAUSE)
     *   {
     *       video.Resume();
     *       playPauseIcon.sprite = pauseIcon;
     *
     *       AddToOutputText("Video was paused, now resumed");
     *   }
     *   else
     *   {
     *       video.Play(moviePath, isLooping);
     *       playPauseIcon.sprite = pauseIcon;
     *
     *       AddToOutputText("Video was stopped, now playing");
     *   }
     *
     *   // Calling Play ignores the current mute settings. This reapplies them
     *   video.SetVolume(isMuted ? 0 : 100);
     #endif
     * }*/



    public void voidplayz()
    {
        video.Play(moviePath, isLooping);
    }