node-id3 icon indicating copy to clipboard operation
node-id3 copied to clipboard

[feature] Add support for React Native

Open PeeJeeDR opened this issue 4 years ago • 5 comments

Hi!

I would like to use this package in my React Native project for reading and writing id3 tags to mp3 files. I have tried to make it working myself, but I can't get it to work. Is there any chance this package could be compatible with React Native?

Thanks in advance!

PeeJeeDR avatar Oct 22 '21 16:10 PeeJeeDR

I think react-native will always fail to execute with node-id3 due to the fs/zlib module import. I'm not sure if there are ways to replace them at compile-time with react-native-fs/react-native-level-fs/react-native-zlib, otherwise I don't see how support can be achieved without creating a new module targeted for react-native

Zazama avatar Oct 23 '21 13:10 Zazama

Thank you for your response. I have indeed tried to use react-native-fs and react-native-zlib, all the errors where gone and my RN build was ok, but the raw output of ID3.read() for example was always empty. I've must have missed something.

Anyways, it was just an idea, I think it will be fairly used. Feel free to close this issue.

PeeJeeDR avatar Oct 24 '21 08:10 PeeJeeDR

Not sure what the problem is then, sorry.

As a workaround, you can also pass a buffer to ID3.read() instead of a filepath. Basically, read the file with react-native-fs and get it as buffer yourself, then pass it to ID3.read().

Same for ID3.write() and ID3.update()

Zazama avatar Oct 24 '21 22:10 Zazama

I will give it a try, thank you!

PeeJeeDR avatar Oct 26 '21 12:10 PeeJeeDR

I think react-native will always fail to execute with node-id3 due to the fs/zlib module import. I'm not sure if there are ways to replace them at compile-time with react-native-fs/react-native-level-fs/react-native-zlib, otherwise I don't see how support can be achieved without creating a new module targeted for react-native

Some thoughts for the future:

  • we should create two APIs on with file operations, one without file operation (which is more less the plan for the next major release)
  • we should try to inject zlib and fs at runtime and two entry points one injecting for node and another one without default injection

pbricout avatar Mar 22 '23 08:03 pbricout