Only getting the first letter for every tag, or may be I am wrong somewhere
void info() {
MP3Instance mp3instance = new MP3Instance("/storage/emulated/0/Download/Army_320-(Mr-Jat.in).mp3");
if(mp3instance.parseTagsSync()){
print(mp3instance.getMetaTags());
print(mp3instance.metaTags['Title']);
print(mp3instance.metaTags['Artist']);
print(mp3instance.metaTags['Album']);
print(mp3instance.metaTags['Year']);
print(mp3instance.metaTags['Genre']);
}
}
and here is the output
I/flutter ( 6995): {Version: v2.3.0, Title: A
I/flutter ( 6995): A
I/flutter ( 6995): S
I/flutter ( 6995): H
I/flutter ( 6995): 2
I/flutter ( 6995): M
Only the first alphabet of text appears and the stops.
I printed out the ASCII equivalent of mp3instance.getMetaTags()
and realized that the string has some ASCII control characters in it which terminates the print()
statement.
After some research I used this method to remove the control characters:
String normalizeString(String s) {
var encoded = ascii.encode(s.toString());
List<int> normalized = new List.from(encoded.map((e) => (e < 32) ? 32 : e));
return ascii.decode(normalized);
}
I printed the normalized string as follows:
print( "Before normalizing: " + mp3instance.getMetaTags().toString() );
String normalString = normalizeString( mp3instance.getMetaTags().toString() );
print( "After normalizing: " + normalString);
print( "Normalized title: " + mp3instance.metaTags['Title'].toString() );
More resources: