aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
758 stars 127 forks source link

Text information frame (TXXX) returned incorrectly #119

Closed curtismenmuir closed 5 years ago

curtismenmuir commented 5 years ago

I have added this library to a react-native project and it successfully parses out all of the ID3 tags set on the file. When reading Text information frame's (TXXX) it always returns as "ÿþX" (with 'X' being the first character of the value of the frame). From my understanding, "ÿþ" is the Byte Order Marker for UTF-16 (LE). When I opened the MP3 in VLC then I can view the full value of the TXXX frames in the files metadata.

Returned tag information from jsmediatags:

TXXX: [{"id":"TXXX","size":39,"description":"User defined text information frame","data":{"user_description":"LICENCE TYPE","data":"ÿþO"}},....

I have had a look at getUserDefinedFields() function inside ID3v2FrameReader.js and the userDesc property is correctly parsed: (console.log) userDesc: {"_value":"LICENCE TYPE","bytesReadCount":28,"length":12} but the userDefinedData does not select the correct length :
(console.log) userDefinedData: {"_value":"ÿþO","bytesReadCount":4,"length":3}

Is there any way to get the full text value of this field?

curtismenmuir commented 5 years ago

Looking into this further, getUserDefinedFields() should pass charset into data.getStringWithCharsetAt() (ID3v2FrameReader.js line 679).

Current code: var userDefinedData = data.getStringWithCharsetAt(offset + 1 + userDesc.bytesReadCount, length - 1 - userDesc.bytesReadCount); -> var userDefinedData = data.getStringWithCharsetAt(offset + 1 + userDesc.bytesReadCount, length - 1 - userDesc.bytesReadCount, charset);

curtismenmuir commented 5 years ago

Will add PR with fix + test updates

curtismenmuir commented 5 years ago

120

curtismenmuir commented 5 years ago

Fix merged, closing issue.