Help - Search - Members - Calendar
Full Version: Adding/Modifying technical info entries
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
AoErat
I'm writing a small plugin to add a data field to a track.

Right now I'm doing something like this:

CODE

file_info_impl info;
track->get_info(info);
info.info_set("test_field","test_value");


... and then using update_info_async_simple to update the info. However, any fields I set with info_set are overwritten by this operation (I can add basic metadata fields just fine).

Is it possible to add custom technical info entries (or even update existing entries)? I don't want to use a metadata field because that writes directly to the file - I just want a field accessible through a title formatting variable.

Any thoughts?
Peter
What you're trying to do simply won't work / isn't possible. By calling update_info_* methods, you're already asking the backend to update file tags with the values that you pass, and technical information part gets ignored by tag writers.
Yirkha
To provide additional fields for use in title formatting strings at runtime, implement metadb_display_field_provider instead. (But be sure to read how it's meant to be used in foobar2000/SDK/metadb.h first.)
AoErat
Peter: Ok, that makes sense. I figured it was something like that.

Yirkha: I took a look at metadb_display_field_provider, and that does look like what I need.

Thanks for the replies folks, much appreciated.
AoErat
For those interested, here's how I did it:
CODE

class your_display_hook : public metadb_display_field_provider
{
public:
    bool process_field(t_uint32 index, metadb_handle * handle, titleformat_text_out * out);
    t_uint32 get_field_count();
    void get_field_name(t_uint32 index, pfc::string_base & out);
private:
};

bool your_display_hook::process_field(t_uint32 index, metadb_handle * handle, titleformat_text_out * out)
{
    if(index == 0) {
        // figure out what YOURSTRING will be
        out->write(titleformat_inputtypes::unknown,YOURSTRING.c_str(),YOURSTRING.length());
    }
    return true;
}

t_uint32 your_display_hook::get_field_count() {
    return 1;
}

void your_display_hook::get_field_name(t_uint32 index, pfc::string_base &out) {
    if(index == 0) {
        out.set_string("your_field_name",your_field_length);
    }
}

static service_factory_single_t<your_display_hook> display_hook;
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.