コード例 #1
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            //Debug.Log($"[{nameof(ProcessFrame)}] videoPlayer null? {videoClip == null}");
            if (playerData is VideoPlayer videoPlayerBinding)
            {
                videoPlayer = videoPlayerBinding;
            }
            if (videoPlayer == null || videoPlayer.clip == null)
            {
                return;
            }
            videoPlayer.playbackSpeed     = (float)playable.GetSpeed();
            videoPlayer.targetCameraAlpha = info.weight;

            if (Application.isPlaying)
            {
                for (ushort i = 0; i < videoPlayer.clip.audioTrackCount; ++i)
                {
                    if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct)
                    {
                        videoPlayer.SetDirectAudioVolume(i, info.weight);
                    }
                    else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource)
                    {
                        AudioSource audioSource = videoPlayer.GetTargetAudioSource(i);
                        if (audioSource != null)
                        {
                            audioSource.volume = info.weight;
                        }
                    }
                }
            }
        }