Download one video / file

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Download one video / file

Post by aebki » Thu Mar 19, 2015 7:05 pm

Hi,

I was asking one question about video in another forum, and for one of my doubts, Klaus suggested me to write it in this forum! :-)

The summary of my question is that i was trying to download one video from my PC to one iPad or to one android phone.

So, i will use one database where i will place all the names of the videos i have and with one datagrid show this list to can choose one ( all what is concerning to database and datagrids of my example i am able to do it ).

But once he made the selection how can i download it? This video will be in this location: "/Users/aebki/Downloads/"

And if we use one public Ip it should be something like this:
"//myPublicIp/Users/aebki/Downloads/" '

So how can i download this to the iPad or the android phone?

Regards.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Download one video / file

Post by sefrojones » Thu Mar 19, 2015 8:01 pm

Are you trying to play the videos in a player object? If so does this work?

Code: Select all

set the filename of player "MyPlayer" to "http://myPublicIp/Users/aebki/Downloads/MyVideo.mp4"
I have had success playing videos from a public folder on my google drive this way.

--Sefro
Last edited by sefrojones on Thu Mar 19, 2015 8:22 pm, edited 1 time in total.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Thu Mar 19, 2015 8:12 pm

Hi Sefro,

Yes, the final target was to play the videos i have in my PC in one iPad or android phone.

But i thought that i had to download it to make it play. But if i don't need it is better! :-)

So i will try to test it this evening.

Once i will test it i will write telling if i managed. But if you already did it and it worked it is a very good sign for me! :-)

Regards

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Thu Mar 19, 2015 9:17 pm

Hi Sefro,

I tried it, but it is not working for me.
But i think that the problem i have is with the path.

In my Mac i have the video here: "Users/aebki/Downloads/Video2.mp4"
and my public ip is "8x.32.xx.182"

so this is the correct path and the correct code?

Code: Select all

set the filename of player "MyPlayer" to "http://8x.32.xx.182/Users/aebki/Downloads/Video2.mp4"
Because in the simulator is not working! :-(

And as for you is working i am thinking it is one problem of path.

Regards.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Download one video / file

Post by Klaus » Thu Mar 19, 2015 11:25 pm

Player objects are not supported on mobile and so setting the filename of a player on iOS won't do anything either! 8)

You need to create and use a native video player on iOS, like this:
http://lessons.runrev.com/m/4069/l/2928 ... -on-mobile

According to the dictionary about "mobilecontrolset" you can also supply a URL for the "filename" of the native player!

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Download one video / file

Post by sefrojones » Fri Mar 20, 2015 12:04 am

:oops: Oops, yes Klaus is correct. You will need to use a native mobile player object. You should still be able to set it's filename to the URL you'd like to use with "mobilecontrolset"
--Sefro

edit: just did a quick test of this on android and this worked. i just placed a regualr rectangle graphic place on the card in the location I wanted the player to appear, then put this in the opencard script of the card containing the video player:

Code: Select all

on openCard
mobileControlCreate "player", "videoControl"
   mobileControlSet "videoControl", "filename", "https://ia700408.us.archive.org/17/items/CC501_hypercard/CC501_hypercard_512kb.mp4"
   mobileControlSet "videoControl", "showController", true
   mobileControlSet "videoControl", "visible", true
   mobileControlSet "videoControl", "rect", the rect of grc "rectangle"
   mobileControlDo "videoControl", "play"
end openCard
it worked well on android, I assume it will work the same on iOS. Hope that helps.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Fri Mar 20, 2015 9:55 am

Hi Sefro,

It worked well your example! :-)
At least in my iPad simulator, so i imagine that it will work well too in the real device!:-)

The problem i have is when i change to look for one video i have in my Mac.

Do you know how i should pass my path? I have something wrong with this!:-(

//8x.32.xx.182/Users/aebki/Downloads/Video2.mp4

Regards.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Download one video / file

Post by sefrojones » Fri Mar 20, 2015 2:29 pm

In order for this to work for videos on your home computer, your home computer must be visible to the internet. You may also have to check your firewall and forward port 80 to the computer hosting the videos. One option, which I find better than hosting files on my own computer, is to use a public folder on google drive, it's free and you don't have to worry about making your personal computer accessible to the internet. Here is a tutorial on how to set up a folder in google drive:

https://support.google.com/drive/answer/2881970?hl=en

Once you have a public folder, you can upload your videos to it, and just point your mobile player at the google drive URL. This will also save you bandwidth and probably be faster. I know googles servers are faster than MY home computer and internet connection....


--Sefro
Last edited by sefrojones on Fri Mar 20, 2015 3:20 pm, edited 1 time in total.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Fri Mar 20, 2015 2:50 pm

Hi Sefro,

Yes, what you say is the 'correct way' i think! :-)
I was only trying to test it first in my computer before to have to do it from Google Drive or another storage site.

But yes, i can do it like you said!

Regards.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Fri Mar 20, 2015 5:01 pm

Hi Sefro,

So, i went to Google Drive and i uploaded one video to test.

I followed the steps in the link you gave.

So, now i have the video shared.

This is the link i have when i finished the steps:

"https://drive.google.com/file/d/0B-8LGB ... sp=sharing"

so the "doc id" is "0B-8LGBoJ3fIbVXpXb3JaX0M5M0lPdnN6SWdpdUgtUU5WT093"

I tried with this line

Code: Select all

mobileControlSet "videoControl", "filename", "www.googledrive.com/host/0B-8LGBoJ3fIbVXpXb3JaX0M5M0lPdnN6SWdpdUgtUU5WT093" 
and also with this one

Code: Select all

mobileControlSet "videoControl", "filename", "https://drive.google.com/host/0B-8LGBoJ3fIbVXpXb3JaX0M5M0lPdnN6SWdpdUgtUU5WT093" 
But anyone worked! :-(

Where is my mistake???

Regards.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Download one video / file

Post by sefrojones » Fri Mar 20, 2015 7:52 pm

aebki,

It appears that google may have changed the way that files are hosted since I last tried this, but here is a link to the exact tutorial that worked for me:

http://drivehosting.pdlindgren.us/


Instead of putting index.html into the folder, you can put your videos instead. and the URL to the video will be the URL displayed in step 8 with "/yourvideo.mp4" added to the end of it. Then surf to that location, and it will display in your web browser. Now you can copy the long URL in your browser and use that as the filename of your native player. I just tested this on android and it is working as expected.

Hope this helps.


-sefro


edit: the final URL you use as the filename will look something like this:

Code: Select all

https://4c1ae64e030ba6bc5bcb2510a44f0c754e5982b6.googledrive.com/secure/AIMa9vojKoRe2EBfwhNHdNjO5czw8N0ZHCgh4ObpPbfjMyflkYN2rhVQbc0m_eRRQCbQP4FcukbFeFWBiTt7VHIKVZAKpgtrDHpgCR3Cs7x3IvSMstfQ3EVk2FevRftXZdtS_6khPz1xTR_-JjO2NaOk0dUWXPIEQr543FIRsD68_Z_k2NyifdK0Bl4dSL3EtQ4i9nAEe-QWqCC4byEVWvRLjgluL_uies7_2wGt9meddReL-Y-ecmb9tVC8cCDHdSdDR385CwxHZq5mWvVl55W9cN374ZaxEDxH1ZJUiUmIh7yZxjQwVEiDiTsi3_qAQrOw9RRrA47j71O7lASr241ov_mkr8dTvEUJbW7dhKYxYgobcdBcosmmqSYhAPKl8G8GmPTqexJN0bGZ9CmkRiamGayjoUtnknbGKH8xkyw0KCVlpCo0sL-Ikd79yqhTBZljCWwWZa4WaHYm2jeiJKdz4eQs1jahdZO9CWC3WeZd0qSCdqkir1Y1mBcyewnA4kuDTPnpgZYbXU4QBWPNQQe1NfR3wbS7MKI_55JfjBVf6v-gMFWfoFZIiNQ1ATeHIAS_3IfkUGK2rb1MdveWq1ayaZsA4W15ng==/host/0B9myvEGzDKvCfjNXR0ZzQUxfSWxuemVZU2Z2UE4zUzhvWmJVdkxqYjlqQ1ZBV05IY2FIcDg/Lesson1.mp4
You can also use this method to host any other kind of file including livecode stacks :)

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Fri Mar 20, 2015 9:47 pm

Hi Sefro,

Thanks a lot, this time it worked well for me! :-)
I could see the video i have in Google Drive!:-)

Anyway, i am still curious to know how to download one video or file to the iPad or android phone.
So, how can i make one download? For example the same video that now i can see from the drive.

Regards.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Download one video / file

Post by sefrojones » Fri Mar 20, 2015 11:11 pm

If you want to download videos, you can download them to the specialfolderpath("Documents"). Depending how large these files are, they might take a while to actually download, so you'll probably want to give the user some kind of visual warning that it is downloading. Here, i Just use a field named "loading"

Code: Select all

put "Downloading..." into fld "Loading"
set the defaultfolder to specialfolderpath("Documents")
put url "http://path/to/yourfile.mp4" into URL "binfile:myfile.mp4"
put "DONE!" into fld "loading" 
and once the file is downloaded, we can play this file in a native player like this:

Code: Select all

put specialfolderpath("Documents")&"/myfile.mp4" into tPath
   mobileControlCreate "player", "videoControl"
   mobileControlSet "videoControl", "filename", tPath
   mobileControlSet "videoControl", "showController", true
   mobileControlSet "videoControl", "visible", true
   mobileControlSet "videoControl", "rect", the rect of grc "rectangle"
   mobileControlDo "videoControl", "play"
As before, I've tested this on android, and it is working, I assume that it will work as well on iOS. :)

--Sefro


Edit: You can skip the native player altogether with this :

Code: Select all

play video "path/to/video.mp4"
unfortunatley this option will leave your app, and if the user hits back button (at least on android) it will take them back out to the OS.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Download one video / file

Post by aebki » Sat Mar 21, 2015 12:39 pm

Hi Sefro,

Thanks a lot for your answer! :-)

I will test it a little bit later...anyway is already nice to know that is working for you!!!

Regards.

Post Reply

Return to “iOS Deployment”