微信版本8.0.71
以下是初始化videoPlayer代码
// 配置 VideoPlayer
videoPlayer.skipOnDrop = false; // 不丢弃帧,保证流畅
videoPlayer.aspectRatio = VideoAspectRatio.FitInside; // 保持比例
// 使用 AudioSource 模式输出音频
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
// 创建或获取 AudioSource
if (videoAudioSource == null)
{
videoAudioSource = gameObject.GetComponent<AudioSource>();
if (videoAudioSource == null)
{
videoAudioSource = gameObject.AddComponent<AudioSource>();
}
}
videoAudioSource.playOnAwake = false;
videoAudioSource.mute = isMute;
// 绑定 AudioSource 到 VideoPlayer 音轨 0
videoPlayer.SetTargetAudioSource(0, videoAudioSource);
videoPlayer.playOnAwake = false;
videoPlayer.waitForFirstFrame = true;
videoPlayer.loopPointReached += OnVideoFinished;
videoPlayer.errorReceived += OnVideoError;
videoPlayer.prepareCompleted += OnVideoPrepared;
