[EDITED] I'm preparing an application for OculusGo = Android In the scene there's 4 characters represented by video clips. Video size between 10mb - 30 mb each.
All video are with the shader GoogleVR/Unlit/TransparentOverlay The videos were encoded to WebM/ VP9/ keep alpha with Adobe encoder. The videos further transcoded in unity to Android, VP8 (again).
The videos loaded from a resources folder at the begining of the scene, and then when it's time to play them VideoPlayer.Play() is called from each one of them and finally they all play together. (Start one after another and continue together).
The issue is: My app is crashing when the third video is supposed to play. It doesn't crash when I "prepare" the video, but only on "VideoPlayer.Play()"
Here's my current code:
public float waiting;
public AudioSource characterAudio;
VideoPlayer videoPlayer;
bool videoStarted = true;
void Awake () {
videoPlayer = GetComponent<VideoPlayer>();
}
private void Update()
{
if (characterAudio != null)
{
if (characterAudio.isPlaying && videoStarted)
{
StartCoroutine(StartVideo());
videoStarted = false;
Debug.Log(characterAudio.name + " called once from update");
}
}
}
IEnumerator StartVideo()
{
yield return new WaitForSeconds(waiting);
videoPlayer.enabled = true;
videoPlayer.Prepare();
while(!videoPlayer.isPrepared)
{
Debug.Log("video is preparing");
yield return null;
}
videoPlayer.Play();
Debug.Log("videoStarted, char name is: " + characterAudio.name);
}
This is the errors I get from logcat (using command: logcat |grep -i unity)
ActivityManager: Force removing ActivityRecord
Consumer closed input channel or an error occurred. events=0x9
Channel is unrecoverably broken and will be disposed!
InputDispatcher: Attempted to unregister already unregistered input channel
Please help, I've been trying for two weeks to get these videos to run simultaneously.
Also I read about using different thread here: https://gamedev.stackexchange.com/questions/113096/how-to-not-freeze-the-main-thread-in-unity and about videos playing simultaneously here: Unity App freezes when loading Multiple Videos on same Scene
I ran logcat (not unity one), and this is what I got right after video preparation has ended:
The way I solved this issue is with the following steps:
So to summaries instead of loading and playing 4 videos with four different materials and creating overload on the system, I played 1 video on 1 material. Application run smoothly.