Asking for help with ASD storage deleting issue

I figured that I would break up my prior question from 5 days ago since its may have been a bit too much to ask at one time. There have been numerous posts on how to delete an existing file within ASD storage, but i am still not able to figure this one out. I am attempting to download (and play) a most recent mp4 from a drive location. This file would be updated every few weeks so the existing file would need to be deleted from the “player” to then play the current one. With the current blocks,


an ASD directory is created within the android device, but it will not automatically play, nor will the prior mp4 file be deleted.
with these blocks, the file does download and automatically play, but i cannot delete the prior downloaded Player_Three.mp4 file due to android restrictions on deleting from a root directory. What am i missing??

thank you

You are trying to play the file before it has been downloaded completely… are you using an extension to download the file? Is there an AfterDownload event available?

Get the ASD version running and do not use a hard coded path to ASD, use the ApplicationSpecificDirectory method from my extension instead

Taifun

thank you Taifun. Excellent extension by the way. I did at some point try the afterdownload block, intent action, etc., but will try again.

By the way, the reason I thought to play the file before it has completed the download is that these blocks do allow the download to be played (at least on android 13 phone) before it has completed. this method, as long as google drive has a API associated with the URL, the mp4 actually “streams” into and is never downloaded, but cannot change file name, etc. so looking for the asd method instead.

trying your suggestions now. thanks again.

thanks but no luck-I changed the blocks (removed and placed action, event, etc and added to after download complete, but does not play. also tried with just the app specific block, then tried to join the app specific block with file name (Player_Three.mp4), also tried /Player_Three.mp4 in file name in activity starter/data URI suggestions?
test.aia (80.2 KB)


Show us a Do it result of the path… it looks like a slash is missing…

use the companion app together with Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps

see also Live Development, Testing and Debugging

Also I think, you do not have to delete the file, just overwrite it…

Taifun

You were absolutely right. I am familiar with the “Do it” function, but forgot to to check between adding the join block and just with the call application specific directory. I did add the necessary slash to correct the code, but player is still not playing


I have also confirmed that the mp4 file did download fully (30.9MB) but activity starter not playing

one of the issues that I am facing is the “Behaviour” that occurs between the android 13 phone ( i am designing in android 10, api 29) and the android tv box. As an example, Player_One.mp4 button/blocks


do work for the android 13 version, although there is a 602 error due to 2 activity starter blocks, but when added in this fashion, after error disappears, The mp4 “streams” in and is never saved to the device, but when i attempt to run this apk on the android box (still a 602 error), it opens a web browser, similar to the web view component, shows the file being downloaded automatically (due to integration with google drive api), but then requires interaction by clicking on “do you wish in install this?.” default KD player then plays mp4 on android box after clicking yes. i can remove this 602 error simply by adding a second activity starter, but what i am trying to show is that from the root storage, it is possible to play/stream immediately an mp4, but can never change that file name/delete/over right, etc. due to android security with deleting files. thats why i am attempting instead with asd to get this working. does not seem that the activity starter can start events if they are stored in a asd.

Shouldn’t that be ActivityStarter2?

Taifun

What happens if you try the videoplayer component instead of the activity starter?
Taifun

Yes. these blocks were just in back pack because I know that they work (to a point, but still require too much interaction on the end user part.) there is not an issue with player, other than i need to change back activity starter to 2. the issues are still with player 2 and 3


if you notice, player two blocks work perfectly to have mp4 play/stream into phone, so does player three, but ONLY if i change the file to a custom download location.

if i attempt to use asd, whether its the Taifun or ASD downloader1, it does create the folder and download the mp4 to an ASD, but does not “Play” mp4 like player 1 would. neither does the delete function work to remove prior player. I tested this by running the code, downloading an mp4, then uploading a different mp4 to the google api drive, but this new mp4 does not download and original mp4 is not replaced.

test (1).aia (80.8 KB)

if you download and try to run the aia you will see players 1 and 2 working, player 1 does have a 602 error, but we know thats because of 2 activity starters. in both cases, player 1 (streams/never saves/ downloads to phone) and player 2, both play file

ok… yes, other apps can’t access the ASD of your app, so when you want to use the activity starter to play the video, then it must be stored in shared storage
sorry, I haven’t seen that earlier…
Taifun

No problem! if you can think of anything, please let me know. Ive spent about a month on and off trying to figure this on out…Its definitely a unique application between ASD and video/slide show for a kiosk screen. Thanks again

If you want to use the activity starter, then the video must be stored in shared storage and NOT in ASD

Taifun

Thank you. Im still wondering why the ASD directory does not delete and download the updated mp4. you mentioned that i could probably overwrite the file, but this would just produce another file in ASD-Player_three.mp4(1), then Player_Three.mp4(2), Player_Three.mp4(3),etc. If I could figure out an app to access the ASD, then I would still need to do something with the naming convention so that the correct/updated mp4 file played. deleting these files first is important since each mp4 would be about 1gb. I will need to research permissions, but my understanding is that I could ask permissions to allow files in android shared storage to be deleted-i think Android 9 or less. What if the app was designed in a lower version of android, do you know what is the minimum level needed for the Taifun extension to work?

It looks like this is a feature of the extension you are using

Let me suggest the following workflow:

  1. Download the file to ASD
  2. Move the file to shared storage
  3. Play the file

Alternatively

  1. Download the file to shared storage
  2. Play the file
  3. Before downloading again, delete the file

Taifun

I definitely agree this would be a solution as the the first player already downloads to local storage, then the activity starter will play that mp4. this works great on an android 13 phone, but not on a android 10 tv box. when the app is installed and loaded onto the android box, the player one link opens a web browser, similar to the web viewer component on a phone. it downloads the file, but then has to be manually played/installed by selecting the downloaded file. player two works as it should, both on the phone and for the tv box. when player two is clicked, the file downloads into local storage, then is AUTOMATICALLY played. this is a perfect solution to what i am attempting to achieve. The problem with this method is as you said, i need to be onsite to first delete the prior Player_Two.mp4, prior to downloading the update mp4 otherwise the next download is named Player_Two.mp4(2) and the activity starter would to be pointing to Player_Two.mp4, not the updated mp4. i was trying to do this in a more automated way. when the end user wanted the new mp4 played on their kiosks, they would simply exit, or hit the back button on the app that I created, then selected/click player one, player two or player 3 button, depending on which kiosk they were in front of. Player one, player two or player three would then reach out to a hard coded google drive link inside the app that i would have uploaded a revision to (new mp4)

it seems the same issue would occur if moving from asd to shared storage, it would still move Player_Two.mp4 (2) and the activity starter would still be pointed to Player_Two.mp4, because local storage cannot rename/delete the existing file.

I’m not sure what you are talking about here…

You can delete programmatically files in ASD without limitation. And also in shared storage you can delete files. Precondition there is, that you own the file.

Taifun

Try this one: test_2.apk (4.4 MB)

Summary

1 Like

Thanks all
Traveling now for work but will definitely take a look at this tomorrow afternoon. Appreciate the help on this! Btw, im always pouring ovwr the forums to learn and for guidance. I was hoping Taifun and bodymindpower could pop in on answering. You two have helped me the most in reading other posts and your answers to them

Wow! Thats really cool. Just ran apk on phone and will try on android box tomorrow. I wont know until then but was avoiding using a media player because i thought it would be limited to the size of the phone screen. The actual mp4 presentation is 24.5" × 36" (62 cm x 81 cm) to be used on a 50" tv mounted in portrait mode. Again, i will have to try but it seems that a video player would be able to access asd and delete prior mp4 when new mp4 was updated versus the activity starter not being able to.