WebGL video "isPrepared" is never true? Preload Assets viable alternative?

Hello everybody,

as this problem gives me some headaches as it seemingly is not consistent I hope anyone of you has an idea.

Target:

  • Play a video as soon as it “isPrepared”
  • Jump to a frame in the middle of said video and play from there

Current state:

  • At another point in the WebGL I do load, play, pause and play again other videos, which works fine
  • I use the very same method to load the intro movie as well as any other movie from an url

Problem:

  • The first video loaded does not start to play
  • When I jump to a specific frame of that video it does also not play correctly from there (I suppose this is due to it not being prepared correctly)

Tested:

  • The requested URL is correct and can be viewed in the browser
  • (Seemingly) no CORS error as other videos from the same folder can be loaded no problem

Used code (reduced):

   public void video_bg_play_url(string video_bg_url) {
        video_bg_player.url = video_bg_url;
        video_bg_player.Prepare();
        StartCoroutine(video_bg_play());
    }

    private IEnumerator video_bg_play() {
        yield return new WaitUntil(() => video_bg_player.isPrepared == true);
        video_bg_player.Play();
    }

Questions:

  • Do you have any ideas where I might look for errors?
  • Would it be a viable sollution to load at least the intro videos as “Preloaded assets”? All of them are about 170mb which is quite a lot, ideally Unity would only preload one of those videos (20mb) which would speak for a custom preloader instead of using the “Preload Assets” of the player settings, right?

Some further thread reading showed that streaming assets does not work for WebGL although some posts imply it does :-/
( Unity - Manual: Streaming Assets )
“It is not possible to access the StreamingAssets folder on WebGL and Android platforms. No file access is available on WebGL.”

Is there another way to “pre-load” a video file or wait with playing it until it is cached completely?

I have “solved” this at least for my usecase. I heard from a colleague that they had a similar issue in their WebGL project, where the first video they loaded did not start by itself unless the user has pressed a button on the canvas.

This also aligns with the phenomenon I discovered that all other videos later in the tour just ran fine, because in order to get to the other videos the user has to press at least one of the buttons.

As I think it is anyways better to call for an action from the user after all data has been loaded, so that the user can decide when to start the tour I did exactly that and put a “Start tour” button with the logo before everything else :stuck_out_tongue: