Is it possible to read part of a file without loading the entire file in memory


#1

I have been trying to read ID3 tags and other metadata from media files (like mp3 files) stored on the sd card on Android (ultimately iOS too :wink: ).

I can read files and load their content in memory with https://ionicframework.com/docs/native/file/
using the readAsArrayBuffer method for instance.

The big drawback of this method is I must load the entire file into memory when obviously the meta data is only a few hundred bytes at the begninning or end.

It takes about 10 seconds per file with the current method. This is not acceptable for a large collection or even a single album.

So I need to find a way to read only part a a file that is stored on the SD card, a.k.a. externalRootDirectory.

Is there a cordova plugin for that? Is it even theoretically possible?


#2

Whose database is this? If it’s yours, add redundant information, and only pull up the real file if you need to.


#3

There is no database, I am talking about the mp3 files stored on my Android phone.


#4

Then no. What you can do is run an index in the background with a web worker. The user gives you access to 10 files say, and you load and read their metadata with FileReader while doing something else in the DOM.