Skip to main content
Topic: Adding/Modifying technical info entries (Read 2959 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Adding/Modifying technical info entries

I'm writing a small plugin to add a data field to a track.

Right now I'm doing something like this:

Code: [Select]
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?

Adding/Modifying technical info entries

Reply #1
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.

Adding/Modifying technical info entries

Reply #2
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.)
Full-quoting makes you scroll past the same junk over and over.

Adding/Modifying technical info entries

Reply #3
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.

Adding/Modifying technical info entries

Reply #4
For those interested, here's how I did it:
Code: [Select]
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;

 
SimplePortal 1.0.0 RC1 © 2008-2019