aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
745 stars 128 forks source link

Add ArrayBufferFIleReader supperted #106

Closed TongDaDa closed 5 years ago

TongDaDa commented 5 years ago

Now, for my updated codes, It just supports the type of ArrayBuffer, but It also can support Uint8Array and other Class about binary by get buffer property of them. What do you think?

TongDaDa commented 5 years ago

Your codes are very beautiful, I learned a lot of design patterns of the programme. @aadsm

But, I have some problems below.

2019-01-12 12 09 25
   if (!isRangeValid(range, fileSize)) {
        continue;
   }

What means the continue in that for-loop, its under codes will execute whether it is true or false that the !isRangeValid(range, fileSize)

aadsm commented 5 years ago

@LiuTongTong in that code we're trying to figure out which media tag reader is able to read the metadata from the audio file. To do that each media tag reader reads a specific section of the file looking for a signature that will identify the metadata. We don't want to read the entire audio file just for that so we ask each tag reader what are the byte ranges where the signature exists, that's what getTagIdentifierByteRange returns. We then only load the part of the file that has those byte ranges. The if/continue you mention acts as a check to make sure the audio file itself is big enough for us to read the byte rages where the signature should be. For example, imagine the signature is in bytes [128-130], if the entire file is only 100bytes then we can't read that range so we skip that, that's why we continue.

TongDaDa commented 5 years ago

Tanks for your suggest! @aadsm

TongDaDa commented 5 years ago

@liutongtong in that code we're trying to figure out which media tag reader is able to read the metadata from the audio file. To do that each media tag reader reads a specific section of the file looking for a signature that will identify the metadata. We don't want to read the entire audio file just for that so we ask each tag reader what are the byte ranges where the signature exists, that's what getTagIdentifierByteRange returns. We then only load the part of the file that has those byte ranges. The if/continue you mention acts as a check to make sure the audio file itself is big enough for us to read the byte rages where the signature should be. For example, imagine the signature is in bytes [128-130], if the entire file is only 100bytes then we can't read that range so we skip that, that's why we continue.

OK, I understood your means, thanks for your answer for me.

TongDaDa commented 5 years ago

How do you think? i had changed these files @aadsm

aadsm commented 5 years ago

@TongDaDa hey, last weekend I ended up working on another project I have so didn’t have time to review this, sorry about that! I’ll check it this weekend, thank you for contributing!

aadsm commented 5 years ago

I’m able to understand your English just fine, it’s not a problem. I’m not a native either :-).

TongDaDa commented 5 years ago

Ok, I like to contribute some open-source projects, so could I develop opened-projects with you?

aadsm commented 5 years ago

Ok, I like to contribute some open-source projects, so could I develop opened-projects with you?

Yes, that would be great!

TongDaDa commented 5 years ago

Ok, I like to contribute to some open-source projects, so could I develop opened-projects with you?

Yes, that would be great!

hah, that is great, I'll learn a lot of knowledge about that.

aadsm commented 5 years ago

I've just merged and also added you to the list of contributors! https://github.com/aadsm/jsmediatags/blob/master/CONTRIBUTORS.md