Question by 
               SirLaur · Dec 20, 2017 at 10:30 PM · 
                assetbundlewwwvideocache  
              
 
              Video plays from Assetbundle in Cache Folder only on second play
Hello everyone, I have a problem. I packed an mp4 video into an Assetbundle, uploaded it to my site, and then i download it with LoadCacheOrDownload. It downloads it to the cache folder, but the problem is, that it's giving me a null reference exception on the LoadAssetAsync(only on the first play of the game). If I hit play again, the video works fine. Here is my code :
 public IEnumerator DownloadObject()
 {
     WWW www;
     if (Application.platform == RuntimePlatform.WindowsEditor)
     {
         www = WWW.LoadFromCacheOrDownload("myurl", 1);
     }
     yield return www;
     AssetBundle bundle = www.assetBundle;
     AssetBundleRequest request = bundle.LoadAssetAsync<VideoClip>("MyVideo.mp4"); // here it gives me the null reference exception
     yield return request;
     VideoClip VideoClip360 = request.asset as VideoClip; 
     VideoClip360 = Instantiate(VideoClip360) as VideoClip;
     myVideoPlayer = GameObject.Find("Player").GetComponent<VideoPlayer>();
     myVideoPlayer.clip = VideoClip360;
     myVideoPlayer.Prepare();
     while (!myVideoPlayer.isPrepared)
     {
         yield return new WaitForSeconds(0.5f);
     }
     if (myVideoPlayer.isPrepared)
     {
         myVideoPlayer.Play();
     }
 }
 
               }
Any idea how to solve it ? Thanks
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Loading array of objects by using parent folder name in asset bundle? 0 Answers
Finding audio clips in a specific folder if it is exist (Android) 0 Answers
Scene Asset bundle 0 Answers
www class download local file (Windows Universal Platform - Hololens) 1 Answer
How to play XOR video files in Unity Video Player? 0 Answers