video: play and then ftp

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

video: play and then ftp

Post by cusingerBUSCw5N » Wed Oct 26, 2016 6:48 am

I want to play a video on an android and then ftp the file to my server. I cannot do either. When I use this code, I get a response that the mp4 file has been found. But when it goes to play video, it crashes, by reverting to the original home page.

The ftp also doesn't work. I get a 0 file size on my server. What am I doing wrong? Thanks

If I delete the playing part, and just do the ftp, it fails as well.

Code: Select all

on mouseUp
   # Start by getting the file to upload
   if there is a file "/mnt/sdcard/testthis23.mp4" then
      answer "say hi"
put "/mnt/sdcard/testthis23.mp4" into tVideoFile
play video tVideoFile
put "/mnt/sdcard/testthis23.mp4" into tusedoc
       put url("binfile:"& specialFolderPath("documents") & "/testthis23.mp4") into url("ftp://myftpaddress/audio/testthis23.mp4")
answer "done"
      end if

end mouseUp

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

Re: video: play and then ftp

Post by Klaus » Wed Oct 26, 2016 11:49 am

Hi cusingerBUSCw5N ,

try again and supply USER NAME and PASSWORD for your FTP server 8)

Code: Select all

... into url("ftp://USERNAME:PASSWORD@myftpaddress/audio/testthis23.mp4")
You may need to URLENCODE both if thy conakin spaces etxc.

In cases like these ALWAYS check THER RESULT, it may give you some hints on what has gone wrong!

Code: Select all

...
put url("binfile:"& specialFolderPath("documents") & "/testthis23.mp4") into url("ftp://myftpaddress/audio/testthis23.mp4")
if the result <> EMTPY then 
  answer "An error occurred!" & CR & the result
...
Best

Klaus

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post by cusingerBUSCw5N » Wed Oct 26, 2016 3:24 pm

sorry I didn't show in my first post: I had my userID and password but removed them for this post

ftp://USERID:PASSWORD@ftp.FTPADDRESS

It can access my server (it posts a 0 size file) - but nothing goes through. When I did the error check, it never got there. It just crashed - didn't even go back to the home page.

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

Re: video: play and then ftp

Post by Klaus » Wed Oct 26, 2016 3:28 pm

I had a typo in my script, should read: if the result <> EMPTY then...

Hm, sorry, no brilliant idea, does it work if you do NOT play the video before uploading?
Did you test the FTP upload with a (small) file?

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post by cusingerBUSCw5N » Wed Oct 26, 2016 3:31 pm

I did a bit more testing. It is completely crashing when it tries to play the video. If I remove the playing code, then it does nothing - i.e. it doesn't get to the error message.

I can click directly on the mp4 using my Android and it plays. It's a very small file - goes for maybe 20 seconds. so file size isn't the issue

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: video: play and then ftp

Post by jacque » Wed Oct 26, 2016 5:40 pm

Android apps are sandboxed and it is likely you don't have permission to read from the root directory. (Imagine the security consequences if any app had access to all your files.)

You need to store the video in your app's documents folder, which does have permissions.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: video: play and then ftp

Post by Klaus » Wed Oct 26, 2016 6:19 pm

Makes sense!

Question is, is that video file really in the users documents folder?
In your script you have conflicting file loctions:
...
put "/mnt/sdcard/testthis23.mp4" into tVideoFile
play video tVideoFile
put "/mnt/sdcard/testthis23.mp4" into tusedoc
put url("binfile:"& specialFolderPath("documents") & "/testthis23.mp4") into url("ftp://myftpaddress/audio/testthis23.mp4")
...

"/mnt/sdcard/testthis23.mp4" <> specialFolderPath("documents") & "/testthis23.mp4"

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post by cusingerBUSCw5N » Wed Oct 26, 2016 9:40 pm

OK.... in theory. but I don't know how to place a video in specialFolderPath("documents") , since I have no idea where "documents" is in this silly Android. I see Android, DCIM, Download, Pictures...and a few others... but nothing called "documents"

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: video: play and then ftp

Post by jacque » Wed Oct 26, 2016 9:51 pm

Every app has its own documents folder that you can't see in an Android file browser without rooting the device. All you need to use is specialFolderPath("documents") as the folder identifier and the app will know where that is. So your file path would be, as you had in your original script:

Code: Select all

put specialFolderPath("documents") & "/testthis23.mp4" into tFilePath
Note that Android is case-sensitive, so don't capitalize "documents". You can both read and save files to that path.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post by cusingerBUSCw5N » Wed Oct 26, 2016 11:08 pm

Very interesting.... I decided to upload my video onto the android...and then test to see if I could download it again.

I installed a button on one card with this code:

Code: Select all

on mouseUp
   answer "start"
   libUrlDownloadToFile "https://mywebsite/vista_ee/vista_ee.mp4", specialfolderpath ("documents") & "/vista_ee.mp4"
   if there is a file (specialFolderPath("documents") & slash & "/vista_ee.mp4")  then
      answer "yep"
   else
      answer "no"
 
Amazingly it answered "yep" - meaning that the file was uploaded!   

So I put the same code on a button in the stack I'm using.... and got nothing.   No "yep"  no "no"  Just a "start"  and then nothing.
Same code, using a button same file... two different results.

This is enough to make me insane.

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post by cusingerBUSCw5N » Thu Oct 27, 2016 3:40 pm

Mysteries solved! All basic things I should have know. First - I found out that the tablet I am testing on doesn't play mp4s. It plays other videos, but not mp4s.

Second, download, I hadn't turned on the Internet on the Standalone Application Settings.

Third.... the two buttons that created different responses - that's because one stack had the internet turned on...the other one didn't.

Thanks for indulging my stupidity.

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

Re: video: play and then ftp

Post by Klaus » Thu Oct 27, 2016 3:44 pm

Glad you got it solved (more or less easily) :D

Hint: You have a SLASH too much here:
...
if there is a file (specialFolderPath("documents") & slash & "/vista_ee.mp4") then
...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”