Is it possible to download video into the StreamingAssets folder ?

Hi guys,

I have an app which contains heavy videos and reach out the Google Play app limit size. So far my videos are in the StreamingAssets folder - I’m looking for a solution to remove those video to my build and then download them during the first runtime of the application. It seems that AssetBundle are not a solution - what would you do in my situation ?

Thanks

There’s WWW.LoadFromCacheOrDownload for doing that with one command. Be wary of cache limits though. Asset bundles are a solution because you can use them with that command. Directly downloading clips that can be streamed with WWW (I know audio can, don’t remember about video) should work too.

Hi,

I’m not quite sure to understand your solution - Asset bundles seem to be used to download and access assets but in my case I want to be able to download and play videos - to do so video files has to be in the StreamingAssets folder - how would you download an AssetBundle containing video and then “move/extract” those videos to the StreamingAssets folder ?

Thank you

Ok - I never used this function - it returns a WWW and then, what should I do ? From a WWW there is a movie property but it’s a MovieTexture which is not usable in Android nor iOS. How to access to the movie file from a WWW instance and then “move/write” this movie file to the StreamingAssets folder ?

Thank you

Well, yeah, my miss. It can’t be packed and that method only works with asset bundles (as stated in it).
You should try to download movie manually(through Sockets or from unity server using UNET or any other way to download file), save it into file(as what you’ve downloaded is byte array) and then open using WWW to load file in path file://path.

WWW is container for whatever you download. First you check if WWW.error is null; if it isn’t - error occured. Then you wait until WWW.isDone (usually done in coroutine) or WWW.error occured; then you access MovieTexture from WWW.movie. If that’s something else you’ve downloaded(like asset bundle) there are properties for them in WWW like .audioClip .assetBundle etc.

If you manage to force WWW to download whole video you can write WWW.bytes into file and later just load it, but because MovieTexture is streamed it might not be possible.
This topic on stackoverflow states it actually can be downloaded using WWW even though it’s streamed. But I’ve not tested that.

Ok - this doesn’t sound like a viable solution, maybe I’m wrong, but having videos in the StreamingAssets is required to be able to read them on Android and iOS using Unity - Scripting API: Handheld.PlayFullScreenMovie

I don’t see how to write/move downloaded videos in that folder.

Thanks

Using that method - yes, it might not possible. (You can still try)
But you can render a fullscreen quad with MovieTexture and Play() it manually instead.

Actually MovieTextures are not supporter on iOS and Android - that’s why I’m trying to figure out a solution to download videos inside the StreamingAssets folder. But maybe it’s simply not possible.

Thanks a lot for your time.

http://answers.unity3d.com/questions/218362/bundle-up-a-movie-file-for-handheld.html
Just googled further and it is possible.

Ho ho, I made google searches but obviously not with the right key words. Thanks for the link !

1 Like

could you please help me how to download images to the streamingaseets folder

the images should be in streaming assets at run time

You cannot reliably download files to Streaming Assets at run time. That directory is read-only on many platforms and can be such on even more depending on configuration. I.e. on Windows if you install app system wide and use that app by non-admin user, the install directory (where streaming assets is located) is read-only.
You should be downloading things to Application.persistentDataPath or Application.temporaryCachePath, those directories are writable.

1 Like