Skip to main content

Topic: Help with writing a component utilizing index-data db / metadb_index_client (Read 629 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • MordredKLB
  • [*][*][*]
Help with writing a component utilizing index-data db / metadb_index_client
So I'm trying to write an alternate playback statistics component (foo_enhanced_playback_statistics) that functions exactly like the official v3.0.2 one except that instead of just recording the count, it stores a string containing a JSON object with all plays timestamped. Maybe it's possible to get it to function like the normal $meta_num / $meta(field, 5) stuff, but I'm not sure.

At the moment I've got a component using the playback_statistics_collector service which gets called after 60secs, and I can retrieve a titleformat string of "%artist% %album% $if2(%discnumber%,1) %tracknumber% %title%" (which is supposedly what foo_playcount uses for differentiating songs) and spit it to the console.

Of course, that doesn't get me very far. Documentation for how to actually use metadb_index_client is basically non-existent, and I guess I'm not smart enough to just figure it out from the method definitions in metadb.h.

So I think what I need to do is in the on_init I need to instantiate my own class based off metadb_index_client. But to do that I need to implement the transform method which seems to return an MD5 hash, but I can't for the life of me figure out how that method is supposed to look. Also that method takes a playable_location which maybe means that I need to call transform when the file is loaded and then cache the hashed value for using later in my playback_statistics_collector?

Anyway, once the playcount is ready to be incremented, I need to call metadb_index_manager->set_user_data which seems relatively straightforward. I also think metadb_display_field_provider probably isn't too bad.

Any help you guys could provide would be much appreciated. Ideally if you could point me towards the source of a component that's already doing something similar it would be super helpful. As it is, I'm flying blind right now. The really frustrating thing is that if the source for foo_playcount was available, I could probably knock this component out in an hour or two. I basically need exactly that, but with only 25% of the functionality.

Thanks.
  • Last Edit: 30 November, 2017, 02:42:51 AM by MordredKLB

  • MordredKLB
  • [*][*][*]
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #1
So is this really nothing that anybody is doing? From what I can tell playback statistics and foo_lyrics3 are the only components doing this sort of thing, and neither is open source which makes figuring out how this is supposed to work a lot harder.

Does anyone know of other components that are creating a metadb_index_client that are open source?


  • Peter
  • [*][*][*][*][*]
  • Administrator
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #2
I made a new foo_sample module implementing a simple rating database, just add this .cpp file to foo_sample project.
The next SDK update will include this.
I hope this helps.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #3
This looks very useful. Is there a way to make the custom fields/values appear in the Properties dialog on the Details tab.

  • Peter
  • [*][*][*][*][*]
  • Administrator
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #4
Now with more track_property_provider
  • Last Edit: 13 December, 2017, 08:02:56 AM by Peter

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #5
Excellent. Thank you very much.

  • MordredKLB
  • [*][*][*]
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #6
Thanks, Peter! I'll give this a look soon hopefully.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #7
Because I'm incredibly stupid, I've not figured out to get multiple fields working with a single GUID. Could the next SDK example include that as well?

For now, I've hacked around it with multiple GUIDs which seems to work fine. I'm using it to store playcounts from last.fm and I've finally been able to ditch foo_customdb (hooray!  :P )
  • Last Edit: 14 December, 2017, 01:30:15 PM by marc2003

  • Peter
  • [*][*][*][*][*]
  • Administrator
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #8
The data pinned to each guid+hash is a blob so it can hold anything that you want, you just have to pack it into a blob on your side. I'll add relevant code to foo_sample for the next update.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: Help with writing a component utilizing index-data db / metadb_index_client
Reply #9
Thanks again.