I am trying to play a video from the streaming assets folder on android. I can get it to play but it is very choppy
I am trying to get the video and audio separate so I can swap them out(for multilanguage support) It works well but the video is choppy and the audio becomes desynced from the video.
Is there a method for preloading the video besided checking if it’s prepared?
I have tried to wait for upwards of 30sec after it’s prepared to let it “Load” but still pretty choppy
public void StartVid()
{
string url = "file://" + Application.streamingAssetsPath + "/" + "video.mp4";
#if !UNITY_EDITOR && UNITY_ANDROID
url = Application.streamingAssetsPath + "/" + "video.mp4";
#endif
//We want to play from url
videoPlayer.source = VideoSource.Url;
videoPlayer.url = url;
StartCoroutine(prepareVid(Path.Combine(Application.streamingAssetsPath, "audio.wav")));
}
private IEnumerator prepareVid(string file)
{
videoPlayer.Prepare();
while (!videoPlayer.isPrepared)
{
Debug.Log("Preparing");
yield return null;
}
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(file, AudioType.WAV);
yield return request.SendWebRequest();
audioSource.clip = DownloadHandlerAudioClip.GetContent(request);
Debug.Log("Prepared");
//yield return new WaitForSeconds(30);
videoPlayer.Play();
videoPlayer.started += (trash) => { audioSource.Play(); };
request.Dispose();
}
Thank you