Vote count:
0
I am using Dart and its JS interop. I need to convert the following JavaScript code to Dart:
ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags("filename.mp3");
if (tags.artist)
artist.textContent = tags.artist;
if (tags.title)
track.textContent = tags.title;
}, {
dataReader: FileAPIReader(file)
});
Note the anonymous callback as the second parameter to loadTags
. How do I create that with Dart and the dart:js
library?
The closest I got was creating a named function with:
js.context['loadTagsCallback'] = () {
var tags = ID3.callMethod('getAllTags', ["filename.mp3"]);
if (tags.artist != null) {
artist.text = tags.artist;
}
if (tags.title != null) {
track.text = tags.title;
}
};
And then using this code:
ID3.callMethod('loadTags', ["filename.mp3", js.context['loadTagsCallback'],
new js.JsObject.jsify({'dataReader': id3FileReader})
]);
However, I don't want to create the named function. Any ideas or tips?
asked 21 secs ago
Aucun commentaire:
Enregistrer un commentaire