Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Stream while simultaneously downloading video from URL using video player

Discussion in 'Audio & Video' started by tomc128, May 22, 2020.

  1. tomc128

    tomc128

    Joined:
    Oct 21, 2017
    Posts:
    4
    Hi, I'm wanting to use a video clip as the background in my menu scene for one of my games.

    Setting the video player's URL to the URL I want to play works, however, each time the game is launched, it re-downloads the video. This causes unnecessary data usage, especially on mobile.

    Instead, I tried downloading the video using a UnityWebRequest and saving it to a file. This works, and the video only has to be downloaded once, however, the video then needs to be fully downloaded before playback can commence, meaning there is a delay before the video starts playing.

    So, my question is: is there any way to stream a video from a URL directly using the video player, but also cache the download in the persistent data path, so the video is only downloaded once?

    The only other way I can think of achieving this is by playing the video via the URL of the video player, while also downloading the file using a web request. This is better than downloading it every time the game is launched, however, it still downloads the video twice which is not ideal.

    Thanks.
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    229
    Hi!

    The VideoPlayer doesn't offer a way to cache while playing back.

    This feature request has been on our radar for a while, but we haven't gotten to it yet. So the compromise you are describing - fully download and play from url at the same time - is the best option currently available.

    Have a nice day,

    Dominique
    A/V developer at Unity
     
    tomc128 likes this.
  3. tomc128

    tomc128

    Joined:
    Oct 21, 2017
    Posts:
    4
    Thanks for the reply! I'll use the method I described above for now then.
     
unityunity