diff --git a/examples/tagreader_c.c b/examples/tagreader_c.c index 0220e19a..04369926 100644 --- a/examples/tagreader_c.c +++ b/examples/tagreader_c.c @@ -51,23 +51,27 @@ int main(int argc, char *argv[]) tag = taglib_file_tag(file); properties = taglib_file_audioproperties(file); - printf("-- TAG --\n"); - printf("title - \"%s\"\n", taglib_tag_title(tag)); - printf("artist - \"%s\"\n", taglib_tag_artist(tag)); - printf("album - \"%s\"\n", taglib_tag_album(tag)); - printf("year - \"%i\"\n", taglib_tag_year(tag)); - printf("comment - \"%s\"\n", taglib_tag_comment(tag)); - printf("track - \"%i\"\n", taglib_tag_track(tag)); - printf("genre - \"%s\"\n", taglib_tag_genre(tag)); + if(tag != NULL) { + printf("-- TAG --\n"); + printf("title - \"%s\"\n", taglib_tag_title(tag)); + printf("artist - \"%s\"\n", taglib_tag_artist(tag)); + printf("album - \"%s\"\n", taglib_tag_album(tag)); + printf("year - \"%i\"\n", taglib_tag_year(tag)); + printf("comment - \"%s\"\n", taglib_tag_comment(tag)); + printf("track - \"%i\"\n", taglib_tag_track(tag)); + printf("genre - \"%s\"\n", taglib_tag_genre(tag)); + } - seconds = taglib_audioproperties_length(properties) % 60; - minutes = (taglib_audioproperties_length(properties) - seconds) / 60; + if(properties != NULL) { + seconds = taglib_audioproperties_length(properties) % 60; + minutes = (taglib_audioproperties_length(properties) - seconds) / 60; - printf("-- AUDIO --\n"); - printf("bitrate - %i\n", taglib_audioproperties_bitrate(properties)); - printf("sample rate - %i\n", taglib_audioproperties_samplerate(properties)); - printf("channels - %i\n", taglib_audioproperties_channels(properties)); - printf("length - %i:%02i\n", minutes, seconds); + printf("-- AUDIO --\n"); + printf("bitrate - %i\n", taglib_audioproperties_bitrate(properties)); + printf("sample rate - %i\n", taglib_audioproperties_samplerate(properties)); + printf("channels - %i\n", taglib_audioproperties_channels(properties)); + printf("length - %i:%02i\n", minutes, seconds); + } taglib_tag_free_strings(); taglib_file_free(file);