Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 static int show_id3(struct id3_tag const *tag)
- 2 {
- 3 unsigned int i;
- 4 int print = 0;
- 5 char emptystring[31];
- 6 char *names[6];
- 7 struct {
- 8 int index;
- 9 char const *id;
- 10 char const *name;
- 11 } const info[] = {
- 12 { 0, ID3_FRAME_TITLE, "Title : " },
- 13 { 1, ID3_FRAME_ARTIST, " Artist: " },
- 14 { 2, ID3_FRAME_ALBUM, "Album : " },
- 15 { 3, ID3_FRAME_YEAR, " Year : " },
- 16 { 4, ID3_FRAME_COMMENT,"Comment: " },
- 17 { 5, ID3_FRAME_GENRE, " Genre : " }
- 18 };
- 19
- 20 memset (emptystring, ' ', 30);
- 21 emptystring[30] = '\0';
- 22 /* Get ID3 tag if available, 30 chars except 4 for year */
- 23 for (i=0; i<=5; i++) {
- 24 names[i] = NULL;
- 25 names[i] = id3_get_tag(tag, info[i].id, (i==3) ? 4 : 30);
- 26 }
- 27 for (i=0; i<=5; i++) {
- 28 if (names[i]) {
- 29 print = 1;
- 30 break;
- 31 }
- 32 }
- 33 if (!print) {
- 34 return 0;
- 35 }
- 36
- 37 if (options.opt & MPG321_REMOTE_PLAY)
- 38 {
- 39 printf("@I ID3:");
- 40
- 41 for (i=0; i<=5; i++)
- 42 {
- 43 if(!names[i])
- 44 {
- 45 printf(emptystring);
- 46 }
- 47
- 48 else
- 49 {
- 50 printf(names[i]);
- 51 free(names[i]);
- 52 }
- 53 }
- 54 printf("\n");
- 55 } else {
- 56 /* Emulate mpg123 original behaviour */
- 57 for (i=0; i<=5; i++) {
- 58 fprintf (stderr, "%s", info[i].name);
- 59 if (!names[i]) {
- 60 fprintf (stderr, emptystring);
- 61 } else {
- 62 fprintf (stderr, names[i]);
- 63 free (names[i]);
- 64 }
- 65 if (i%2) fprintf (stderr, "\n");
- 66 }
- 67 }
- 68
- 69 return 1;
- 70 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement