Parsing HTML file from SDCard

Hi,

I have some video content to show in the app. The video count is big (100+), so I cannot package them into the APK of the app.

The idea I am trying to follow is that I manually place the contents folder on SDCard, it will have one index.html file which will act as the index of videos, and all the videos would be present in a folder called 'videos' in the same directory. The simplest HTML coding will only give video name as hyperlink text, and clicking it should play the video. Since the app only needs to display the index.html file, I can manually update the contents of the folder (add more videos + put new index file) any time by only placing new contents folder on SDcard, without any need of app upgrade.

Is it feasible? How can I make the connection between the app and the contents folder on SDcard, and how to show index.html file?

Thanks,
Saad

Your html file will need to be in the same directory as your video files. How will you always show all the files? Do you expect the webviewer you use to show the html file to play the videos as well ?

Yes, this is what I have in mind. The HTML file will be in the same contents folder on the SDCard. The webviewer should read the HTML file from that location which will act as an index for all videos. How to do it?

You may want to consider using a file extension, which will return all the paths to the files in a folder, then use these paths to play the videos using the built in video player. No need for any html.

How do you intend to load the videos into a folder on the device, and how to handle file storage differences between pre and post Android 10?

Hi,

So I place the files in a folder in SD card, and trying to read the HTML file in that folder through webviewer. It works great in AI2 companion, but when I compile the application and install as a standalone APK, I am getting ERR_ACCESS_DENIED in webviewer. Plz suggest what to do.

Thanks,
Saad

Is this app just for your own use, when uploading new videos to the folder on your sdcard, or do you intend for this app to be available to others, on other devices?

Your problems on compilation are possibly due to file permissions?

Where are you saving the files on your sdcard?

What Android version are you using?

I intend to distribute it to a small group of users in the field (will do so by APK distribution, not playstore). So, other devices would be there.

I am placing files in /LMS on SDCard. The folder has one file index.html (which gives simple clickable hyperlinks to 5 videos), and the videos are present in /LMS/vdos folders.

The project has over 10GB of videos. Since these cannot be updated via app, the idea is that for any upgrade, we take out SD card, update the LMS folder containing new videos and a new index.html file, and the app remains the same. This way, I avoid updating the app again and again, and content update needs only updating folder on SD card.

Android version 8.

It may be a simple as asking for read permission for external storage, put these blocks in your screen initialise event for your compiled app. (asking for write permission will give you read permission as well)

However, it may be more complicated.....

Thanks. I coded the permission part, but its not offering any permission prompt, instead straight away rejecting the thing, saying:

ERROR 908: THE PERMISSION WRITE_EXTERNA_STORAGE HAS BEEN DENIED. PLEASE ENABLE IT IN THE SETTINGS APP.

In settings of this app, the permission tab is greyed out (disabled) automatically.

What to do now?

Can I try to access that html file via localhost URL? How do I point webserver root to that folder on SDcard for setting up some URL like http://localhost/LMS/index.html?

Did you spell it correctly ? Should be:

WRITE_EXTERNAL_STORAGE

Yes, its a typing mistake in this msg only.

Make a screenshot of this and post it here.

The WebViewer declares both permissions (READ / WRITE) in the Manifest.
So it should be possible to manually grant these permissions in the app settings.

Post the aia or send it privately via PM.
(Upload the APK to Google Drive and post the link.)

WebViewer have only this permission:

@SimpleObject
@UsesPermissions(permissionNames = "android.permission.INTERNET")

He must add file component.

I don't know if the built-in WebView component is able to display files from internal memory. It may be necessary to use the "CustomWebView" extension.

Oh, I didn't check this with AI2, because I assumed it would be the same as for Kodular:

But if the permissions are not declared in the Manifest, there shoud be no permissions in the app settings. So the greyed out part should not appear.

Well, I don't know how or why, but it has started working by itself. Although I was doing a clean install every time for the new app (deleting old app completely, and then installing new), but still it has started working without any proper logic I could identify. Here is my code in any case:

The app now prompts for the ACCESS PERMISSION TO STORAGE at initialization, and then displays the page comfortably.

What I am concerned now, is to find a proper way to access the SDcard contents. This path which is working for me (/storage/0000-0000/LMS/) does not seem to be the standard method of calling any sd card (I assume). I tried the code piece below (file:///mnt/sdcard/LMS/index.html) but somehow it opens the LMS folder present at the root of the phone memory (not the sdcard one - I checked very carefully by changing names).

What is the standard way/path of calling any content on the sdcard?