Open cobarx opened 6 years ago
@davidroeca, is this something you have experienced?
@aadsm I honestly haven't tried, I've only worked with local files using the ReactNativeFileReader. The issue at hand is with https://github.com/aadsm/jsmediatags/blob/master/src/XhrFileReader.js
Maybe alternative logic for the following?
@davidroeca Let me give that a shot and see if I can get it to load xhr2. Fixing that might handle the rest of the issues. Will keep you guys posted.
I did a bit of reading and React Native's implementation of fetch & XMLHTTPRequest don't support binary blobs, so I don't think xhr2 will work either. They just landed binary blob support in 0.54 so once that is final, I'm going to take another look at this. I'm a bit too short on time to spend much time debugging at the moment.
Hi @cobarx do you by any chance gotten around the problem Offset 0 hasn't been loaded yet.
?
Just as a note for anyone still trying to solve this on RN. I had to essentially just replicate the overrideMimeType
function in XhrFileReader.js
in order to preven the error from being thrown, which I copied from the xhr2 library:
xhr.overrideMimeType = function(newMimeType) {
if (this.readyState === XMLHttpRequest.LOADING || this.readyState === XMLHttpRequest.DONE) {
throw new InvalidStateError("overrideMimeType() not allowed in LOADING or DONE");
}
this._mimeOverride = newMimeType.toLowerCase();
return void 0;
}
xhr.overrideMimeType("text/plain; charset=x-user-defined");
I've been trying to pull tags off mp3 and m4a files stored on a web server. This works great when I do it in node, but when I try from React Native I've been hitting a couple issues.
First, overrideMimeType is not implemented on the version of XMLHTTPRequest that ships with React Native. I attempted to force it to load xhr2 but didn't have much luck. I was able to get past that point by commenting out that call and replacing it with:
xhr._mimeOverride = "text/plain; charset=x-user-defined";
The next issue I ran into is that it's not properly retrieving the data. I get a warning:
Received data was not a string, or was not a recognised encoding.
It looks like this causes ChunkedFileData getByteAt to fail with:Offset 0 hasn't been loaded yet.
I'll look into this further tomorrow but was hoping you might have some insights on where to start.