We have added a tutorial in our game using looping video playback. The problem is that on the Android build on some devices the game sometimes crashes after a few seconds of playing the video. The video player output goes to the raw texture. This texture is used by the UI Image, and the GifPlayer script operates on these processes. All screenshots are below
public class GifPlayer : MonoBehaviour
{
public static GifPlayer Instance { get; private set; }
[SerializeField] private GameObject rawImage;
[SerializeField] private VideoPlayer videoPlayer;
private void Awake()
{
Instance = this;
rawImage.SetActive(false);
}
public void StartVideo(VideoClip clip)
{
StartCoroutine(PrepareVideo(clip));
}
private IEnumerator PrepareVideo(VideoClip clip)
{
videoPlayer.Stop();
videoPlayer.clip = clip;
videoPlayer.Prepare();
while (!videoPlayer.isPrepared)
{
yield return new WaitForSeconds(Time.fixedDeltaTime);
}
videoPlayer.Play();
rawImage.SetActive(true);
}
public void StopVideo()
{
rawImage.SetActive(false);
videoPlayer.Stop();
}
}