aadsm / jsmediatags

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

Need a synchronous way as well to fetch tags #92

Closed krish512 closed 4 years ago

krish512 commented 6 years ago

This is a feature request

Current output format as {onSuccess:(), onError:()} works well for console.log() but to use this data it needs complicated callback structuring.

Can you provide the same output in multiple output formats like, jsmediatags.read("./music-file.mp3", cb(err, success));

Also, need a synchronous method for this like, let tags = jsmediatags.read("./music-file.mp3"); console.log(tags); // {success:{tags...}, error: false}

Regards, Krishna Modi

Stuart98 commented 5 years ago

I use this wrapping method to make it compatible with promises and the async/await syntax - it works well.

        async readMetadataAsync (file) {
        return new Promise((resolve, reject) => {
            jsmediatags.read(file, {
                onSuccess: resolve,
                onError: reject
            });
        });
    }
try {
    let output = await this.readMetadataAsync(file);

    console.log(output);
} catch (e) {
    console.log(e.message);
}
codenoobforreal commented 5 years ago

I use this wrapping method to make it compatible with promises and the async/await syntax - it works well.

        async readMetadataAsync (file) {
      return new Promise((resolve, reject) => {
          jsmediatags.read(file, {
              onSuccess: resolve,
              onError: reject
          });
      });
  }
try {
    let output = await this.readMetadataAsync(file);

    console.log(output);
} catch (e) {
    console.log(e.message);
}

thanks a lot for this nice approach

jeghers commented 2 years ago

None of these are working for me in the latest version. Did something change?