Author Topic: What's the API call for set a specific tag of the selected tracks?  (Read 681 times)

jonap

  • Full Member
  • ***
  • Posts: 129
I am new to plugins, so forgive me if it's a stupid question

But I can't seem to find a documentation for the API calls and I have no idea how one would go to find out the specific calls needed for their plugin, so could you show me some sort of documentation if I am just not looking properly?

Anyway, in my case, I want to just create some buttons that will set specific text to specific tags of the selected tracks.

Is this possible? And what are the API calls needed?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
no, there is no API documentation. you can read the source code of "MusicBeeInterface.cs" (search the forum for it), which is mostly self-explanatory, or download one of the open-source plugins as an example.

but what do you want to do that the tag tools plugin cannot? see the "advanced search & replace" command, "example: set tag" preset.

jonap

  • Full Member
  • ***
  • Posts: 129
I have a bunch of custom tags and need to manually add them to my library

So I wanted a simple floating window (the default window form of the plugin) to have buttons that add specific values to specific tags (like hardcoded)

Foe exemple a group of buttons with the label "color", btn-red, btn-green, btn-blue, that on click set "red", "green", "blue" in the custom tag "color" of the selected track, so that I don't have to manually write it each time

boroda

  • Sr. Member
  • ****
  • Posts: 4595
So I wanted a simple floating window (the default window form of the plugin) to have buttons that add specific values to specific tags (like hardcoded)

you can do this with the plugin i mentioned. you assign a hotkey or toolbar button to any preset. of course, you can create several copies of any preset so that every copy has its own options (the text to save tag for the preset i mentioned).

jonap

  • Full Member
  • ***
  • Posts: 129
could you please help on how to achieve that with ATRT plugin?

I currently use toolbar buttons in addition to Quick Tagger plugin, but the problem is that there is not enough space in the toolbar for my buttons.

So I suspect that ATRT would not solve my problem either.

So can you help me with the original question too? How do I select the selected tracks with API?

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1014
  • Heal The World
As boroda has already mentioned, the interface file will have a list of all available functions.
They have all been named appropriately and it'd be rare to encounter one that hasn't been discussed in depth on the forum - so a forum search will also do wonders here.
Feel free to ask further should you require more info.

So can you help me with the original question too? How do I select the selected tracks with API?
https://getmusicbee.com/forum/index.php?topic=20934.0

Anyway, in my case, I want to just create some buttons that will set specific text to specific tags of the selected tracks.
Is this possible? And what are the API calls needed?
Library_SetFileTag(string sourceFileUrl, MetaDataType field, string value)
Library_CommitTagsToFile(string sourceFileUrl)
MB_RefreshPanels()
Favourite song at the moment:   Decode by Paramore

jonap

  • Full Member
  • ***
  • Posts: 129
Thank you for the reply.

Quote
Feel free to ask further should you require more info.

I do have plenty of questions, though they are all cause I am new to coding in C#, so they are all very stupid questions, like the next one.

For the post you linked, I already looked at that, I just didn't understand what I am supposed to put as file-urls

Code
Library_QueryFilesEx("domain=SelectedFiles",files-urls)

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1014
  • Heal The World
Somebody I know always tells me that "there's no such thing as a stupid question" ;-)

string[] files;
Library_QueryFilesEx("domain=SelectedFiles", files)
The second parameter will store the file path(s) for the selected track(s) in a string array.

The delegates in the interface file do indicate what parameter types are used.
Code
public delegate bool Library_QueryFilesExDelegate(string query, out string[] files);
Last Edit: December 15, 2023, 03:56:20 PM by Mayibongwe
Favourite song at the moment:   Decode by Paramore

jonap

  • Full Member
  • ***
  • Posts: 129
wow, there might not be stupid questions, but I do feel stupid. Now I get it.Thank you.

By the way, since I am here for silly questions, I basically only added a contextMenu, that leads to a Windows Form, and I am trying to make some actions at the click of buttons

But when trying to put some code in
Code
public void button1_Click(object sender, EventArgs e){ 
//mbApiInterface
}
in Form1.cs file, mbApiInterface does not exists in the current context

I know the answer is very simple, but I am not able to figure out by myself what I am missing, and I looked at ATRT code too, but didn't find the solution

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1014
  • Heal The World
There's an open source plugin I created last year that you can have a look at.
A partial class is what I'd went with (working with the same class across different files). I made the mbApiInterface available as a global variable.
Favourite song at the moment:   Decode by Paramore

jonap

  • Full Member
  • ***
  • Posts: 129
Thank you for your help, I was able to understand the basics of it and have fun trying few things