Help - Search - Members - Calendar
Full Version: How to Get the Title ,Artist, Album informations of the song that is p
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
fbs
//////////////
static const GUID cfg_title_guid =
{ 0x10845646, 0x3391, 0x4931, { 0xb2, 0x17, 0xa2, 0x2d, 0x34, 0x14, 0xf3, 0x3b } };
// {8ADA0C53-2EB8-4389-9FEC-457D2C2C2C01}

static cfg_string cfg_title(cfg_title_guid,"%title%");

track->format_title(NULL, title8, cfg_title, NULL);
///////////////////////

I tried to complie these codes in lastest verion of the SDK,but the third can't be complied, so how can I do to make it useful as before to get the such information?
foosion
You should use playback_control::playback_format_title() if you want data from the currently playing song. If you use the metadb_handle, you won't get any dynamic information. Also, you should compile your formatting script into a titleformat_object using the titleformat_compiler. There should be sample code for this here on the forum.
fbs
thank you smile.gif
eyebex
What if I do not want to have any formatting applied, but to get the plain title, album, artist etc. as specified in the tags (if any)? Is there an easier way (read: less lines of code) to retrieve this kind of information in that case?
eyebex
Found it: If you do not need formatting but just want to get the plain tag / metadata, you can do:

CODE
static_api_ptr_t<playback_control> pbc;
metadb_handle_ptr song;
if (pbc->get_now_playing(song)) {
    file_info_impl info;
    if (song->get_info(info)) {
        char const* title=info.meta_get("TITLE",0);
        char const* artist=info.meta_get("ARTIST",0);
        char const* album=info.meta_get("ALBUM",0);
        char const* genre=info.meta_get("GENRE",0);

        // [...]
    }
}
foosion
Note that there may be multiple values for a given field. Unless you have a specific reason to ignore additional values you should check for that.
eyebex
Hmm, in my case I'd like to just display the title etc. of the currently playing file on the desktop (using third-party software). I guess in such a case it does not make much sense to check for multiple "TITLE" tags fields within a single file, as I would display only one (i.e. the first) title anyways, or?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.