Video Player - source

I need help with Video Player. I am using Taifun's FTP extension to download a 53MB .mp4 file.

The problem I am having is I don't know where to point VideoPlayer1.source to.

Where do i download .mp4 to so Video Player finds it by default ?

Thank you,

Carlos

you can download it to a directory of your choice
however if you want the app to work after App Inventor targets API 30 in late 2021, then you should download the file to the App Specific Directory
see also

in the videoplayer component just set the Source accordingly, see also Media

Source
Sets the “path” to the video. Usually, this will be the name of the video file, which should be added in the Designer.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Sorry I forgot to mention that I have 5 different .mp4 so I can not use the designer.

I have tried so many combinations of "path" to be used by "source" with no success.

To remove the ftp extension from the formula, i copy the mp4 to different folders on the sd card with bo success.

Example:

VideoPlayer1.Source=file:///storage/emulated/0/Android/data/appinventor.ai_biesys.HNC/files/Glucometer ENG.mp4

/Internal storage/Android/data/edu.mit.appinventor.aicompanion3/files/assets/Glucometer ENG.mp4

It is working now.

FTP dumps the file in:
/Android/data/edu.mit.appinventor.aicompanion3/files/assets

And "source" only uses the name of the file

Thank you Taifun for your help/

well, the assets directory does not seem to be a good choice, because the assets directory is read only after building the app...
why not using the application specific directory, which is
/storage/emulated/0/Android/data/<packageName>/files/

EDIT: afaik the video placer component expects a relative path, which woud be
/Android/data/<packageName>/files/yourVideo.mp4

Taifun

The simplest way (to download files / a video to the ASD) might be something like this:

Thank you Taifun and Anke.

The problem is not ftp downloading to a wrong folder. My Folder (in and out of companion was correct all along). I installed Anke extention to confirm and folder is not the problem.

The problem is the size of the File. VideoPlayer1 does not play it. It reports an error as "File not found" (very misleading).

I uploaded to my server another test mp4 i always use which is 770KB then used my App (not companion) to download it and Player worked fine.

So my only solution is a Video Player that can play any size mp4 files. Any recommendations ? I really don't want to use an external player.

Thank you again so much.

I never heard, that there is a filesize limit for the built in video player component..
do you like to share your relevant blocks, so we can check, if these are correct?

for other video players you might want to search the extensions directory App Inventor Extensions | Pura Vida Apps

Taifun

Very confusing thing is that mp4 (57MB) does play in companion but not when i generate the apk.

to find out, what is going on, you could use logcat

also which device and Android version are you using for your tests?

Taifun

Android 10
Samsung Galaxy Tab A 8"

I see my mp4 downloaded to the correct folder. I used Anke's tool to display the mp4 location.

I will next remove everything else from my "Play Video" button to see if thats the problem.

you are trying to start the video before it has been completely downloaded ...
use the AfterDownload event (or similar) and move all your blocks below the DownloadToASD method into that event

Taifun

The ftp process is done on another screen. It is only after download complete event, which turna Notifier progress bar off, that I am able to move to the second screen.

After file is downloaded the first time, i dont have the need to download again and proceed to the screen where the Player is. I just click on PlayVideo button and that's the block you see.

I moved "source" to the Main Menu module and out of the "PlayVideo" block.

a

The 770KB mp4 works fine at all times.

Will use logcat now.

1 Like

ok, I see, I have been confused by the method DownloadToASD.AppSpecificDirectory
which does not download anything, it just returns the path to the ASD (Application specific directory).. :slight_smile:

you are downloading the file to the ASD, but in your latest screenshot you do not set the correct path to the downloaded file (your large blue arrow).... use again the method DownloadToASD.AppSpecificDirectory together with your file name, as already mentioned earlier it must be a relative path for the video player component...

/Android/data/<packageName>/files/yourVideo.mp4

also it would help you very much to use Do it to debug your blocks to find out, if the path is correct...
see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Eureka !! (We should bring that exclamation back)

Now it works only as the apk and not inside companion.

  1. VideoPlayer1.Source moved out of the "PlayVideo" block.
  2. VideoPlayer1.Source = Anke's "DownloadToASD" element & "/" & mp4 file name.

Thank you both !!

Now, to the next headache lol

Try this and use the absolute path for the VideoPlayer.Source.
It downloads a 72MB video from Google Drive to the ASD and plays it with Companion:

video

grafik

Thank you Anke.