Video sometimes works and other times does not work on Android.

I have Unity 2019.3.14f1. My android is 7.
The video, which is type mp4, plays fine on pc but on my phone sometimes plays and others doesn’t.
I have a script attached to a Raw Image. This script is to enable the video to play on the Raw Image.

Here is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;    
using UnityEngine.Video;     

public class NoLoopAnim : MonoBehaviour {

	//Public Variables
	public RawImage mainMenuImg;
	public VideoClip mainMenuToPlay;         

	//Private Variables
	private VideoPlayer mainMenuVideo;   
	private VideoSource mainMenuSource;       

	// Use this for initialization
	void Start ()
    {
		Application.runInBackground = false;
		StartCoroutine (playVideo ());              	
    }

	IEnumerator playVideo()  
    {
		//Adds the main menu video to the game object
		mainMenuVideo = gameObject.AddComponent<VideoPlayer> ();

		//Enable play on awake for video
		mainMenuVideo.playOnAwake = true;

		//Playing from video clip
		mainMenuVideo.source = VideoSource.VideoClip;

		//Set video to play then prepare audio to prevend buffering
		mainMenuVideo.clip = mainMenuToPlay;
		mainMenuVideo.Prepare ();

		//Wait until video is prepared
		WaitForSeconds waitTime = new WaitForSeconds(1);

		while (!mainMenuVideo.isPrepared)
		{
			yield return waitTime;             
			break;
		}

		//Assign the Texture from Video to RawImage to be displayed
		mainMenuImg.texture = mainMenuVideo.texture;

		//Play video
		mainMenuVideo.isLooping = false;
		mainMenuVideo.Play();

		while (mainMenuVideo.isPlaying)
		{
			yield return null;     
		}

		
	}

}

Never mind. I found the answer on a youtube video.

link text