Mysterious file management

will they be providing their own audio files on a google drive as well, or using the same ones you are testing with ?

> I was able to reproduce the problem even with just one or two GD download links.

Is this fact really compatible with a restriction on the part of Google to limit the large number of downloads? :thinking:

> In addition, after the problem appeared with Number ~40, I tried another GD link of my own. The same problem arose with this too.

For my part, I observe the opposite (see the video): my test application is blocked, but WhatsApp manages to download the same links without problem... If I come back to my app right after, it is still blocked ...

> The problem also occurs with Niotron; so it is not limited to AI2.

This can help, provided that Niotron has not taken the code from "App Inventor" to do the same thing... they look very similar...

> The same thing happens with my DownloadToASD extension.

Also interesting, if the Java code generated by "DownloadToASD" is different from that generated by "Web".

> will they be providing their own audio files on a google drive as well, or using the same ones you are testing with ?

Each teacher would use their own Google account as they wish. However, I am trying to see if it would be possible to find other accommodation options later...

> ...which then ensures the download action is generated by the file owner, which may overcome any restrictions...

I just did the test: I read a file several times on the GD of the same Google account as my phone this time. And the blockage happened around 50 downloads.

> I do, however like the idea of downloading the whole lot on initialise (zipped or not), then playing back locally. The OP seems averse to this idea though...

Anything that adds manipulation will result in teachers not wanting to use the application... The simple use of a link to share a file on a shared folder of a GD is already a lot for some...

That is not the same thing as I suggested....

You only need to change the blocks a bit to handle this, the files are already being downloaded, just only download them once, if they already exist on the device, then just call the local filename. I will do some blocks for this if I get time....bear in mind that most mobile phones these days have plenty of storage space.

I believe this will do it (not tested)

You will end up with all the files eventually downloaded, named nMAELtemp.mp3, where n is the URLIndex of the file in the list of urls.

Yes of course, I could still access the GD links via my PC or another external application.
But that's not the question, but whether it depends on the DG source. And that doesn't seem to be the case. Whether I retrieve the files from an external GD account or my own doesn't matter.

This system could at least limit the number of downloads, that's still it... Is there a way to make App Inventor just keep the name of the original files like "GI.mp3" or "GUE.mp3 “?

I did some more tests:

I managed to use a source other than GD to provide an .mp3 file online. I used DropBox. It is also possible to share a file with anyone who has the link. You only need to change "&dl=0" to "&dl=1" at the end of the address for the file to be downloadable...

So it works, I can listen to an .mp3 file downloaded from my DropBox.
And I managed to download and then listen to the same file more than 120 times without the bug occurring...
So it seems that this is a limitation of GD...

If this is really the case... Does this mean that my application which was easy to use, in reality, is not functional and I can't do anything? :cry:

Yes, as I said before, download the 14 files only once, play the one you need and delete these 14 files if desired at the end of using the app (e.g. when the app is closed).

Yes, when you get the url, also get the filename, and add this to a separate list that corresponds to the url list, e.g.

image

Then set the responsefilename to the actual filename in the filenames list using the url index:

I looked to see if there was a default limit on the number of downloads over a given time set up on Google Drive, but I couldn't find anything convincing...
And if I find a way to download an entire file at once, won't Google count the 14 downloads anyway?

Users discovered, at the beginning of 2023, that Google had introduced a limit of 5,000,000 files created per user without warning anyone, which was a scandal. But that doesn't concern me in my situation, it just shows that Google is capable of introducing hidden limitations without warning anyone...

I will write to them. But without much hope...

Yes, but you only do it once, after you have the 14 files, everything will happen on your phone/device, no more downloading....

Yes, you're right. However, when you manually download a folder from a computer, Google Drive offers a .Zip file. If it were possible to reproduce this from App Inventor: this one, by downloading a folder which is automatically unzipped on the phone, it would already be not bad and transparent for teachers. It would be enough to tell them that they put all the sound files for a given activity in a single folder (likely to be downloaded at the same time by all the students in a class). If only one class uses the activity, that's less than 30 downloads, it shouldn't bug. If 2 or more classes are involved in the activities, there could be problems again... But it is already the beginning of a solution...

This is all you need:

Try this one:

OK
Thank You
Is it this one?

Or try this

intDownload.aia (4.9 KB)

I have used images instead of mp3s, but the premise is the same.

View the first few images, then refresh the companion, you should not see the progress dialog until you reach a new file when you start viewing again. Once you have all the files then they view more or less immediately.

Here also is a short google apps script, bound to a google sheet, that writes file details to a google sheet:

function getFileIdAndNames() {

 var FileFolderID = 'YOUR FOLDER ID HERE'; // the ID of the folder with files
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];
 var urlCol = 1;
 var urlRow = 1;
 var folder = DriveApp.getFolderById(FileFolderID);
 var files = folder.getFiles();

 sheet.clear();

 while (files.hasNext()) {
 var file = files.next();
 
 
   if (file.getName().indexOf(".png") != -1) {
     sheet.getRange(urlRow, urlCol).setValue(file.getName());
     sheet.getRange(urlRow, urlCol+1).setValue(file.getId());
     sheet.getRange(urlRow, urlCol+2).setValue('https://drive.google.com/uc?export=download&id='+ file.getId());
     sheet.getRange(urlRow, urlCol+3).setValue('PNG');
     sheet.getRange(urlRow, urlCol+4).setValue(Math.round(file.getSize()/1000) + " KB");
     sheet.getRange(urlRow, urlCol+5).setValue(file.getName().substr(7).slice(0, -4));
   } 
   
 urlRow = urlRow+1;
 }
  sheet.sort(1, true);
  sheet.sort(4, true);
  sheet.insertRows(1);
  var title = [["Filename","File ID","Direct Link to Download","File Type","File Size (KB)","Description"]];
  var fontStyles = [ [ "bold", "bold", "bold", "bold", "bold","bold" ]];
  var titleRange = sheet.getRange("A1:F1");
  titleRange.setValues(title);
  titleRange.setFontWeights(fontStyles);
 }

Output:

Does the APK work for you?

Yes, it works. Although I still have a little trouble understanding the code. THANKS.
The proposal also works well with images. Thanks, it's good for the test application.

However, teachers will use a slightly different program.

Description of typical use:
1- A teacher creates an .mp3 file containing a word that corresponds to an image.
2- The teacher places this .mp3 file on his Google Drive (in a folder shared with anyone who has the link)
3- It retrieves the sharing link of this .mp3 file.
4- It uses a small application (that I programmed in python) which generates a QR code containing the Google Drive ID of the file.
5- He pastes this QR code into his document (created with Libre Office for example), next to an image which corresponds to the word contained in the .mp3.
6- He prints this document for his students.
7- The student uses the application on his parents' phone at home: he scans the QR code created by the teacher: he listens to the word corresponding to the image.

The teacher should be able to create, for example, a notebook with 30 images associated with 30 QR codes giving links to the corresponding sounds...
But if his 25 students, returning home at the same time, start their homework around the same time, well it's over: we explode the 40 downloads in 10 minutes (approximately...)

What could smooth things out a bit is a single download of the folder containing the audios in a single .zip

Example :
1- The Android application detects the name of the file (on GD) which is requested for reading.
2- It detects in its local memory if it already has the requested file.
3- If not, it detects the parent folder which contains the mp3 file on GD.
4- It downloads this entire folder in a single ZIP (a single download).
5- It unzips the archive into a local folder.
6- The Android app finds the requested file in this unzipped folder.
7- The Android app reads it.

But I think I understand that neither of those two proposals uses a similar procedure.