Page 1 of 1

video: play and then ftp

Posted: Wed Oct 26, 2016 6:48 am
by cusingerBUSCw5N
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

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 11:49 am
by Klaus
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

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 3:24 pm
by cusingerBUSCw5N
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.

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 3:28 pm
by Klaus
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?

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 3:31 pm
by cusingerBUSCw5N
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

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 5:40 pm
by jacque
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.

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 6:19 pm
by Klaus
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"

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 9:40 pm
by cusingerBUSCw5N
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"

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 9:51 pm
by jacque
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.

Re: video: play and then ftp

Posted: Wed Oct 26, 2016 11:08 pm
by cusingerBUSCw5N
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.

Re: video: play and then ftp

Posted: Thu Oct 27, 2016 3:40 pm
by cusingerBUSCw5N
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.

Re: video: play and then ftp

Posted: Thu Oct 27, 2016 3:44 pm
by Klaus
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
...