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 »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: video: play and then ftp

Post 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
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post 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.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: video: play and then ftp

Post 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?
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post 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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: video: play and then ftp

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: video: play and then ftp

Post 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"
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: video: play and then ftp

Post 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"
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: video: play and then ftp

Post 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.
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 »

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 »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: video: play and then ftp

Post 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
...
Post Reply