Author Topic: Newbie here, stuck on tutorial  (Read 9846 times)

2MuchToo

  • Newbie
  • *
  • Posts: 2
Hi!  Thanks to Steven and this community for the great player app.

I am interested in making a plugin.  I'm a total C# newb and it's a few years since I did coding at all. So I've been following the tutorial, but got stuck.  I believe the issue is where methods belong in the code, specifically createMenuItem() and MenuClicked, and/or the call to mbApiInterface.createmenuitem()






If I have the createmenuitem call in the Initialize method as per the instructions (highlighted), then
If createMenuItem() and MenuClicked are outside the Initialize code block, I get “Unreachable code detected”.  Everything still runs but there's no menu created.

If the 2 methods are inside the Initialize code block I get “The modifier private is not valid for this item.” Again it doesn't crash but no menu.

If I put mbApiInterface.createmenuitem() outside of Initialize method, I get “The name mbApiInterface.createmenuitem() does not exist in the current context.

I imagine this is a very simple error related to the flow of the code, but I am stumped. If someone could point me right it would be much appreciated!

Thanks!

karaluh

  • Jr. Member
  • **
  • Posts: 30
Same issue here. The code compiles, there are no warnings, but there is no menu entry either.

Code
namespace MusicBeePlugin
{
    public partial class Plugin
    {
        private MusicBeeApiInterface mbApiInterface;
        private PluginInfo about = new PluginInfo();

        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
          
            [some default code removed]

            createMenuItem();

            return about;
        }


        [some default code removed]

        private void createMenuItem() {
            mbApiInterface.MB_AddMenuItem("mnuTools/Start My Plugin", "HotKey For Start My Plugin", menuClicked);
        }

        private void menuClicked(object sender, EventArgs args) {
            Form1 myForm = new Form1(); myForm.Show();
        }
}
ListenBrainz plugin for MusicBee:
https://github.com/karaluh/ScrobblerBrainz

karaluh

  • Jr. Member
  • **
  • Posts: 30
My issue was my stupidity. I forgot to enable the plugin :P
ListenBrainz plugin for MusicBee:
https://github.com/karaluh/ScrobblerBrainz

Briter

  • Newbie
  • *
  • Posts: 1
LOL I have the same problem. (Solved)

It was API calling. You call an API before the API calling.
You need to use "createMenuItem();" after "mbApiInterface.Initialise(apiInterfacePtr);" in Initialise method.
Yeah. That's all. EZ fixed.  8)