0

How can i get information from the file's url?

Eg: if i have the file

 char *my_file = /home/user/music.mp3 

How can i retrive:

File's title

artist

album

year

file type

1 Answer 1

1

You can use libid3tag for the MP3 stuff. Something like:

struct id3_file *id3_file; struct id3_frame const *frame; struct id3_tag *tag; id3_utf8_t *title=NULL; id3_file = id3_file_open (filename, ID3_FILE_MODE_READONLY); if (!id3_file) { // fail return } tag = id3_file_tag (id3_file); if (!tag) { // fail id3_file_close(id3_file); return; } /* get tag values */ frame = id3_tag_findframe (tag, ID3_FRAME_TITLE, 0); if (frame && (field = &frame->fields[1])) { if (id3_field_getnstrings (field) > 0) { title = id3_ucs4_utf8duplicate (id3_field_getstrings (field, 0)); } } /* ... etc ...*/ id3_file_close (id3_file); 
Sign up to request clarification or add additional context in comments.

2 Comments

That looks pretty interesting.But that works only with mp3 files right?
Yes, if you're looking for regular file information, use the Gio library. The GFile object can be created for a URI or a local path. From that you can get all sorts of info from the GFileInfo which you get by calling g_file_query_info() developer.gnome.org/gio/stable/GFileInfo.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.