Avoid Polling when waiting for a trackchange.

Sep 9, 2009 at 7:40 PM

Hi there,

Your little app is very clean in the way you exposed plugins and all.. I really appreciate and I already have made a plugin within seconds ! that's vers good !

Nevertheless, I came across your routine to guess when a new track is playing and you're basically polling every half-a-second to see if the new windows title is any different as the previous one..

That's maybe a bit too naive an approach as you could for instance register some hooks to get the WM_SETTEXT window message to trigger this action... of course this might need a bit of native code :(

other than that, I really like the software and it saved me a lot of time making my own little features...

 

One thing that I had to do, though, was to make the Spotify class public so I could referenfe it from my plugin to use SendAction.. Maybe those things should be moved to an other project ( such as pluginbase ) to avoir circular reference ( luckily as it is loaded dynamically, VIsual Studio doesn't insult me if I add a reference on the Toastify assembly in my plugin) but it might be a little bit cleaner, and furthermore, I wouldn't have to change your code then ;)

Cheers, Fabio

Coordinator
Sep 15, 2009 at 6:33 PM

Hi,

It's not possible to create a system wide hook with .net languages. But I think I have found a way around this.

If you want I would really appreciate some help testing this experimental version. So if your up for it, send me a message from the main page and I will see to it that you get a version without the constant polling for track change. 

/Jesper

Sep 16, 2009 at 7:39 AM
Edited Sep 16, 2009 at 7:41 AM

Hi !

I'd be glad to test your experimental version !

 

By the way, while you're at it, you might want to fix a little bug : when the artist is "Spotify", the parsing is not done correctly and it ends up with an empty string, thus resulting in displaying the track infos incorrectly ;)

 

You might change the following line :

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

return

</font></font><font size="2" color="#0000ff">

 

</font>

sb.ToString().Replace("Spotify", "").TrimStart(' ', '-').Trim();

with something like a Split or regex to only remove the first occurency