alexmercerind / flutter_media_metadata

A Flutter plugin to read 🔖 metadata of 🎵 media files. Supports Windows, Linux, macOS, Android, iOS & Web.
MIT License
69 stars 35 forks source link

Provide pure Dart support in case of a platform is not supported #15

Closed bdlukaa closed 3 years ago

bdlukaa commented 3 years ago

Imagine we try to run this project in the web, iOS or macOS. Likely, a Not Supported error will be thrown.

With a pure dart implementation of this, we could make this work for every platform. I am not saying to remove the native implementation, since they're faster than Dart, I'm saying to support all the platforms, regardless of how fast it is.

This could be done through ffi and add a pure dart implementation for the web, or just don't provide web support (I don't see how web apps would be manipulating media files, and if they do, that'd be uneffectively).

great project btw :)

alexmercerind commented 3 years ago

There are actually reasons for this to be not supported:

alexmercerind commented 3 years ago

For web, few people have ported libmediainfo to WASM, but I don't see a reason why would one force users to download 6 MB shared library, when they can just send metadata as JSON without having to parse the file.

bdlukaa commented 3 years ago

As I said, ffi is not the only way around this, only a possibility.

We could have a pure dart implementation, regardless of how fast it is, to support all the platforms.

Me, as a developer, get really frustrated when a plugin doesn't support the platform I'm targeting

alexmercerind commented 3 years ago

As I said, ffi is not the only way around this, only a possibility.

That's what I'd assume from a "pure Dart" title, and if you want to write entire parsing & reading in Dart, it will be really really slow (atleast 10 times). It will take years to come up with something comparable to existing MediaMetadataRetriever or LibMediaInfo. It will require extensive studying & implementation for supporting each codec/container and their tag specifications. It's no easy task. You'll end up creating your own TagLib in Dart, but a lot lot slower. I initially used an id3 reading project from pub.dev & my app used to parse music in ~20 seconds, but after this barely 4 seconds.

Supporting just particular tagging system e.g. ID3V2 etc. is not goal since I want to deal with all kind of formats.