Hey everyone,
I actually solved this, but I wanted to get this out there for anyone who might be running into this issue. It seems pretty simple in retrospect, but then again, don’t most issues?
Anyways, I am using the new “Video Player” in unity beta, and it’s been working swell as I’m developing. I have a few smaller videos (10-20 MB) and one very large video, which I play at the beginning of the scene. Everything is working great in the editor, so I create a build, and the video does not play…Long story short (skipping the pulling of the hair and cussing at the monitor), the video actually was playing, but it took about 60 seconds before it started to show it was playing.
There is a section in “Player Settings” where you can actually PreLoad assets…You can get there by going to File->Build Settings->Player Settings, Go to the “Other Settings” tab and under “Optimization” there is an array field called “Preloaded Assets”. Make that array size as big as you need and import each asset you want to preload right there. This solved my problem for the video, though, this solution will probably work for any large asset that is giving you issues…
Anyways, hope this helps…And if I stated something overly obvious, I’m sorry about that…I’m just hoping to save someone the 5 hours it took me to figure out.
Hey everyone,
I realize the solution I listed above might not be the best, or ideal…I did find something else that worked for me, and if the above solution isn’t working for you, you can try this…
If you go to the properties of the imported video (in the unity editor), check the “Transcode” checkbox. Then you should be good to go. This also worked for me and, in fact, I was able to remove the video from the preloaded assets section and it still worked!!! I’d be curious if this works for anyone else, so please comment below if it worked for you, as I’m still testing this out on different platforms…
I do the transcoding, preloading, AND attach a script with:
//be sure to have the using statements at the top
using UnityEngine;
using UnityEngine.Video;
//create a public videoplayer, this way you can simply drag the video plane
//onto the object this script is attached to in Unity's Inspector
public VideoPlayer videoPlane;
//then in whatever method or even the Start()
// I am building a Vuforia project, so I use this in the OnTrackingLost()
videoPlane.Prepare();
This finally did the trick for me. I had to combine all 3 methods (Transcoding, Preloaded Asset, and Prepare())
I know this is old but thank you! The Transcode fix worked for me.
Hello there, maybe a bit late but i walked across this very same problem last day at work.
Apparently the loading stuff carried on by .Prepare()
is managed underneath asynchronously. So in order to make sure your video is prepared you can subscribe to VideoPlayer.prepareCompleted
and be notified when that takes place.
The reason of transcoding working is that maybe makes the process faster so you dont notice the loading process.