Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: PET on January 20, 2017, 06:46:04 AM

Title: Android - Download file to a location[SOLVED]
Post by: PET on January 20, 2017, 06:46:04 AM
Hello guys!

I have to ... download a mp4 file on Android. My guess is that... file has to be in a particular location, then after the file is downloaded I need to ... play that mp4 file and do some other stuff.

Is there a way to download the mp4 file using Playmaker then know when the file has finished downloading?

Thank you!
Title: Re: Android - Download file to a location
Post by: PET on February 08, 2017, 07:37:40 AM
anyone :(  :o
Title: Re: Android - Download file to a location
Post by: elusiven on February 08, 2017, 09:24:12 AM
Get the WWWPOST mobile action from ecosystem if you don't have it. It gets data from a url and stores it in variables, although I'm not sure if it supports movie textures.


https://docs.unity3d.com/ScriptReference/WWW.html

This is how you would download a movie.
https://docs.unity3d.com/ScriptReference/WWW-movie.html
Title: Re: Android - Download file to a location
Post by: PET on February 09, 2017, 09:37:28 AM
Thanks.

Normally I need something like ... "Having an URL with an mp4 file". I click a buton something something ... that movie starts to be downloaded to a particular PATH (not sure exactly how Android handles the paths).

When the movie finished downloading I go to another scene where I play that video in a 360 sphere (using another Unity plugin).

But thanks for the tips!
Title: Re: Android - Download file to a location
Post by: elusiven on February 09, 2017, 10:00:17 AM
Hmm well you could save it to application's local data path with WWW.

https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

And then on second scene you just load it from the same path with www again but then put it to a movie texture, and that the can be loaded into a renderer.

I don't think the current WWW action supports movie textures, I will have a look later, it should be relatively easy to write one up.

Also mp4 format isn't supported so it won't play. You need to convert it to .ovg   - Google it up, there should be converters online or something.
Title: Re: Android - Download file to a location
Post by: PET on February 14, 2017, 07:08:30 AM
You sure mp4 isn't supported? I used mp4 before but as I said... I'm using AVPro Video (that 485 euro plugin).
Title: Re: Android - Download file to a location
Post by: PET on March 09, 2017, 01:05:10 PM
So... with that WWW action from the EcoSystem... I can point to a file... I can download that file... then I can pass a viariable to something else?

Can I specify where to download the file?
Can I take the path where the file has been downloaded?

What's the difference betweetn WWW & WWWMobile from the EcoSystem?

Thanks <3
Title: Re: Android - Download file to a location
Post by: jeanfabre on March 10, 2017, 04:57:43 AM
Hi,

 the WWW action do not work on mobile platform, so you need to use the WWMobile version which will compile ok for these targets.

you'll have to check with Unity WWW api wether it's suitable for mobile hardware location, I think it does, but it's been a long time, so I am not sure.

 Bye,

 Jean
Title: Re: Android - Download file to a location
Post by: PET on March 13, 2017, 09:08:34 AM
Hello Jean!

(http://i.imgur.com/hVZi0m8.png)

Well those are the options for the action.

Is there any way to check the download location of the file? Basically what I'm trying to do is...

0.Check if the file has already been downloaded ... if NOT:
1.Download the file to a location
2.Get the full path location
3.Store that location in a variable so I can pass it later to another script.

Thanks bro! <3


EDIT:
Hmmm.... is it true that WWW downloads the file... but keeps it into memory??
I actually want to file just to be downloaded and stored on the HDD or SD (mobile) card. My file will be a pretty large mp4 and I don't want that loaded in memory.

EDIT2:
https://www.assetstore.unity3d.com/en/#!/content/78958

HMmmmmmmmmmmm........
Title: Re: Android - Download file to a location
Post by: jeanfabre on March 16, 2017, 01:54:27 AM
Hi,

 yes, but with script you can download and store in the Application persistent storage folder, So this is likely what this asset does, I have done projects that downloads from the web and then keep, so I know this is possible, but indeed requires scripting.

 If you keep struggling with this let me know.

Bye,

 Jean
Title: Re: Android - Download file to a location
Post by: PET on March 16, 2017, 05:11:07 AM
I decided to use Easy Action 2 PlayMaker actions so I'm downloading the file with that asset :) Works kind of nice.