Author Topic: Get unique Albums and Artwork  (Read 6293 times)

BoringName

  • Full Member
  • ***
  • Posts: 201
The OnSelectedFilesChanged event is called on the GUI thread. Other notifications are sent in a separate plugin thread, so you might need to invoke those events on to the GUI thread if OnSelectedFilesChanged  works

Well that's a day of my life I will never get back. So it turns out the invoke wasn't running at all and the panel wasn't losing focus or getting paused, I had a mouse move event that was setting off the trigger when I moused over the panel.

Long story short, I had another plugin installed that was silently throwing errors to the error log that I really should have checked sooner.... it was masking what my actual problem was. I ended up using the panel element for the invoke and it's all good now.

Thanks again for all your help.


hiccup

  • Sr. Member
  • ****
  • Posts: 7785
utterly off-topic:
As a non-coder I'm enjoying following this thread, and it makes me appreciate the work, effort and knowledge going into the software and the plugins so that mortals like me can use and enjoy it.
(and/or complain about it ;-)

BoringName

  • Full Member
  • ***
  • Posts: 201
As a non-coder I'm enjoying following this thread, and it makes me appreciate the work, effort and knowledge going into the software and the plugins so that mortals like me can use and enjoy it.

Not sure about the knowledge part for me, I've been giving google a work out the last few months:)

You certainly learn to appreciate the knowledge required to do this professionally, especially pre-google. Some of the OpenGL stuff for animations is pretty nuts. This thing just draws a flat square with a picture on it that moves around. Hate to think how much work would be involved drawing a full game environment....

I don't know if I should start another thread as the thread title issue has been resolved but it's all related to the same plugin so I'll stay in here for now...

2 more questions\issues
1. It looks like the notification TagsChanged never gets triggered. TagsChanging does and I'm using that one which works fine for what I need.

2. Is it possible to create config options in a plugin that show up in the "Panel Configuration Window"?. Eg) when you put the "wavebar" element into a panel, it shows an option to change the pixel height of the element.

I looked at a few other plugins and couldn't see any code for it. The only info I can find is for the panel that shows when you click the "configure" button in the Preferences-Plugin tab. And I can use that panel for the options I want but having them in the panel configuration window would be more user friendly.

And not really a big deal but just some resizing behavior I noticed. I don't know if it's intended or if I've coded something wrong or maybe just because I'm embedding a control into the panel but when I add this plugin to the main panel so its -
A-Z Jumpbar
Coverflow
files.
I can't adjust the height of the coverflow element, the width adjusts when the main panel width is adjusted. Now If I move it to below the files element so it's
A-Z Jumpbar
files
Coverflow
 I can adjust the height of Coverflow to what I want, then if I move it back to the first configuration, it will maintain the height I adjusted it to when it was in the second configuration.

I have tried 0 and -1 for DPIScaling but the behaviour is the same.

None of these issues are really a problem but figured they were worth mentioning in case something is amiss.

BoringName

  • Full Member
  • ***
  • Posts: 201
I lied, the TagsChanged event not triggering actually caused me issues but I figured it out.

I changed this line
about.ReceiveNotifications = ReceiveNotificationFlags.PlayerEvents;
to
about.ReceiveNotifications = ReceiveNotificationFlags.TagEvents;

Seems obvious really....

What threw me was getting the TagsChanging event. I figured if I was getting that one, why not the other. It probably shouldn't have been triggering when set to "PlayerEvents"?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
if you need both, just or the flags
about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
2. Is it possible to create config options in a plugin that show up in the "Panel Configuration Window"?. Eg) when you put the "wavebar" element into a panel, it shows an option to change the pixel height of the element.
use
Code
             about.ConfigurationPanelHeight = 100;   // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function
that will tell MB to reserve some space in the plugin panel
then in the Configure(IntPtr panelHandle) function
use something like this:
Code
            if (panelHandle != IntPtr.Zero)
            {
                Panel configPanel = (Panel)Panel.FromHandle(panelHandle);
                Label prompt = new Label();
                prompt.AutoSize = true;
                prompt.Location = new Point(0, 0);
                prompt.Text = "prompt:";
                TextBox textBox = new TextBox();
                textBox.Bounds = new Rectangle(60, 0, 100, textBox.Height);
                configPanel.Controls.AddRange(new Control[] { prompt, textBox });
            }
            return false;

BoringName

  • Full Member
  • ***
  • Posts: 201
if you need both, just or the flags
about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);

Yep, I did needed both, thanks.

With the config panel, It just creates options under "Preferences-> plugins". I've already created a custom config panel for that bit when the user clicks the configure button.

I was querying whether it's possible to add options in the panel settings area in the "Arrange Panels" configuration window like the wavebar element in the picture has.


It would be good to have a height adjust setting there when first settings it up without having to do the shenanigans I mentioned earlier, moving it to a spot where the height could be changed and then moving it back. I'll stick a height option in my config panel anyway so it's not really a problem, just figured if I could do it I would give it a go.

BoringName

  • Full Member
  • ***
  • Posts: 201
Is there any way to get the current library name or some kind of identifier in the api? I went over the MusicBeeInterface file a few times but couldn't see anything.

I could strip back a playlistUrl and get the folder name but that feels dirty and problematic if there are no playlists.


Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
no, unfortunately there isnt. I could add an id for the Setting_GetValue api

BoringName

  • Full Member
  • ***
  • Posts: 201
All good. I'm just setting up so playlists can be cached and I wanted the user selections to be saved between sessions.

It would have been easier if I could have saved a separate config file per library, I'll just have to change how I process the config files. Each playlistUrl will be unique even if the playlist name is used in multiple libraries so I can just work off that.

BoringName

  • Full Member
  • ***
  • Posts: 201
Code
string[] files;
Library_QueryFilesEx("domain=DisplayedFiles", files)

Just experimenting with this. Is there a notification I'm missing for when the files element changes?

I have no issue only displaying covers currently listed in the files element but I can't find a way to refresh it when the user clicks on something else, unless they actually select something and trigger the OnSelectedFilesChanged.

That doesn't trigger if the user is just selecting items in the navigator element like Audiobooks or different playlists.


Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
in the very latest v3.5 from the first forum topic i added a new notification type
SelectedNodeChanged = 42

BoringName

  • Full Member
  • ***
  • Posts: 201
in the very latest v3.5 from the first forum topic i added a new notification type
SelectedNodeChanged = 42

Perfect, thanks.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
but what if user have changed library filter rather than node? or just have filtered any current view using custom search? i believe there must be more general notification: DisplayedTracksChanged.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
There are many scenarios where the displayed files changes, some of which i expect you would want to ignore eg. as the user types in search text.
So for now i wont include all cases but have added to the patch version
SelectedFilterChanged = 43