Skip to content Skip to sidebar Skip to footer

Unity App Freezes When Loading Multiple Videos On Same Scene

When navigating from menu to a Scene that contains 8, 1-minutes MP4 videos, that are played using new VideoPlayer script on RawImage component. I am using Unity 5.6.0b11 beta versi

Solution 1:

For my case of problem. I had to make some changes on the VideoPlayer API Script I was using from this StackOverflow Question

In the script I was using from that link. The Co-routine was started inside the Start() function, that made the videos in 8 different prefab, to load at once even they were in pause mode.

So I added a new function PlayVideoOnClick() and attached it to the Click Event of the RawImage, so now the video will be loaded only if the RawImage is clicked.

Changed from

publicvoidStart()
{
    Application.runInBackground = true;
    StartCoroutine(playVideo());

}

To

publicvoidPlayVideoOnclick()
{
    Application.runInBackground = true;
    StartCoroutine(playVideo());

}

P.S: You can also see my YouTube Video Tutorial and Blog on Playing Videos smoothly in Unity.

Post a Comment for "Unity App Freezes When Loading Multiple Videos On Same Scene"