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
    }
コード例 #2
0
    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());
    }