我使用视频播放器,它附加了3D游戏对象。这个游戏对象也包含“网格渲染器”组件。视频播放器渲染者->这个游戏对象。我尝试过很多方法,但总是玩撞车游戏。
,
现在代码:
void Start()
{
index = 0;
videoPlayer = gameObject.GetComponent<VideoPlayer>();
videoPlayer.loopPointReached += CheckOver;
}
IEnumerator Waitforseconds()
{
Debug.Log("Waitforseconds start");
videoPlayer.clip = null;
Debug.Log("Videoplayer clip null);
yield return new WaitForSeconds(5);
videoPlayer.clip = theVideo;
Debug.Log("Videoplayer set the video");
yield return new WaitForSeconds(5);
Debug.Log("Next play video player");
videoPlayer.Play();
Debug.Log("Play video player");
isPlaying = true;
}
void CheckOver(UnityEngine.Video.VideoPlayer vp)
{
Debug.Log("Checkover");
index += 1;
if (index >= videos.Length)
{
index = 0;
}
theVideo = videos[index];
Debug.Log("Set the video");
StartCoroutine(Waitforseconds());
}视频大小5-10 MB和10-60秒。其结果是:统一编辑器工作良好,我构建成iOS,如果我播放下一个视频,有时会导致游戏崩溃(iPhone 12 Pro Max,据说是最快的智能手机芯片,所以如果不起作用,就会有一个大问题。)
Debug:我在游戏崩溃之前得到了最后一个Debug.log:“视频播放剪辑为空”,所以我认为游戏崩溃的原因是: videoPlayer.clip = theVideo;但是只有iOS!统一编辑器工作良好.
Xcode错误:

我试着在谷歌找到解决方案,但我找不到..。也许是记忆错误?我应该从记忆中删除以前的视频吗?或者我该如何解决这个问题?请帮帮我。
非常感谢!
编辑:我看到问题是音频。(音频输出模式:音频源,此组件附加到相同的游戏对象。同样的游戏对象包含音频源和视频播放器。)如果我把音频输出模式设置为“无”,那么游戏不会崩溃,工作良好。所以问题是当"PrepareAudioTap“。我如何解决这个问题?
发布于 2020-12-05 11:33:25
解决了!
I更改视频播放器组件“音频输出模式”:音频源到Direct.然后不崩溃游戏。
但我想使用音频源,因为我需要3D声音。(不重要,我很高兴它能工作,但如果你知道如何处理3D声音,我会很高兴的。)
谢谢!
https://stackoverflow.com/questions/65155849
复制相似问题