Search Unity

Question 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.
     
    AllanSmithZ3 likes this.
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    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
     
    AllanSmithZ3 and tomc128 like 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.
     
  4. AllanSmithZ3

    AllanSmithZ3

    Joined:
    May 21, 2019
    Posts:
    23
    Hey, any updates on this? Seems like a fairly important feature of the video player. I was actually going to implement addressables mainly to deal with this but then I realized I probably would need to fully download the video first which is not ideal...
     
  5. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Any update or prospect of any update on this? I would also very much like to not have to double download every video in order to (1) get immediate playback from URL streaming and (2) be able to cache it to persistentDataPath after so I can read it from there on subsequent plays...
     
  6. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    We now have a roadmap for all features request. You can see @mikejm_ what we are doing and planning to do, and you can propose your own. We are pretty dependent on the platform SDK, which usually doesn't provide this option. So we would need a big refactor, which we are planning to do but has not yet been done. https://unity.com/roadmap/unity-platform/audio-video
     
  7. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks. No worries. I can work around it. I will simply stick to streaming instead. This one is not a big deal for me I don't think.