diff --git a/include/MDE/Sound/Sound.h b/include/MDE/Sound/Sound.h index 9659ebe..04f070f 100644 --- a/include/MDE/Sound/Sound.h +++ b/include/MDE/Sound/Sound.h @@ -18,10 +18,11 @@ struct _MDESoundContext { int frames; void* opaque; - char* title; - char* album; - char* artist; - char* genre; + char* title; + char* album; + char* artist; + char* genre; + unsigned int track; }; struct _MDESoundDriver { diff --git a/sound/drv_mp3.c b/sound/drv_mp3.c index a3b3fde..e06f85b 100644 --- a/sound/drv_mp3.c +++ b/sound/drv_mp3.c @@ -6,12 +6,24 @@ static MDESoundContext mp3_open(const char* path) { MDESoundContext ctx = malloc(sizeof(*ctx)); + char* s; memset(ctx, 0, sizeof(*ctx)); ctx->title = MDEID3GetString(path, "TIT2"); ctx->artist = MDEID3GetString(path, "TPE1"); ctx->album = MDEID3GetString(path, "TALB"); ctx->genre = MDEID3GetString(path, "TCON"); + ctx->track = 0; + + s = MDEID3GetString(path, "TRCK"); + if(s != NULL) { + char* t = strchr(s, '/'); + if(t != NULL) t[0] = 0; + + ctx->track = atoi(s); + + free(s); + } ctx->opaque = malloc(sizeof(drmp3)); if(!drmp3_init_file(ctx->opaque, path, NULL)) { diff --git a/sound/drv_vorbis.c b/sound/drv_vorbis.c index 2f3e5c1..f84157b 100644 --- a/sound/drv_vorbis.c +++ b/sound/drv_vorbis.c @@ -36,6 +36,8 @@ static MDESoundContext vorbis_open(const char* path) { ctx->artist = MDEStringDuplicate(p + 1); } else if(strcasecmp(s, "GENRE") == 0) { ctx->genre = MDEStringDuplicate(p + 1); + } else if(strcasecmp(s, "TRACK") == 0) { + ctx->track = atoi(p + 1); } }