Closed krish512 closed 4 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);
}
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
None of these are working for me in the latest version. Did something change?
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