private Item CreatePlayerInstance() { var item = new Item(); var player = new PS4VideoPlayer(); player.PerformanceLevel = PS4VideoPlayer.Performance.Default; //player.demuxVideoBufferSize = 2 * 1024 * 1024; // change the demux buffer from it's 1mb default player.demuxVideoBufferSize = 1024; player.numOutputVideoFrameBuffers = 20; // increasing this can stop frame stuttering player.videoMemoryType = PS4VideoPlayer.MemoryType.WB_ONION; var lumaTex = new UnityEngine.PS4.PS4ImageStream(); lumaTex.Create(1920, 1080, PS4ImageStream.Type.R8, 0); var chromaTex = new UnityEngine.PS4.PS4ImageStream(); chromaTex.Create(1920 / 2, 1080 / 2, PS4ImageStream.Type.R8G8, 0); player.Init(lumaTex, chromaTex); item.player = player; item.material = new Material(Shader.Find("FMVTexture")); item.material.mainTexture = lumaTex.GetTexture(); item.material.SetTexture("_CromaTex", chromaTex.GetTexture()); return(item); }
void Start() { #if UNITY_PS4 // Please set a movie to play! if (string.IsNullOrEmpty(moviePath)) { Debug.LogError("Movie Path is null or empty! Please set this from within the Editor!"); enabled = false; return; } // You cannot use back-slashes on PS4, although they work on PC-Hosted they will fail on an installed package if (moviePath.Contains("\\")) { Debug.LogError("Movie Path uses back-slashes! Replacing with forward-slashes instead."); moviePath = moviePath.Replace("\\", "/"); } moviePath = Path.Combine(Application.streamingAssetsPath, moviePath); if (!File.Exists(moviePath)) { Debug.LogError("Movie could not be found! Unable to play."); enabled = false; return; } AddToOutputText(string.Format("Movie path for playback is: {0}", moviePath)); #if UNITY_5_4_OR_NEWER // In 5.3 this event is triggered automatically, as an optimization in 5.4 onwards you need to register the callback PS4VideoPlayer.OnMovieEvent += OnMovieEvent; #endif video = new PS4VideoPlayer(); // This sets up a VideoDecoderType.DEFAULT system video.PerformanceLevel = PS4VideoPlayer.Performance.Optimal; video.demuxVideoBufferSize = 2 * 1024 * 1024; // Change the demux buffer from it's 1mb default video.numOutputVideoFrameBuffers = 2; // Increasing this can stop frame stuttering lumaTex = new PS4ImageStream(); lumaTex.Create(1920, 1080, PS4ImageStream.Type.R8, 0); chromaTex = new PS4ImageStream(); chromaTex.Create(1920 / 2, 1080 / 2, PS4ImageStream.Type.R8G8, 0); video.Init(lumaTex, chromaTex); // Apply video textures to the UI image videoImage.material.SetTexture("_MainTex", lumaTex.GetTexture()); videoImage.material.SetTexture("_CromaTex", chromaTex.GetTexture()); #endif }
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; }
void Start() { // In 5.3 this event is triggered automatically, as an optimization in 5.4 onwards you need to register the callback PS4VideoPlayer.OnMovieEvent += OnMovieEvent; video = new PS4VideoPlayer(); // This sets up a VideoDecoderType.DEFAULT system video.PerformanceLevel = PS4VideoPlayer.Performance.Optimal; video.demuxVideoBufferSize = 8 * 1024 * 1024; // Change the demux buffer from it's 1mb default video.numOutputVideoFrameBuffers = 8; // Increasing this can stop frame stuttering lumaTex = new PS4ImageStream(); lumaTex.Create(1920, 1080, PS4ImageStream.Type.R8, 0); chromaTex = new PS4ImageStream(); chromaTex.Create(1920 / 2, 1080 / 2, PS4ImageStream.Type.R8G8, 0); video.Init(lumaTex, chromaTex); // Apply video textures to the UI image videoImage.material.SetTexture("_MainTex", lumaTex.GetTexture()); videoImage.material.SetTexture("_CromaTex", chromaTex.GetTexture()); }
//qua ci pensa il modulo PS4 void Start() { //disabilitiamo il modulo non PS4 video = new PS4VideoPlayer(); // this sets up a VideoDecoderType.DEFAULT system bool useNewDecoder = true; if (useNewDecoder == false) { // this setting allows you to player more than one video at the same time video.PerformanceLevel = PS4VideoPlayer.Performance.Default; video.demuxVideoBufferSize = 2 * 1024 * 1024; // change the demux buffer from it's 1mb default video.numOutputVideoFrameBuffers = 3; // increasing this can stop frame stuttering } else { video.PerformanceLevel = PS4VideoPlayer.Performance.Optimal; video.demuxVideoBufferSize = 2 * 1024 * 1024; // change the demux buffer from it's 1mb default video.numOutputVideoFrameBuffers = 2; // increasing this can stop frame stuttering } 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); video.Init(lumaTex, chromaTex); plane = GameObject.Find("PS4Video"); plane.GetComponent <Renderer>().material.mainTexture = lumaTex.GetTexture(); plane.GetComponent <Renderer>().material.SetTexture("_CromaTex", chromaTex.GetTexture()); initialized = false; string assetLocation = System.IO.Path.Combine(Application.streamingAssetsPath, "VelocityImprovedLogo.mp4"); Play(assetLocation); }